Add mainClass option for Repackage task

Add `mainClass` property option to the Repackage task. If the property
is defined within a task, it works in the same way as if it defined
within the springBoot{} 'ext' properties section.

Option is valid only for that specific task where it is defined, and
will override option defined in springBoot{} ext properties.

Fixes gh-283
pull/236/head
Janne Valkealahti 11 years ago committed by Phillip Webb
parent ed9735361e
commit 32453b27d3

@ -32,6 +32,7 @@ import org.springframework.boot.loader.tools.Repackager;
* Repackage task.
*
* @author Phillip Webb
* @author Janne Valkealahti
*/
public class Repackage extends DefaultTask {
@ -41,6 +42,8 @@ public class Repackage extends DefaultTask {
private Object withJarTask;
private String mainClass;
public void setCustomConfiguration(String customConfiguration) {
this.customConfiguration = customConfiguration;
}
@ -49,6 +52,10 @@ public class Repackage extends DefaultTask {
this.withJarTask = withJarTask;
}
public void setMainClass(String mainClass) {
this.mainClass = mainClass;
}
@TaskAction
public void repackage() {
Project project = getProject();
@ -64,6 +71,7 @@ public class Repackage extends DefaultTask {
else if (extension.getCustomConfiguration() != null) {
libraries.setCustomConfigurationName(extension.getCustomConfiguration());
}
project.getTasks().withType(Jar.class, new Action<Jar>() {
@Override
@ -99,7 +107,9 @@ public class Repackage extends DefaultTask {
}
};
};
repackager.setMainClass(extension.getMainClass());
repackager
.setMainClass(Repackage.this.mainClass != null ? Repackage.this.mainClass
: extension.getMainClass());
if (extension.convertLayout() != null) {
repackager.setLayout(extension.convertLayout());
}

Loading…
Cancel
Save