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
This commit is contained in:
parent
ed9735361e
commit
32453b27d3
|
|
@ -32,6 +32,7 @@ import org.springframework.boot.loader.tools.Repackager;
|
||||||
* Repackage task.
|
* Repackage task.
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
|
* @author Janne Valkealahti
|
||||||
*/
|
*/
|
||||||
public class Repackage extends DefaultTask {
|
public class Repackage extends DefaultTask {
|
||||||
|
|
||||||
|
|
@ -41,6 +42,8 @@ public class Repackage extends DefaultTask {
|
||||||
|
|
||||||
private Object withJarTask;
|
private Object withJarTask;
|
||||||
|
|
||||||
|
private String mainClass;
|
||||||
|
|
||||||
public void setCustomConfiguration(String customConfiguration) {
|
public void setCustomConfiguration(String customConfiguration) {
|
||||||
this.customConfiguration = customConfiguration;
|
this.customConfiguration = customConfiguration;
|
||||||
}
|
}
|
||||||
|
|
@ -49,6 +52,10 @@ public class Repackage extends DefaultTask {
|
||||||
this.withJarTask = withJarTask;
|
this.withJarTask = withJarTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMainClass(String mainClass) {
|
||||||
|
this.mainClass = mainClass;
|
||||||
|
}
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
public void repackage() {
|
public void repackage() {
|
||||||
Project project = getProject();
|
Project project = getProject();
|
||||||
|
|
@ -64,6 +71,7 @@ public class Repackage extends DefaultTask {
|
||||||
else if (extension.getCustomConfiguration() != null) {
|
else if (extension.getCustomConfiguration() != null) {
|
||||||
libraries.setCustomConfigurationName(extension.getCustomConfiguration());
|
libraries.setCustomConfigurationName(extension.getCustomConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
project.getTasks().withType(Jar.class, new Action<Jar>() {
|
project.getTasks().withType(Jar.class, new Action<Jar>() {
|
||||||
|
|
||||||
@Override
|
@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) {
|
if (extension.convertLayout() != null) {
|
||||||
repackager.setLayout(extension.convertLayout());
|
repackager.setLayout(extension.convertLayout());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue