You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
spring-boot/spring-boot-tools/spring-boot-loader-tools
Janne Valkealahti 4c9c2b8dcf Tweaks for boot gradle plugin
Fixes gh-152.

... to ease excluding dependencies
eckage changed to bootRepackage

- Register BootRepackage order to use task foo(type: BootRepackage){}
- Allow user to use customConfiguration

configurations {
  hadoopruntime.exclude group: 'log4j'
  hadoopruntime.exclude group: 'org.slf4j'
  hadoopruntime.exclude group: 'org.apache.hadoop'
  hadoopruntime.exclude group: 'org.apache.hive'
  hadoopruntime.exclude group: 'commons-logging'
  hadoopruntime.exclude group: 'org.codehaus.jettison'
  hadoopruntime.exclude group: 'com.thoughtworks.xstream'
}
dependencies {
  compile "org.springframework.batch:spring-batch-core:$springBatchVersion"
  compile "org.springframework.batch:spring-batch-infrastructure:$springBatchVersion"
  compile "org.springframework.data:spring-yarn-batch:$springDataVersion"
  compile "org.springframework.data:spring-yarn-boot:$springDataVersion"
  runtime "org.springframework.data:spring-data-hadoop:$springDataVersion"
  runtime "org.springframework.data:spring-data-hadoop-core:$springDataVersion"
  runtime "log4j:log4j:$log4jVersion"
  runtime "org.slf4j:slf4j-log4j12:$slf4jVersion"
  testCompile "org.springframework.data:spring-yarn-test:$springDataVersion"
  testCompile "org.hamcrest:hamcrest-core:$hamcrestVersion"
  testCompile "org.hamcrest:hamcrest-library:$hamcrestVersion"
  hadoopruntime configurations.runtime
}

springBoot {
  backupSource = true
  customConfiguration = 'hadoopruntime'
}

task appmasterJar(type: Jar) {
  appendix = 'appmaster'
  from sourceSets.main.output
  exclude('**/*Container*')
  exclude('**/*Client*')
}

task clientJar(type: Jar) {
  appendix = 'client'
  from sourceSets.main.output
  exclude('**/*Appmaster*')
  exclude('**/*Container*')
}

task clientBoot(type: BootRepackage, dependsOn: clientJar) {
  withJarTask = clientJar
}

task appmasterBoot(type: BootRepackage, dependsOn: appmasterJar) {
  customConfiguration = "hadoopruntime"
  withJarTask = appmasterJar
}

//jar.enabled = false
//bootRepackage.enabled = false

task bootJars
bootJars.dependsOn = [clientBoot,containerBoot,appmasterBoot]

build.dependsOn(clientBoot)
build.dependsOn(containerBoot)
build.dependsOn(appmasterBoot)
//build.dependsOn(bootJars)
11 years ago
..
src Tweaks for boot gradle plugin 11 years ago
README.md Documentation updates 11 years ago
pom.xml Reinstate git commit ID in loader tools manifest 11 years ago

README.md

Spring Boot - Loader Tools

The Spring Boot Loader Tools module provides support utilities to help when creating Spring Boot Loader compatible archives. This module is used by the various build system plugins that we provide.

Note: The quickest way to build a compatible archive is to use the spring-boot-maven-plugin or spring-boot-gradle-plugin.

Repackaging archives

To repackage an existing archive so that it becomes a self-contained executable archive use org.springframework.boot.loader.tools.Repackager. The Repackager class takes a single constructor argument that refers to an existing jar or war archive. Use one of the two available repackage() methods to either replace the original file or write to a new destination. Various settings can also be configured on the repackager before it is run.

Libraries

When repackaging an archive you can include references to dependency files using the org.springframework.boot.loader.tools.Libraries interface. We don't provide any concrete implementations of Libraries here as they are usually build system specific.

If your archive already includes libraries you can use Libraries.NONE

Finding a main class

If you don't use Repackager.setMainClass() to specify a main class, the repackager will use ASM to read class files and attempt to find a suitable class. The first class with a public static void main(String[] args) method will be used. Searching is performed using a breadth first algorithm, with the assumption that the main class will appear high in the package structure.

Example

Here is a typical example repackage:

Repackager repackager = new Repackager(sourceJarFile);
repackager.setBackupSource(false);
repackager.repackage(new Libraries() {
			@Override
			public void doWithLibraries(LibraryCallback callback) throws IOException {
				// Build system specific implementation, callback for each dependency
				// callback.library(nestedFile, LibraryScope.COMPILE);
			}
		});

Further Reading

For more information on how Spring Boot Loader archives work take a look at the spring-boot-loader module. If you want to see how we use this library the Maven and Gradle plugins are good place to start.