commit
72361a7521
@ -1,109 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.gradle.plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.gradle.api.InvalidUserDataException;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.file.FileCollection;
|
||||
import org.gradle.api.plugins.JavaApplication;
|
||||
import org.gradle.api.provider.Property;
|
||||
|
||||
import org.springframework.boot.gradle.dsl.SpringBootExtension;
|
||||
import org.springframework.boot.loader.tools.MainClassFinder;
|
||||
|
||||
/**
|
||||
* A {@link Callable} that provides a convention for the project's main class name.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
final class MainClassConvention implements Callable<String> {
|
||||
|
||||
private static final String SPRING_BOOT_APPLICATION_CLASS_NAME = "org.springframework.boot.autoconfigure.SpringBootApplication";
|
||||
|
||||
private final Project project;
|
||||
|
||||
private final Supplier<FileCollection> classpathSupplier;
|
||||
|
||||
MainClassConvention(Project project, Supplier<FileCollection> classpathSupplier) {
|
||||
this.project = project;
|
||||
this.classpathSupplier = classpathSupplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
SpringBootExtension springBootExtension = this.project.getExtensions().findByType(SpringBootExtension.class);
|
||||
if (springBootExtension != null) {
|
||||
String mainClass = springBootExtension.getMainClass().getOrNull();
|
||||
if (mainClass != null) {
|
||||
return mainClass;
|
||||
}
|
||||
}
|
||||
String javaApplicationMainClass = getJavaApplicationMainClass();
|
||||
return (javaApplicationMainClass != null) ? javaApplicationMainClass : resolveMainClass();
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "deprecation" })
|
||||
private String getJavaApplicationMainClass() {
|
||||
JavaApplication javaApplication = this.project.getConvention().findByType(JavaApplication.class);
|
||||
if (javaApplication == null) {
|
||||
return null;
|
||||
}
|
||||
Method getMainClass = findMethod(JavaApplication.class, "getMainClass");
|
||||
if (getMainClass != null) {
|
||||
try {
|
||||
Property<String> mainClass = (Property<String>) getMainClass.invoke(javaApplication);
|
||||
return mainClass.getOrElse(null);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Continue
|
||||
}
|
||||
}
|
||||
return javaApplication.getMainClassName();
|
||||
}
|
||||
|
||||
private static Method findMethod(Class<?> type, String name) {
|
||||
for (Method candidate : type.getMethods()) {
|
||||
if (candidate.getName().equals(name)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String resolveMainClass() {
|
||||
return this.classpathSupplier.get().filter(File::isDirectory).getFiles().stream().map(this::findMainClass)
|
||||
.filter(Objects::nonNull).findFirst().orElseThrow(() -> new InvalidUserDataException(
|
||||
"Main class name has not been configured and it could not be resolved"));
|
||||
}
|
||||
|
||||
private String findMainClass(File file) {
|
||||
try {
|
||||
return MainClassFinder.findSingleMainClass(file, SPRING_BOOT_APPLICATION_CLASS_NAME);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.gradle.plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.InvalidUserDataException;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.file.FileCollection;
|
||||
import org.gradle.api.file.RegularFileProperty;
|
||||
import org.gradle.api.plugins.BasePlugin;
|
||||
import org.gradle.api.plugins.Convention;
|
||||
import org.gradle.api.plugins.JavaApplication;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.provider.Provider;
|
||||
import org.gradle.api.tasks.Classpath;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.Optional;
|
||||
import org.gradle.api.tasks.OutputFile;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.api.tasks.TaskProvider;
|
||||
|
||||
import org.springframework.boot.gradle.dsl.SpringBootExtension;
|
||||
import org.springframework.boot.loader.tools.MainClassFinder;
|
||||
|
||||
/**
|
||||
* {@link Task} for resolving the name of the application's main class.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 2.4
|
||||
*/
|
||||
public class ResolveMainClassName extends DefaultTask {
|
||||
|
||||
private static final String SPRING_BOOT_APPLICATION_CLASS_NAME = "org.springframework.boot.autoconfigure.SpringBootApplication";
|
||||
|
||||
private final RegularFileProperty outputFile;
|
||||
|
||||
private final Property<String> configuredMainClass;
|
||||
|
||||
private FileCollection classpath;
|
||||
|
||||
/**
|
||||
* Creates a new instance of the {@code ResolveMainClassName} task.
|
||||
*/
|
||||
public ResolveMainClassName() {
|
||||
this.outputFile = getProject().getObjects().fileProperty();
|
||||
this.configuredMainClass = getProject().getObjects().property(String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the classpath that the task will examine when resolving the main class
|
||||
* name.
|
||||
* @return the classpath
|
||||
*/
|
||||
@Classpath
|
||||
public FileCollection getClasspath() {
|
||||
return this.classpath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the classpath that the task will examine when resolving the main class name.
|
||||
* @param classpath the classpath
|
||||
*/
|
||||
public void setClasspath(FileCollection classpath) {
|
||||
this.classpath = classpath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the property for the task's output file that will contain the name of the
|
||||
* main class.
|
||||
* @return the output file
|
||||
*/
|
||||
@OutputFile
|
||||
public RegularFileProperty getOutputFile() {
|
||||
return this.outputFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the property for the explicitly configured main class name that should be
|
||||
* used in favour of resolving the main class name from the classpath.
|
||||
* @return the configured main class name property
|
||||
*/
|
||||
@Input
|
||||
@Optional
|
||||
public Property<String> getConfiguredMainClassName() {
|
||||
return this.configuredMainClass;
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
void resolveAndStoreMainClassName() throws IOException {
|
||||
File outputFile = this.outputFile.getAsFile().get();
|
||||
outputFile.getParentFile().mkdirs();
|
||||
String mainClassName = resolveMainClassName();
|
||||
Files.write(outputFile.toPath(), mainClassName.getBytes(StandardCharsets.UTF_8), StandardOpenOption.WRITE,
|
||||
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
|
||||
}
|
||||
|
||||
private String resolveMainClassName() {
|
||||
String configuredMainClass = this.configuredMainClass.getOrNull();
|
||||
if (configuredMainClass != null) {
|
||||
return configuredMainClass;
|
||||
}
|
||||
return getClasspath().filter(File::isDirectory).getFiles().stream().map(this::findMainClass)
|
||||
.filter(Objects::nonNull).findFirst().orElse("");
|
||||
}
|
||||
|
||||
private String findMainClass(File file) {
|
||||
try {
|
||||
return MainClassFinder.findSingleMainClass(file, SPRING_BOOT_APPLICATION_CLASS_NAME);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Provider<String> readMainClassName() {
|
||||
return this.outputFile.map((file) -> {
|
||||
if (file.getAsFile().length() == 0) {
|
||||
throw new InvalidUserDataException(
|
||||
"Main class name has not been configured and it could not be resolved");
|
||||
}
|
||||
Path output = file.getAsFile().toPath();
|
||||
try {
|
||||
return new String(Files.readAllBytes(output), StandardCharsets.UTF_8);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new RuntimeException("Failed to read main class name from '" + output + "'");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static TaskProvider<ResolveMainClassName> registerForTask(String taskName, Project project,
|
||||
FileCollection classpath) {
|
||||
TaskProvider<ResolveMainClassName> resolveMainClassNameProvider = project.getTasks()
|
||||
.register(taskName + "MainClassName", ResolveMainClassName.class, (resolveMainClassName) -> {
|
||||
Convention convention = project.getConvention();
|
||||
resolveMainClassName.setDescription(
|
||||
"Resolves the name of the application's main class for the " + taskName + " task.");
|
||||
resolveMainClassName.setGroup(BasePlugin.BUILD_GROUP);
|
||||
resolveMainClassName.setClasspath(classpath);
|
||||
resolveMainClassName.getConfiguredMainClassName().convention(project.provider(() -> {
|
||||
String javaApplicationMainClass = getJavaApplicationMainClass(convention);
|
||||
if (javaApplicationMainClass != null) {
|
||||
return javaApplicationMainClass;
|
||||
}
|
||||
SpringBootExtension springBootExtension = project.getExtensions()
|
||||
.findByType(SpringBootExtension.class);
|
||||
return springBootExtension.getMainClass().getOrNull();
|
||||
}));
|
||||
resolveMainClassName.getOutputFile()
|
||||
.set(project.getLayout().getBuildDirectory().file(taskName + "MainClassName"));
|
||||
});
|
||||
return resolveMainClassNameProvider;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static String getJavaApplicationMainClass(Convention convention) {
|
||||
JavaApplication javaApplication = convention.findByType(JavaApplication.class);
|
||||
if (javaApplication == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return javaApplication.getMainClass().getOrNull();
|
||||
}
|
||||
catch (NoSuchMethodError ex) {
|
||||
return javaApplication.getMainClassName();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.example.main;
|
||||
|
||||
/**
|
||||
* Application used for testing {@code BootRun}'s main class configuration.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class CustomMainClass {
|
||||
|
||||
protected CustomMainClass() {
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(CustomMainClass.class.getName());
|
||||
}
|
||||
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.gradle.plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.plugins.ApplicationPlugin;
|
||||
import org.gradle.api.plugins.JavaApplication;
|
||||
import org.gradle.testfixtures.ProjectBuilder;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import org.springframework.boot.gradle.dsl.SpringBootExtension;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link MainClassConvention}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class MainClassConventionTests {
|
||||
|
||||
@TempDir
|
||||
File temp;
|
||||
|
||||
private Project project;
|
||||
|
||||
private MainClassConvention convention;
|
||||
|
||||
@BeforeEach
|
||||
void createConvention() throws IOException {
|
||||
this.project = ProjectBuilder.builder().withProjectDir(this.temp).build();
|
||||
this.convention = new MainClassConvention(this.project, () -> null);
|
||||
}
|
||||
|
||||
@Test
|
||||
void javaApplicationExtensionMainClassNameIsUsed() throws Exception {
|
||||
this.project.getPlugins().apply(ApplicationPlugin.class);
|
||||
JavaApplication extension = this.project.getExtensions().findByType(JavaApplication.class);
|
||||
extension.getMainClass().set("com.example.MainClass");
|
||||
assertThat(this.convention.call()).isEqualTo("com.example.MainClass");
|
||||
}
|
||||
|
||||
@Test
|
||||
void springBootExtensionMainClassNameIsUsed() throws Exception {
|
||||
SpringBootExtension extension = this.project.getExtensions().create("springBoot", SpringBootExtension.class,
|
||||
this.project);
|
||||
extension.getMainClass().set("com.example.MainClass");
|
||||
assertThat(this.convention.call()).isEqualTo("com.example.MainClass");
|
||||
}
|
||||
|
||||
@Test
|
||||
void springBootExtensionMainClassNameIsUsedInPreferenceToJavaApplicationExtensionMainClassName() throws Exception {
|
||||
this.project.getPlugins().apply(ApplicationPlugin.class);
|
||||
JavaApplication javaApplication = this.project.getExtensions().findByType(JavaApplication.class);
|
||||
javaApplication.getMainClass().set("com.example.JavaApplicationMainClass");
|
||||
SpringBootExtension extension = this.project.getExtensions().create("springBoot", SpringBootExtension.class,
|
||||
this.project);
|
||||
extension.getMainClass().set("com.example.SpringBootExtensionMainClass");
|
||||
assertThat(this.convention.call()).isEqualTo("com.example.SpringBootExtensionMainClass");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '{version}' apply false
|
||||
}
|
||||
|
||||
version = '0.1.0'
|
||||
|
||||
task buildInfo(type: org.springframework.boot.gradle.tasks.buildinfo.BuildInfo) {
|
||||
destinationDir project.buildDir
|
||||
properties {
|
||||
artifact = 'foo'
|
||||
group = 'foo'
|
||||
name = 'foo'
|
||||
additional = ['additional': 'foo']
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '{version}' apply false
|
||||
}
|
||||
|
||||
task buildInfo(type: org.springframework.boot.gradle.tasks.buildinfo.BuildInfo)
|
@ -0,0 +1,13 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '{version}' apply false
|
||||
}
|
||||
|
||||
task buildInfo(type: org.springframework.boot.gradle.tasks.buildinfo.BuildInfo) {
|
||||
properties {
|
||||
artifact = 'example'
|
||||
group = 'com.example'
|
||||
name = 'example'
|
||||
additional = ['additional': 'alpha']
|
||||
time = null
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '{version}' apply false
|
||||
}
|
||||
|
||||
version = '{projectVersion}'
|
||||
|
||||
task buildInfo(type: org.springframework.boot.gradle.tasks.buildinfo.BuildInfo) {
|
||||
properties {
|
||||
artifact = 'example'
|
||||
group = 'com.example'
|
||||
name = 'example'
|
||||
additional = ['additional': 'alpha']
|
||||
time = null
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '{version}' apply false
|
||||
}
|
||||
|
||||
task buildInfo(type: org.springframework.boot.gradle.tasks.buildinfo.BuildInfo) {
|
||||
properties {
|
||||
time = null
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '{version}' apply false
|
||||
}
|
||||
|
||||
task buildInfo(type: org.springframework.boot.gradle.tasks.buildinfo.BuildInfo) {
|
||||
properties {
|
||||
time = null
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '{version}' apply false
|
||||
}
|
||||
|
||||
def property(String name, Object defaultValue) {
|
||||
project.hasProperty(name) ? project.getProperty(name) : defaultValue
|
||||
}
|
||||
|
||||
version = property('projectVersion', '0.1.0')
|
||||
|
||||
task buildInfo(type: org.springframework.boot.gradle.tasks.buildinfo.BuildInfo) {
|
||||
destinationDir file(property('buildInfoDestinationDir', project.buildDir))
|
||||
properties {
|
||||
artifact = property('buildInfoArtifact', 'foo')
|
||||
group = property('buildInfoGroup', 'foo')
|
||||
name = property('buildInfoName', 'foo')
|
||||
additional = ['additional': property('buildInfoAdditional', 'foo')]
|
||||
if (project.hasProperty('nullTime')) {
|
||||
time = null
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClass = 'com.example.Application'
|
||||
layered {
|
||||
{layerTools}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClass = 'com.example.Application'
|
||||
layered {
|
||||
{layerEnablement}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClass = 'com.example.Application'
|
||||
launchScript {
|
||||
properties 'prop' : '{launchScriptProperty}'
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClass = 'com.example.Application'
|
||||
{launchScript}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClass = 'com.example.Application'
|
||||
{launchScript}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'application'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClassName = 'com.example.Application'
|
||||
launchScript()
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClass = 'com.example.Application'
|
||||
{layered}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClass = 'com.example.Application'
|
||||
if (project.hasProperty('includeLaunchScript') ? includeLaunchScript : false) {
|
||||
launchScript {
|
||||
properties 'prop' : project.hasProperty('launchScriptProperty') ? launchScriptProperty : 'default'
|
||||
}
|
||||
}
|
||||
if (project.hasProperty('customizeLayered') && project.getProperty('customizeLayered')) {
|
||||
layered {
|
||||
includeLayerTools = project.hasProperty('excludeTools') && project.getProperty('excludeTools') ? false : true
|
||||
enabled = project.hasProperty('disableLayers') && project.getProperty('disableLayers') ? false : true
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
plugins {
|
||||
id 'war'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
plugins {
|
||||
id 'war'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.CustomMain'
|
||||
duplicatesStrategy = "exclude"
|
||||
}
|
||||
|
||||
configurations {
|
||||
provided
|
||||
}
|
||||
|
||||
sourceSets.all {
|
||||
compileClasspath += configurations.provided
|
||||
runtimeClasspath += configurations.provided
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.apache.commons:commons-lang3:3.6")
|
||||
provided "org.apache.commons:commons-lang3:3.6"
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
plugins {
|
||||
id 'war'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
launchScript {
|
||||
properties 'prop' : '{launchScriptProperty}'
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
plugins {
|
||||
id 'war'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
{launchScript}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
plugins {
|
||||
id 'war'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
{launchScript}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
plugins {
|
||||
id 'war'
|
||||
id 'application'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
plugins {
|
||||
id 'war'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
plugins {
|
||||
id 'war'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
launchScript()
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
plugins {
|
||||
id 'war'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
if (project.hasProperty('includeLaunchScript') ? includeLaunchScript : false) {
|
||||
launchScript {
|
||||
properties 'prop' : project.hasProperty('launchScriptProperty') ? launchScriptProperty : 'default'
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,8 @@
|
||||
plugins {
|
||||
id 'application'
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = 'com.example.CustomMainClass'
|
||||
}
|
||||
|
||||
task echoMainClassName {
|
||||
println 'Main class name = ' + bootRun.main
|
||||
mainClass = 'com.example.main.CustomMainClass'
|
||||
}
|
||||
|
Loading…
Reference in New Issue