Merge branch '1.2.x'
This commit is contained in:
commit
47576354f7
|
|
@ -18,6 +18,7 @@
|
||||||
</organization>
|
</organization>
|
||||||
<properties>
|
<properties>
|
||||||
<main.basedir>${basedir}/..</main.basedir>
|
<main.basedir>${basedir}/..</main.basedir>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
</properties>
|
</properties>
|
||||||
<modules>
|
<modules>
|
||||||
<module>spring-boot-gradle-tests</module>
|
<module>spring-boot-gradle-tests</module>
|
||||||
|
|
|
||||||
|
|
@ -367,6 +367,7 @@
|
||||||
</versionRange>
|
</versionRange>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>descriptor</goal>
|
<goal>descriptor</goal>
|
||||||
|
<goal>helpmojo</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</pluginExecutionFilter>
|
</pluginExecutionFilter>
|
||||||
<action>
|
<action>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|
@ -18,6 +19,7 @@
|
||||||
</organization>
|
</organization>
|
||||||
<properties>
|
<properties>
|
||||||
<main.basedir>${basedir}/..</main.basedir>
|
<main.basedir>${basedir}/..</main.basedir>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
</properties>
|
</properties>
|
||||||
<modules>
|
<modules>
|
||||||
<module>spring-boot-sample-ant</module>
|
<module>spring-boot-sample-ant</module>
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
</organization>
|
</organization>
|
||||||
<properties>
|
<properties>
|
||||||
<main.basedir>${basedir}/../..</main.basedir>
|
<main.basedir>${basedir}/../..</main.basedir>
|
||||||
<java.version>1.7</java.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
<url>http://www.spring.io</url>
|
<url>http://www.spring.io</url>
|
||||||
</organization>
|
</organization>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.7</java.version>
|
|
||||||
<main.basedir>${basedir}/../..</main.basedir>
|
<main.basedir>${basedir}/../..</main.basedir>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
</organization>
|
</organization>
|
||||||
<properties>
|
<properties>
|
||||||
<main.basedir>${basedir}/../..</main.basedir>
|
<main.basedir>${basedir}/../..</main.basedir>
|
||||||
<java.version>1.7</java.version>
|
|
||||||
<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
|
<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
<properties>
|
<properties>
|
||||||
<main.basedir>${basedir}/../..</main.basedir>
|
<main.basedir>${basedir}/../..</main.basedir>
|
||||||
<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
|
<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
|
||||||
<java.version>1.7</java.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
<main.basedir>${basedir}/../..</main.basedir>
|
<main.basedir>${basedir}/../..</main.basedir>
|
||||||
<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
|
<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
|
||||||
<tomcat.version>7.0.59</tomcat.version>
|
<tomcat.version>7.0.59</tomcat.version>
|
||||||
<java.version>1.7</java.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
</organization>
|
</organization>
|
||||||
<properties>
|
<properties>
|
||||||
<main.basedir>${basedir}/../..</main.basedir>
|
<main.basedir>${basedir}/../..</main.basedir>
|
||||||
<java.version>1.7</java.version>
|
|
||||||
<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
|
<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
<url>http://www.spring.io</url>
|
<url>http://www.spring.io</url>
|
||||||
</organization>
|
</organization>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.7</java.version>
|
|
||||||
<main.basedir>${basedir}/../..</main.basedir>
|
<main.basedir>${basedir}/../..</main.basedir>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
</organization>
|
</organization>
|
||||||
<properties>
|
<properties>
|
||||||
<main.basedir>${basedir}/../..</main.basedir>
|
<main.basedir>${basedir}/../..</main.basedir>
|
||||||
<java.version>1.7</java.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
</organization>
|
</organization>
|
||||||
<properties>
|
<properties>
|
||||||
<main.basedir>${basedir}/../..</main.basedir>
|
<main.basedir>${basedir}/../..</main.basedir>
|
||||||
<java.version>1.7</java.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
</organization>
|
</organization>
|
||||||
<properties>
|
<properties>
|
||||||
<main.basedir>${basedir}/../..</main.basedir>
|
<main.basedir>${basedir}/../..</main.basedir>
|
||||||
<java.version>1.7</java.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -50,64 +50,6 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
|
||||||
<sourceDirectory>src/main/groovy</sourceDirectory>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<compilerId>groovy-eclipse-compiler</compilerId>
|
|
||||||
</configuration>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.codehaus.groovy</groupId>
|
|
||||||
<artifactId>groovy-eclipse-compiler</artifactId>
|
|
||||||
<version>2.8.0-01</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.codehaus.groovy</groupId>
|
|
||||||
<artifactId>groovy-eclipse-batch</artifactId>
|
|
||||||
<version>2.1.8-01</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
<pluginManagement>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.eclipse.m2e</groupId>
|
|
||||||
<artifactId>lifecycle-mapping</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<configuration>
|
|
||||||
<lifecycleMappingMetadata>
|
|
||||||
<pluginExecutions>
|
|
||||||
<pluginExecution>
|
|
||||||
<pluginExecutionFilter>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<versionRange>[2.10,)</versionRange>
|
|
||||||
<goals>
|
|
||||||
<goal>compile</goal>
|
|
||||||
<goal>testCompile</goal>
|
|
||||||
</goals>
|
|
||||||
<parameters>
|
|
||||||
<compilerId>groovy-eclipse-compiler</compilerId>
|
|
||||||
</parameters>
|
|
||||||
</pluginExecutionFilter>
|
|
||||||
<action>
|
|
||||||
<configurator>
|
|
||||||
<id>org.codehaus.groovy.m2eclipse.configurator</id>
|
|
||||||
</configurator>
|
|
||||||
</action>
|
|
||||||
</pluginExecution>
|
|
||||||
</pluginExecutions>
|
|
||||||
</lifecycleMappingMetadata>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>gradle</id>
|
<id>gradle</id>
|
||||||
|
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2012-2014 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
|
|
||||||
*
|
|
||||||
* http://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
|
|
||||||
|
|
||||||
import org.gradle.api.Plugin
|
|
||||||
import org.gradle.api.Project
|
|
||||||
import org.gradle.api.plugins.JavaPlugin
|
|
||||||
import org.springframework.boot.gradle.agent.AgentPluginFeatures
|
|
||||||
import org.springframework.boot.gradle.dependencymanagement.DependencyManagementPluginFeatures
|
|
||||||
import org.springframework.boot.gradle.repackage.RepackagePluginFeatures
|
|
||||||
import org.springframework.boot.gradle.run.RunPluginFeatures
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gradle 'Spring Boot' {@link Plugin}.
|
|
||||||
*
|
|
||||||
* @author Phillip Webb
|
|
||||||
* @author Dave Syer
|
|
||||||
* @author Andy Wilkinson
|
|
||||||
*/
|
|
||||||
class SpringBootPlugin implements Plugin<Project> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
void apply(Project project) {
|
|
||||||
project.getExtensions().create("springBoot", SpringBootPluginExtension)
|
|
||||||
|
|
||||||
project.getPlugins().apply(JavaPlugin)
|
|
||||||
|
|
||||||
new AgentPluginFeatures().apply(project)
|
|
||||||
new RepackagePluginFeatures().apply(project)
|
|
||||||
new RunPluginFeatures().apply(project)
|
|
||||||
new DependencyManagementPluginFeatures().apply(project)
|
|
||||||
|
|
||||||
useUtf8Encoding(project)
|
|
||||||
}
|
|
||||||
|
|
||||||
private useUtf8Encoding(Project project) {
|
|
||||||
project.tasks.withType(org.gradle.api.tasks.compile.JavaCompile).all {
|
|
||||||
it.doFirst {
|
|
||||||
if(!it.options.encoding) {
|
|
||||||
it.options.encoding = 'UTF-8'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,153 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2012-2014 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
|
|
||||||
*
|
|
||||||
* http://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
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.springframework.boot.loader.tools.Layout;
|
|
||||||
import org.springframework.boot.loader.tools.Layouts;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gradle DSL Extension for 'Spring Boot'. Most of the time Spring Boot can guess the
|
|
||||||
* settings in this extension, but occasionally you might need to explicitly set one
|
|
||||||
* or two of them. E.g.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* apply plugin: "spring-boot"
|
|
||||||
* springBoot {
|
|
||||||
* mainClass = 'org.demo.Application'
|
|
||||||
* layout = 'ZIP'
|
|
||||||
* }
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author Phillip Webb
|
|
||||||
* @author Dave Syer
|
|
||||||
*/
|
|
||||||
public class SpringBootPluginExtension {
|
|
||||||
|
|
||||||
enum LayoutType {
|
|
||||||
|
|
||||||
JAR(new Layouts.Jar()),
|
|
||||||
|
|
||||||
WAR(new Layouts.War()),
|
|
||||||
|
|
||||||
ZIP(new Layouts.Expanded()),
|
|
||||||
|
|
||||||
DIR(new Layouts.Expanded()),
|
|
||||||
|
|
||||||
MODULE(new Layouts.Module()),
|
|
||||||
|
|
||||||
NONE(new Layouts.None());
|
|
||||||
|
|
||||||
Layout layout;
|
|
||||||
|
|
||||||
private LayoutType(Layout layout) {
|
|
||||||
this.layout = layout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The main class that should be run. Instead of setting this explicitly you can use the
|
|
||||||
* 'mainClassName' of the project or the 'main' of the 'run' task. If not specified the
|
|
||||||
* value from the MANIFEST will be used, or if no manifest entry is the archive will be
|
|
||||||
* searched for a suitable class.
|
|
||||||
*/
|
|
||||||
String mainClass
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The classifier (file name part before the extension). Instead of setting this explicitly
|
|
||||||
* you can use the 'classifier' property of the 'bootRepackage' task. If not specified the archive
|
|
||||||
* will be replaced instead of renamed.
|
|
||||||
*/
|
|
||||||
String classifier
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the ivy configuration name to treat as 'provided' (when packaging
|
|
||||||
* those dependencies in a separate path). If not specified 'providedRuntime' will
|
|
||||||
* be used.
|
|
||||||
*/
|
|
||||||
String providedConfiguration
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the custom configuration to use.
|
|
||||||
*/
|
|
||||||
String customConfiguration
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If the original source archive should be backed-up before being repackaged.
|
|
||||||
*/
|
|
||||||
boolean backupSource = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The layout of the archive if it can't be derived from the file extension.
|
|
||||||
* Valid values are JAR, WAR, ZIP, DIR (for exploded zip file). ZIP and DIR
|
|
||||||
* are actually synonymous, and should be used if there is no MANIFEST.MF
|
|
||||||
* available, or if you want the MANIFEST.MF 'Main-Class' to be
|
|
||||||
* PropertiesLauncher. Gradle will coerce literal String values to the
|
|
||||||
* correct type.
|
|
||||||
*/
|
|
||||||
LayoutType layout;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenience method for use in a custom task.
|
|
||||||
* @return the Layout to use or null if not explicitly set
|
|
||||||
*/
|
|
||||||
Layout convertLayout() {
|
|
||||||
(layout == null ? null : layout.layout)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Libraries that must be unpacked from fat jars in order to run. Use Strings in the
|
|
||||||
* form {@literal groupId:artifactId}.
|
|
||||||
*/
|
|
||||||
Set<String> requiresUnpack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Location of an agent jar to attach to the VM when running the application with runJar task.
|
|
||||||
*/
|
|
||||||
File agent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flag to indicate that the agent requires -noverify (and the plugin will refuse to start if it is not set)
|
|
||||||
*/
|
|
||||||
Boolean noverify;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If exclude rules should be applied to dependencies based on the spring-dependencies-bom
|
|
||||||
*/
|
|
||||||
boolean applyExcludeRules = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If a fully executable jar (for *nix machines) should be generated by prepending a
|
|
||||||
* launch script to the jar.
|
|
||||||
*/
|
|
||||||
boolean executable = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The embedded launch script to prepend to the front of the jar if it is fully
|
|
||||||
* executable. If not specified the 'Spring Boot' default script will be used.
|
|
||||||
*/
|
|
||||||
File embeddedLaunchScript;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Properties that should be expanded in the embedded launch script.
|
|
||||||
*/
|
|
||||||
Map<String,String> embeddedLaunchScriptProperties;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2012-2015 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
|
|
||||||
*
|
|
||||||
* http://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.dependencymanagement;
|
|
||||||
|
|
||||||
import org.gradle.api.Project;
|
|
||||||
import org.springframework.boot.gradle.PluginFeatures;
|
|
||||||
|
|
||||||
import io.spring.gradle.dependencymanagement.DependencyManagementExtension
|
|
||||||
import io.spring.gradle.dependencymanagement.DependencyManagementPlugin
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link PluginFeatures} to configure dependency management
|
|
||||||
*
|
|
||||||
* @author Andy Wilkinson
|
|
||||||
*/
|
|
||||||
class DependencyManagementPluginFeatures implements PluginFeatures {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
void apply(Project project) {
|
|
||||||
project.plugins.apply(DependencyManagementPlugin)
|
|
||||||
DependencyManagementExtension dependencyManagement = project.extensions
|
|
||||||
.findByType(DependencyManagementExtension)
|
|
||||||
dependencyManagement.imports {
|
|
||||||
def version = DependencyManagementPluginFeatures.class.getPackage().implementationVersion
|
|
||||||
mavenBom "org.springframework.boot:spring-boot-starter-parent:$version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2015 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
|
||||||
|
*
|
||||||
|
* http://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;
|
||||||
|
|
||||||
|
import org.gradle.api.Action;
|
||||||
|
import org.gradle.api.Plugin;
|
||||||
|
import org.gradle.api.Project;
|
||||||
|
import org.gradle.api.Task;
|
||||||
|
import org.gradle.api.plugins.JavaPlugin;
|
||||||
|
import org.gradle.api.tasks.compile.JavaCompile;
|
||||||
|
import org.springframework.boot.gradle.agent.AgentPluginFeatures;
|
||||||
|
import org.springframework.boot.gradle.dependencymanagement.DependencyManagementPluginFeatures;
|
||||||
|
import org.springframework.boot.gradle.repackage.RepackagePluginFeatures;
|
||||||
|
import org.springframework.boot.gradle.run.RunPluginFeatures;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gradle 'Spring Boot' {@link Plugin}.
|
||||||
|
*
|
||||||
|
* @author Phillip Webb
|
||||||
|
* @author Dave Syer
|
||||||
|
* @author Andy Wilkinson
|
||||||
|
*/
|
||||||
|
class SpringBootPlugin implements Plugin<Project> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply(Project project) {
|
||||||
|
project.getExtensions().create("springBoot", SpringBootPluginExtension.class);
|
||||||
|
project.getPlugins().apply(JavaPlugin.class);
|
||||||
|
new AgentPluginFeatures().apply(project);
|
||||||
|
new RepackagePluginFeatures().apply(project);
|
||||||
|
new RunPluginFeatures().apply(project);
|
||||||
|
new DependencyManagementPluginFeatures().apply(project);
|
||||||
|
project.getTasks().withType(JavaCompile.class).all(new SetUtf8EncodingAction());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SetUtf8EncodingAction implements Action<JavaCompile> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(final JavaCompile compile) {
|
||||||
|
compile.doFirst(new Action<Task>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public void execute(Task t) {
|
||||||
|
if (compile.getOptions().getEncoding() == null) {
|
||||||
|
compile.getOptions().setEncoding("UTF-8");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,263 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2015 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
|
||||||
|
*
|
||||||
|
* http://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;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.springframework.boot.loader.tools.Layout;
|
||||||
|
import org.springframework.boot.loader.tools.Layouts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gradle DSL Extension for 'Spring Boot'. Most of the time Spring Boot can guess the
|
||||||
|
* settings in this extension, but occasionally you might need to explicitly set one or
|
||||||
|
* two of them. E.g.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* apply plugin: "spring-boot"
|
||||||
|
* springBoot {
|
||||||
|
* mainClass = 'org.demo.Application'
|
||||||
|
* layout = 'ZIP'
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author Phillip Webb
|
||||||
|
* @author Dave Syer
|
||||||
|
*/
|
||||||
|
public class SpringBootPluginExtension {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main class that should be run. Instead of setting this explicitly you can use
|
||||||
|
* the 'mainClassName' of the project or the 'main' of the 'run' task. If not
|
||||||
|
* specified the value from the MANIFEST will be used, or if no manifest entry is the
|
||||||
|
* archive will be searched for a suitable class.
|
||||||
|
*/
|
||||||
|
String mainClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The classifier (file name part before the extension). Instead of setting this
|
||||||
|
* explicitly you can use the 'classifier' property of the 'bootRepackage' task. If
|
||||||
|
* not specified the archive will be replaced instead of renamed.
|
||||||
|
*/
|
||||||
|
String classifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the ivy configuration name to treat as 'provided' (when packaging those
|
||||||
|
* dependencies in a separate path). If not specified 'providedRuntime' will be used.
|
||||||
|
*/
|
||||||
|
String providedConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the custom configuration to use.
|
||||||
|
*/
|
||||||
|
String customConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the original source archive should be backed-up before being repackaged.
|
||||||
|
*/
|
||||||
|
boolean backupSource = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The layout of the archive if it can't be derived from the file extension. Valid
|
||||||
|
* values are JAR, WAR, ZIP, DIR (for exploded zip file). ZIP and DIR are actually
|
||||||
|
* synonymous, and should be used if there is no MANIFEST.MF available, or if you want
|
||||||
|
* the MANIFEST.MF 'Main-Class' to be PropertiesLauncher. Gradle will coerce literal
|
||||||
|
* String values to the correct type.
|
||||||
|
*/
|
||||||
|
LayoutType layout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Libraries that must be unpacked from fat jars in order to run. Use Strings in the
|
||||||
|
* form {@literal groupId:artifactId}.
|
||||||
|
*/
|
||||||
|
Set<String> requiresUnpack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Location of an agent jar to attach to the VM when running the application with
|
||||||
|
* runJar task.
|
||||||
|
*/
|
||||||
|
File agent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag to indicate that the agent requires -noverify (and the plugin will refuse to
|
||||||
|
* start if it is not set).
|
||||||
|
*/
|
||||||
|
Boolean noverify;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If exclude rules should be applied to dependencies based on the
|
||||||
|
* spring-dependencies-bom.
|
||||||
|
*/
|
||||||
|
boolean applyExcludeRules = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a fully executable jar (for *nix machines) should be generated by prepending a
|
||||||
|
* launch script to the jar.
|
||||||
|
*/
|
||||||
|
boolean executable = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The embedded launch script to prepend to the front of the jar if it is fully
|
||||||
|
* executable. If not specified the 'Spring Boot' default script will be used.
|
||||||
|
*/
|
||||||
|
File embeddedLaunchScript;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Properties that should be expanded in the embedded launch script.
|
||||||
|
*/
|
||||||
|
Map<String, String> embeddedLaunchScriptProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method for use in a custom task.
|
||||||
|
* @return the Layout to use or null if not explicitly set
|
||||||
|
*/
|
||||||
|
public Layout convertLayout() {
|
||||||
|
return (this.layout == null ? null : this.layout.layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMainClass() {
|
||||||
|
return this.mainClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMainClass(String mainClass) {
|
||||||
|
this.mainClass = mainClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClassifier() {
|
||||||
|
return this.classifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClassifier(String classifier) {
|
||||||
|
this.classifier = classifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProvidedConfiguration() {
|
||||||
|
return this.providedConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProvidedConfiguration(String providedConfiguration) {
|
||||||
|
this.providedConfiguration = providedConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCustomConfiguration() {
|
||||||
|
return this.customConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomConfiguration(String customConfiguration) {
|
||||||
|
this.customConfiguration = customConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBackupSource() {
|
||||||
|
return this.backupSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBackupSource(boolean backupSource) {
|
||||||
|
this.backupSource = backupSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LayoutType getLayout() {
|
||||||
|
return this.layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLayout(LayoutType layout) {
|
||||||
|
this.layout = layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getRequiresUnpack() {
|
||||||
|
return this.requiresUnpack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequiresUnpack(Set<String> requiresUnpack) {
|
||||||
|
this.requiresUnpack = requiresUnpack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getAgent() {
|
||||||
|
return this.agent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAgent(File agent) {
|
||||||
|
this.agent = agent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getNoverify() {
|
||||||
|
return this.noverify;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNoverify(Boolean noverify) {
|
||||||
|
this.noverify = noverify;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isApplyExcludeRules() {
|
||||||
|
return this.applyExcludeRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApplyExcludeRules(boolean applyExcludeRules) {
|
||||||
|
this.applyExcludeRules = applyExcludeRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExecutable() {
|
||||||
|
return this.executable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExecutable(boolean executable) {
|
||||||
|
this.executable = executable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getEmbeddedLaunchScript() {
|
||||||
|
return this.embeddedLaunchScript;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmbeddedLaunchScript(File embeddedLaunchScript) {
|
||||||
|
this.embeddedLaunchScript = embeddedLaunchScript;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getEmbeddedLaunchScriptProperties() {
|
||||||
|
return this.embeddedLaunchScriptProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmbeddedLaunchScriptProperties(
|
||||||
|
Map<String, String> embeddedLaunchScriptProperties) {
|
||||||
|
this.embeddedLaunchScriptProperties = embeddedLaunchScriptProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Layout Types.
|
||||||
|
*/
|
||||||
|
enum LayoutType {
|
||||||
|
|
||||||
|
JAR(new Layouts.Jar()),
|
||||||
|
|
||||||
|
WAR(new Layouts.War()),
|
||||||
|
|
||||||
|
ZIP(new Layouts.Expanded()),
|
||||||
|
|
||||||
|
DIR(new Layouts.Expanded()),
|
||||||
|
|
||||||
|
MODULE(new Layouts.Module()),
|
||||||
|
|
||||||
|
NONE(new Layouts.None());
|
||||||
|
|
||||||
|
Layout layout;
|
||||||
|
|
||||||
|
LayoutType(Layout layout) {
|
||||||
|
this.layout = layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -32,7 +32,8 @@ import org.springframework.boot.gradle.SpringBootPluginExtension;
|
||||||
*
|
*
|
||||||
* <ol>
|
* <ol>
|
||||||
* <li>Use "-Prun.agent=[path-to-jar]" on the gradle command line</li>
|
* <li>Use "-Prun.agent=[path-to-jar]" on the gradle command line</li>
|
||||||
* <li>Add an "agent" property (jar file) to the "springBoot" extension in build.gradle</li>
|
* <li>Add an "agent" property (jar file) to the "springBoot" extension in build.gradle
|
||||||
|
* </li>
|
||||||
* <li>As a special case springloaded is detected as a build script dependency</li>
|
* <li>As a special case springloaded is detected as a build script dependency</li>
|
||||||
* </ol>
|
* </ol>
|
||||||
*
|
*
|
||||||
|
|
@ -59,8 +60,8 @@ public class AgentTasksEnhancer implements Action<Project> {
|
||||||
|
|
||||||
private void setup(Project project) {
|
private void setup(Project project) {
|
||||||
project.getLogger().info("Configuring agent");
|
project.getLogger().info("Configuring agent");
|
||||||
SpringBootPluginExtension extension = project.getExtensions().getByType(
|
SpringBootPluginExtension extension = project.getExtensions()
|
||||||
SpringBootPluginExtension.class);
|
.getByType(SpringBootPluginExtension.class);
|
||||||
this.noverify = extension.getNoverify();
|
this.noverify = extension.getNoverify();
|
||||||
this.agent = getAgent(project, extension);
|
this.agent = getAgent(project, extension);
|
||||||
if (this.agent == null) {
|
if (this.agent == null) {
|
||||||
|
|
@ -114,8 +115,8 @@ public class AgentTasksEnhancer implements Action<Project> {
|
||||||
if (this.noverify != null && this.noverify) {
|
if (this.noverify != null && this.noverify) {
|
||||||
exec.jvmArgs("-noverify");
|
exec.jvmArgs("-noverify");
|
||||||
}
|
}
|
||||||
Iterable<?> defaultJvmArgs = exec.getConventionMapping().getConventionValue(
|
Iterable<?> defaultJvmArgs = exec.getConventionMapping()
|
||||||
null, "jvmArgs", false);
|
.getConventionValue(null, "jvmArgs", false);
|
||||||
if (defaultJvmArgs != null) {
|
if (defaultJvmArgs != null) {
|
||||||
exec.jvmArgs(defaultJvmArgs);
|
exec.jvmArgs(defaultJvmArgs);
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2015 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
|
||||||
|
*
|
||||||
|
* http://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.dependencymanagement;
|
||||||
|
|
||||||
|
import org.gradle.api.Project;
|
||||||
|
import org.springframework.boot.gradle.PluginFeatures;
|
||||||
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
|
import groovy.lang.Closure;
|
||||||
|
import io.spring.gradle.dependencymanagement.DependencyManagementExtension;
|
||||||
|
import io.spring.gradle.dependencymanagement.DependencyManagementPlugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link PluginFeatures} to configure dependency management.
|
||||||
|
*
|
||||||
|
* @author Andy Wilkinson
|
||||||
|
* @author Phillip Webb
|
||||||
|
* @since 1.3.0
|
||||||
|
*/
|
||||||
|
public class DependencyManagementPluginFeatures implements PluginFeatures {
|
||||||
|
|
||||||
|
private static final String SPRING_BOOT_VERSION = DependencyManagementPluginFeatures.class
|
||||||
|
.getPackage().getImplementationVersion();
|
||||||
|
|
||||||
|
private static final String SPRING_BOOT_BOM = "org.springframework.boot:spring-boot-starter-parent:"
|
||||||
|
+ SPRING_BOOT_VERSION;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply(Project project) {
|
||||||
|
project.getPlugins().apply(DependencyManagementPlugin.class);
|
||||||
|
DependencyManagementExtension dependencyManagement = project.getExtensions()
|
||||||
|
.findByType(DependencyManagementExtension.class);
|
||||||
|
dependencyManagement.imports(new Closure<Void>(this) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void call(Object... args) {
|
||||||
|
try {
|
||||||
|
ReflectionUtils.findMethod(getDelegate().getClass(), "mavenBom",
|
||||||
|
String.class).invoke(getDelegate(), SPRING_BOOT_BOM);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -96,9 +96,10 @@ class ProjectLibraries implements Libraries {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<GradleLibrary> getLibraries(String configurationName, LibraryScope scope) {
|
private Set<GradleLibrary> getLibraries(String configurationName,
|
||||||
Configuration configuration = (configurationName == null ? null : this.project
|
LibraryScope scope) {
|
||||||
.getConfigurations().findByName(configurationName));
|
Configuration configuration = (configurationName == null ? null
|
||||||
|
: this.project.getConfigurations().findByName(configurationName));
|
||||||
if (configuration == null) {
|
if (configuration == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -118,8 +119,8 @@ class ProjectLibraries implements Libraries {
|
||||||
if (dependency instanceof FileCollectionDependency) {
|
if (dependency instanceof FileCollectionDependency) {
|
||||||
FileCollectionDependency fileDependency = (FileCollectionDependency) dependency;
|
FileCollectionDependency fileDependency = (FileCollectionDependency) dependency;
|
||||||
for (File file : fileDependency.resolve()) {
|
for (File file : fileDependency.resolve()) {
|
||||||
libraries.add(new GradleLibrary(fileDependency.getGroup(), file,
|
libraries.add(
|
||||||
scope));
|
new GradleLibrary(fileDependency.getGroup(), file, scope));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dependency instanceof ProjectDependency) {
|
else if (dependency instanceof ProjectDependency) {
|
||||||
|
|
@ -231,8 +232,8 @@ class ProjectLibraries implements Libraries {
|
||||||
public boolean isUnpackRequired() {
|
public boolean isUnpackRequired() {
|
||||||
if (ProjectLibraries.this.extension.getRequiresUnpack() != null) {
|
if (ProjectLibraries.this.extension.getRequiresUnpack() != null) {
|
||||||
ModuleVersionIdentifier id = this.artifact.getModuleVersion().getId();
|
ModuleVersionIdentifier id = this.artifact.getModuleVersion().getId();
|
||||||
return ProjectLibraries.this.extension.getRequiresUnpack().contains(
|
return ProjectLibraries.this.extension.getRequiresUnpack()
|
||||||
id.getGroup() + ":" + id.getName());
|
.contains(id.getGroup() + ":" + id.getName());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -63,8 +63,8 @@ public class RepackagePluginFeatures implements PluginFeatures {
|
||||||
+ "archives so that they can be executed from the command "
|
+ "archives so that they can be executed from the command "
|
||||||
+ "line using 'java -jar'");
|
+ "line using 'java -jar'");
|
||||||
task.setGroup(BasePlugin.BUILD_GROUP);
|
task.setGroup(BasePlugin.BUILD_GROUP);
|
||||||
Configuration runtimeConfiguration = project.getConfigurations().getByName(
|
Configuration runtimeConfiguration = project.getConfigurations()
|
||||||
JavaPlugin.RUNTIME_CONFIGURATION_NAME);
|
.getByName(JavaPlugin.RUNTIME_CONFIGURATION_NAME);
|
||||||
TaskDependency runtimeProjectDependencyJarTasks = runtimeConfiguration
|
TaskDependency runtimeProjectDependencyJarTasks = runtimeConfiguration
|
||||||
.getTaskDependencyFromProjectDependency(true, JavaPlugin.JAR_TASK_NAME);
|
.getTaskDependencyFromProjectDependency(true, JavaPlugin.JAR_TASK_NAME);
|
||||||
task.dependsOn(
|
task.dependsOn(
|
||||||
|
|
@ -103,8 +103,8 @@ public class RepackagePluginFeatures implements PluginFeatures {
|
||||||
* @param project the source project
|
* @param project the source project
|
||||||
*/
|
*/
|
||||||
private void registerRepackageTaskProperty(Project project) {
|
private void registerRepackageTaskProperty(Project project) {
|
||||||
project.getExtensions().getExtraProperties()
|
project.getExtensions().getExtraProperties().set("BootRepackage",
|
||||||
.set("BootRepackage", RepackageTask.class);
|
RepackageTask.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -143,8 +143,8 @@ public class RepackagePluginFeatures implements PluginFeatures {
|
||||||
+ this.task.getName());
|
+ this.task.getName());
|
||||||
File inputFile = jarTask.getArchivePath();
|
File inputFile = jarTask.getArchivePath();
|
||||||
String outputName = inputFile.getName();
|
String outputName = inputFile.getName();
|
||||||
outputName = StringUtils.stripFilenameExtension(outputName) + "-"
|
outputName = StringUtils.stripFilenameExtension(outputName) + "-" + classifier
|
||||||
+ classifier + "." + StringUtils.getFilenameExtension(outputName);
|
+ "." + StringUtils.getFilenameExtension(outputName);
|
||||||
File outputFile = new File(inputFile.getParentFile(), outputName);
|
File outputFile = new File(inputFile.getParentFile(), outputName);
|
||||||
this.task.getInputs().file(jarTask);
|
this.task.getInputs().file(jarTask);
|
||||||
addLibraryDependencies(this.task);
|
addLibraryDependencies(this.task);
|
||||||
|
|
@ -91,16 +91,16 @@ public class RepackageTask extends DefaultTask {
|
||||||
@TaskAction
|
@TaskAction
|
||||||
public void repackage() {
|
public void repackage() {
|
||||||
Project project = getProject();
|
Project project = getProject();
|
||||||
SpringBootPluginExtension extension = project.getExtensions().getByType(
|
SpringBootPluginExtension extension = project.getExtensions()
|
||||||
SpringBootPluginExtension.class);
|
.getByType(SpringBootPluginExtension.class);
|
||||||
ProjectLibraries libraries = getLibraries();
|
ProjectLibraries libraries = getLibraries();
|
||||||
project.getTasks().withType(Jar.class, new RepackageAction(extension, libraries));
|
project.getTasks().withType(Jar.class, new RepackageAction(extension, libraries));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProjectLibraries getLibraries() {
|
public ProjectLibraries getLibraries() {
|
||||||
Project project = getProject();
|
Project project = getProject();
|
||||||
SpringBootPluginExtension extension = project.getExtensions().getByType(
|
SpringBootPluginExtension extension = project.getExtensions()
|
||||||
SpringBootPluginExtension.class);
|
.getByType(SpringBootPluginExtension.class);
|
||||||
ProjectLibraries libraries = new ProjectLibraries(project, extension);
|
ProjectLibraries libraries = new ProjectLibraries(project, extension);
|
||||||
if (extension.getProvidedConfiguration() != null) {
|
if (extension.getProvidedConfiguration() != null) {
|
||||||
libraries.setProvidedConfigurationName(extension.getProvidedConfiguration());
|
libraries.setProvidedConfigurationName(extension.getProvidedConfiguration());
|
||||||
|
|
@ -123,8 +123,7 @@ public class RepackageTask extends DefaultTask {
|
||||||
|
|
||||||
private final ProjectLibraries libraries;
|
private final ProjectLibraries libraries;
|
||||||
|
|
||||||
RepackageAction(SpringBootPluginExtension extension,
|
RepackageAction(SpringBootPluginExtension extension, ProjectLibraries libraries) {
|
||||||
ProjectLibraries libraries) {
|
|
||||||
this.extension = extension;
|
this.extension = extension;
|
||||||
this.libraries = libraries;
|
this.libraries = libraries;
|
||||||
}
|
}
|
||||||
|
|
@ -251,8 +250,7 @@ public class RepackageTask extends DefaultTask {
|
||||||
finally {
|
finally {
|
||||||
long duration = System.currentTimeMillis() - startTime;
|
long duration = System.currentTimeMillis() - startTime;
|
||||||
if (duration > FIND_WARNING_TIMEOUT) {
|
if (duration > FIND_WARNING_TIMEOUT) {
|
||||||
getLogger().warn(
|
getLogger().warn("Searching for the main-class is taking "
|
||||||
"Searching for the main-class is taking "
|
|
||||||
+ "some time, consider using setting "
|
+ "some time, consider using setting "
|
||||||
+ "'springBoot.mainClass'");
|
+ "'springBoot.mainClass'");
|
||||||
}
|
}
|
||||||
|
|
@ -65,8 +65,8 @@ public class BootRunTask extends JavaExec {
|
||||||
private void addResourcesIfNecessary() {
|
private void addResourcesIfNecessary() {
|
||||||
if (this.addResources) {
|
if (this.addResources) {
|
||||||
SourceSet mainSourceSet = SourceSets.findMainSourceSet(getProject());
|
SourceSet mainSourceSet = SourceSets.findMainSourceSet(getProject());
|
||||||
final File outputDir = (mainSourceSet == null ? null : mainSourceSet
|
final File outputDir = (mainSourceSet == null ? null
|
||||||
.getOutput().getResourcesDir());
|
: mainSourceSet.getOutput().getResourcesDir());
|
||||||
final Set<File> resources = new LinkedHashSet<File>();
|
final Set<File> resources = new LinkedHashSet<File>();
|
||||||
if (mainSourceSet != null) {
|
if (mainSourceSet != null) {
|
||||||
resources.addAll(mainSourceSet.getResources().getSrcDirs());
|
resources.addAll(mainSourceSet.getResources().getSrcDirs());
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -70,8 +70,8 @@ public class FindMainClassTask extends DefaultTask {
|
||||||
String mainClass = null;
|
String mainClass = null;
|
||||||
|
|
||||||
// Try the SpringBoot extension setting
|
// Try the SpringBoot extension setting
|
||||||
SpringBootPluginExtension bootExtension = project.getExtensions().getByType(
|
SpringBootPluginExtension bootExtension = project.getExtensions()
|
||||||
SpringBootPluginExtension.class);
|
.getByType(SpringBootPluginExtension.class);
|
||||||
if (bootExtension.getMainClass() != null) {
|
if (bootExtension.getMainClass() != null) {
|
||||||
mainClass = bootExtension.getMainClass();
|
mainClass = bootExtension.getMainClass();
|
||||||
}
|
}
|
||||||
|
|
@ -99,13 +99,11 @@ public class FindMainClassTask extends DefaultTask {
|
||||||
if (mainClass == null) {
|
if (mainClass == null) {
|
||||||
// Search
|
// Search
|
||||||
if (this.mainClassSourceSetOutput != null) {
|
if (this.mainClassSourceSetOutput != null) {
|
||||||
project.getLogger().debug(
|
project.getLogger().debug("Looking for main in: "
|
||||||
"Looking for main in: "
|
|
||||||
+ this.mainClassSourceSetOutput.getClassesDir());
|
+ this.mainClassSourceSetOutput.getClassesDir());
|
||||||
try {
|
try {
|
||||||
mainClass = MainClassFinder
|
mainClass = MainClassFinder.findSingleMainClass(
|
||||||
.findSingleMainClass(this.mainClassSourceSetOutput
|
this.mainClassSourceSetOutput.getClassesDir());
|
||||||
.getClassesDir());
|
|
||||||
project.getLogger().info("Computed main class: " + mainClass);
|
project.getLogger().info("Computed main class: " + mainClass);
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -47,8 +47,8 @@ public class RunPluginFeatures implements PluginFeatures {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mainClassNameFinder(Project project) {
|
private void mainClassNameFinder(Project project) {
|
||||||
FindMainClassTask findMainClassTask = project.getTasks().create(
|
FindMainClassTask findMainClassTask = project.getTasks()
|
||||||
FIND_MAIN_CLASS_TASK_NAME, FindMainClassTask.class);
|
.create(FIND_MAIN_CLASS_TASK_NAME, FindMainClassTask.class);
|
||||||
SourceSet mainSourceSet = SourceSets.findMainSourceSet(project);
|
SourceSet mainSourceSet = SourceSets.findMainSourceSet(project);
|
||||||
if (mainSourceSet != null) {
|
if (mainSourceSet != null) {
|
||||||
findMainClassTask.setMainClassSourceSetOutput(mainSourceSet.getOutput());
|
findMainClassTask.setMainClassSourceSetOutput(mainSourceSet.getOutput());
|
||||||
|
|
@ -64,15 +64,15 @@ public class RunPluginFeatures implements PluginFeatures {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBootRunTask(final Project project) {
|
private void addBootRunTask(final Project project) {
|
||||||
final JavaPluginConvention javaConvention = project.getConvention().getPlugin(
|
final JavaPluginConvention javaConvention = project.getConvention()
|
||||||
JavaPluginConvention.class);
|
.getPlugin(JavaPluginConvention.class);
|
||||||
|
|
||||||
BootRunTask run = project.getTasks().create(RUN_APP_TASK_NAME, BootRunTask.class);
|
BootRunTask run = project.getTasks().create(RUN_APP_TASK_NAME, BootRunTask.class);
|
||||||
run.setDescription("Run the project with support for "
|
run.setDescription("Run the project with support for "
|
||||||
+ "auto-detecting main class and reloading static resources");
|
+ "auto-detecting main class and reloading static resources");
|
||||||
run.setGroup("application");
|
run.setGroup("application");
|
||||||
run.setClasspath(javaConvention.getSourceSets().findByName("main")
|
run.setClasspath(
|
||||||
.getRuntimeClasspath());
|
javaConvention.getSourceSets().findByName("main").getRuntimeClasspath());
|
||||||
run.getConventionMapping().map("main", new Callable<Object>() {
|
run.getConventionMapping().map("main", new Callable<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object call() throws Exception {
|
public Object call() throws Exception {
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -43,8 +43,8 @@ final class SourceSets {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Iterable<SourceSet> getJavaSourceSets(Project project) {
|
private static Iterable<SourceSet> getJavaSourceSets(Project project) {
|
||||||
JavaPluginConvention plugin = project.getConvention().getPlugin(
|
JavaPluginConvention plugin = project.getConvention()
|
||||||
JavaPluginConvention.class);
|
.getPlugin(JavaPluginConvention.class);
|
||||||
if (plugin == null) {
|
if (plugin == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue