Browse Source
The default behaviour doesn't change with this commit, but now
the user has the option to specify a 'classifier' property
either in springBoot { classifier = 'exec' } (i.e. globally
for all repackage tasks) or in each repackage task, e.g.
bootRepackage { classifier = 'exec' }. In that case the original
archive is not overwritten but copied into <file>-<classifier>.jar
(or .war etc.) and then enhanced.
Fixes gh-1113, fixes gh-141 also I believe.
pull/1118/merge
6 changed files with 233 additions and 7 deletions
@ -0,0 +1,63 @@ |
|||||||
|
/* |
||||||
|
* 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 static org.junit.Assert.assertNotNull; |
||||||
|
|
||||||
|
import java.util.jar.JarFile; |
||||||
|
|
||||||
|
import org.gradle.tooling.ProjectConnection; |
||||||
|
import org.junit.Test; |
||||||
|
import org.springframework.boot.dependency.tools.ManagedDependencies; |
||||||
|
|
||||||
|
/** |
||||||
|
* Tests for using the Gradle plugin's support for installing artifacts |
||||||
|
* |
||||||
|
* @author Dave Syer |
||||||
|
*/ |
||||||
|
public class ClassifierTests { |
||||||
|
|
||||||
|
private ProjectConnection project; |
||||||
|
|
||||||
|
private static final String BOOT_VERSION = ManagedDependencies.get().find( |
||||||
|
"spring-boot").getVersion(); |
||||||
|
|
||||||
|
@Test |
||||||
|
public void classifierInBootTask() throws Exception { |
||||||
|
project = new ProjectCreator().createProject("classifier"); |
||||||
|
project.newBuild().forTasks("build").withArguments( |
||||||
|
"-PbootVersion=" + BOOT_VERSION, "--stacktrace").run(); |
||||||
|
checkFilesExist("classifier"); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void classifierInBootExtension() throws Exception { |
||||||
|
project = new ProjectCreator().createProject("classifier-extension"); |
||||||
|
project.newBuild().forTasks("build").withArguments( |
||||||
|
"-PbootVersion=" + BOOT_VERSION, "--stacktrace", "--info").run(); |
||||||
|
} |
||||||
|
|
||||||
|
private void checkFilesExist(String name) throws Exception { |
||||||
|
JarFile jar = new JarFile("target/" + name + "/build/libs/" + name + ".jar"); |
||||||
|
assertNotNull(jar.getManifest()); |
||||||
|
jar.close(); |
||||||
|
jar = new JarFile("target/" + name + "/build/libs/" + name + "-exec.jar"); |
||||||
|
assertNotNull(jar.getManifest()); |
||||||
|
jar.close(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,30 @@ |
|||||||
|
buildscript { |
||||||
|
repositories { |
||||||
|
mavenLocal() |
||||||
|
} |
||||||
|
dependencies { |
||||||
|
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}") |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
apply plugin: 'java' |
||||||
|
apply plugin: 'maven' |
||||||
|
apply plugin: 'spring-boot' |
||||||
|
|
||||||
|
jar { |
||||||
|
baseName = 'classifier-extension' |
||||||
|
} |
||||||
|
|
||||||
|
springBoot { |
||||||
|
classifier = 'exec' |
||||||
|
mainClass = 'demo.Application' |
||||||
|
} |
||||||
|
|
||||||
|
repositories { |
||||||
|
mavenLocal() |
||||||
|
mavenCentral() |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
compile "org.springframework:spring-core" |
||||||
|
} |
||||||
@ -0,0 +1,30 @@ |
|||||||
|
buildscript { |
||||||
|
repositories { |
||||||
|
mavenLocal() |
||||||
|
} |
||||||
|
dependencies { |
||||||
|
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}") |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
apply plugin: 'java' |
||||||
|
apply plugin: 'maven' |
||||||
|
apply plugin: 'spring-boot' |
||||||
|
|
||||||
|
jar { |
||||||
|
baseName = 'classifier' |
||||||
|
} |
||||||
|
|
||||||
|
bootRepackage { |
||||||
|
classifier = 'exec' |
||||||
|
mainClass = 'demo.Application' |
||||||
|
} |
||||||
|
|
||||||
|
repositories { |
||||||
|
mavenLocal() |
||||||
|
mavenCentral() |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
compile "org.springframework:spring-core" |
||||||
|
} |
||||||
Loading…
Reference in new issue