commit
514aede91e
|
|
@ -22,6 +22,7 @@ import java.util.concurrent.Callable;
|
|||
import java.util.function.Function;
|
||||
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.ResolvableDependencies;
|
||||
import org.gradle.api.file.CopySpec;
|
||||
import org.gradle.api.file.FileCollection;
|
||||
|
|
@ -72,15 +73,16 @@ public class BootJar extends Jar implements BootArchive {
|
|||
*/
|
||||
public BootJar() {
|
||||
this.support = new BootArchiveSupport(LAUNCHER, new LibrarySpec(), new ZipCompressionResolver());
|
||||
this.bootInfSpec = getProject().copySpec().into("BOOT-INF");
|
||||
this.mainClass = getProject().getObjects().property(String.class);
|
||||
Project project = getProject();
|
||||
this.bootInfSpec = project.copySpec().into("BOOT-INF");
|
||||
this.mainClass = project.getObjects().property(String.class);
|
||||
configureBootInfSpec(this.bootInfSpec);
|
||||
getMainSpec().with(this.bootInfSpec);
|
||||
getProject().getConfigurations().all((configuration) -> {
|
||||
project.getConfigurations().all((configuration) -> {
|
||||
ResolvableDependencies incoming = configuration.getIncoming();
|
||||
incoming.afterResolve((resolvableDependencies) -> {
|
||||
if (resolvableDependencies == incoming) {
|
||||
this.resolvedDependencies.processConfiguration(configuration);
|
||||
this.resolvedDependencies.processConfiguration(project, configuration);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -70,15 +70,16 @@ public class BootWar extends War implements BootArchive {
|
|||
*/
|
||||
public BootWar() {
|
||||
this.support = new BootArchiveSupport(LAUNCHER, new LibrarySpec(), new ZipCompressionResolver());
|
||||
this.mainClass = getProject().getObjects().property(String.class);
|
||||
Project project = getProject();
|
||||
this.mainClass = project.getObjects().property(String.class);
|
||||
getWebInf().into("lib-provided", fromCallTo(this::getProvidedLibFiles));
|
||||
this.support.moveModuleInfoToRoot(getRootSpec());
|
||||
getRootSpec().eachFile(this.support::excludeNonZipLibraryFiles);
|
||||
getProject().getConfigurations().all((configuration) -> {
|
||||
project.getConfigurations().all((configuration) -> {
|
||||
ResolvableDependencies incoming = configuration.getIncoming();
|
||||
incoming.afterResolve((resolvableDependencies) -> {
|
||||
if (resolvableDependencies == incoming) {
|
||||
this.resolvedDependencies.processConfiguration(configuration);
|
||||
this.resolvedDependencies.processConfiguration(project, configuration);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
|
|
@ -22,9 +22,9 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.artifacts.ModuleVersionIdentifier;
|
||||
import org.gradle.api.artifacts.ProjectDependency;
|
||||
import org.gradle.api.artifacts.ResolvedArtifact;
|
||||
import org.gradle.api.artifacts.ResolvedConfiguration;
|
||||
|
||||
|
|
@ -44,13 +44,15 @@ class ResolvedDependencies {
|
|||
|
||||
private final Map<Configuration, ResolvedConfigurationDependencies> configurationDependencies = new LinkedHashMap<>();
|
||||
|
||||
void processConfiguration(Configuration configuration) {
|
||||
Set<String> projectDependencyIds = configuration.getAllDependencies().withType(ProjectDependency.class).stream()
|
||||
.map((projectDependency) -> projectDependency.getGroup() + ":" + projectDependency.getName() + ":"
|
||||
+ projectDependency.getVersion())
|
||||
private String projectId(Project project) {
|
||||
return project.getGroup() + ":" + project.getName() + ":" + project.getVersion();
|
||||
}
|
||||
|
||||
void processConfiguration(Project project, Configuration configuration) {
|
||||
Set<String> localProjectIds = project.getRootProject().getAllprojects().stream().map(this::projectId)
|
||||
.collect(Collectors.toSet());
|
||||
this.configurationDependencies.put(configuration,
|
||||
new ResolvedConfigurationDependencies(projectDependencyIds, configuration.getResolvedConfiguration()));
|
||||
new ResolvedConfigurationDependencies(localProjectIds, configuration.getResolvedConfiguration()));
|
||||
}
|
||||
|
||||
DependencyDescriptor find(File file) {
|
||||
|
|
|
|||
|
|
@ -326,6 +326,7 @@ abstract class AbstractBootArchiveIntegrationTests {
|
|||
assertThat(jarFile.getEntry(layerToolsJar)).isNotNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "alpha-1.2.3.jar")).isNotNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "bravo-1.2.3.jar")).isNotNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "charlie-1.2.3.jar")).isNotNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "commons-lang3-3.9.jar")).isNotNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "spring-core-5.2.5.RELEASE.jar")).isNotNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "spring-jcl-5.2.5.RELEASE.jar")).isNotNull();
|
||||
|
|
@ -347,8 +348,9 @@ abstract class AbstractBootArchiveIntegrationTests {
|
|||
assertThat(indexedLayers.get("dependencies")).containsExactlyElementsOf(expectedDependencies);
|
||||
assertThat(indexedLayers.get("spring-boot-loader")).containsExactly("org/");
|
||||
assertThat(indexedLayers.get("snapshot-dependencies")).containsExactlyElementsOf(expectedSnapshotDependencies);
|
||||
assertThat(indexedLayers.get("application")).containsExactly(getExpectedApplicationLayerContents(
|
||||
this.classesPath, this.libPath + "alpha-1.2.3.jar", this.libPath + "bravo-1.2.3.jar"));
|
||||
assertThat(indexedLayers.get("application"))
|
||||
.containsExactly(getExpectedApplicationLayerContents(this.classesPath, this.libPath + "alpha-1.2.3.jar",
|
||||
this.libPath + "bravo-1.2.3.jar", this.libPath + "charlie-1.2.3.jar"));
|
||||
BuildResult listLayers = this.gradleBuild.build("listLayers");
|
||||
assertThat(listLayers.task(":listLayers").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
String listLayersOutput = listLayers.getOutput();
|
||||
|
|
@ -417,6 +419,7 @@ abstract class AbstractBootArchiveIntegrationTests {
|
|||
assertThat(jarFile.getEntry(layerToolsJar)).isNotNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "alpha-1.2.3.jar")).isNotNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "bravo-1.2.3.jar")).isNotNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "charlie-1.2.3.jar")).isNotNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "commons-lang3-3.9.jar")).isNotNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "spring-core-5.2.5.RELEASE.jar")).isNotNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "spring-jcl-5.2.5.RELEASE.jar")).isNotNull();
|
||||
|
|
@ -432,6 +435,7 @@ abstract class AbstractBootArchiveIntegrationTests {
|
|||
Set<String> expectedSubprojectDependencies = new TreeSet<>();
|
||||
expectedSubprojectDependencies.add(this.libPath + "alpha-1.2.3.jar");
|
||||
expectedSubprojectDependencies.add(this.libPath + "bravo-1.2.3.jar");
|
||||
expectedSubprojectDependencies.add(this.libPath + "charlie-1.2.3.jar");
|
||||
Set<String> expectedDependencies = new TreeSet<>();
|
||||
expectedDependencies.add(this.libPath + "spring-core-5.2.5.RELEASE.jar");
|
||||
expectedDependencies.add(this.libPath + "spring-jcl-5.2.5.RELEASE.jar");
|
||||
|
|
@ -492,7 +496,7 @@ abstract class AbstractBootArchiveIntegrationTests {
|
|||
private void writeSettingsGradle() {
|
||||
try (PrintWriter writer = new PrintWriter(
|
||||
new FileWriter(new File(this.gradleBuild.getProjectDir(), "settings.gradle")))) {
|
||||
writer.println("include 'alpha', 'bravo'");
|
||||
writer.println("include 'alpha', 'bravo', 'charlie'");
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class BootJarTests extends AbstractBootArchiveTests<BootJar> {
|
|||
|
||||
@Override
|
||||
void populateResolvedDependencies(Configuration configuration) {
|
||||
getTask().getResolvedDependencies().processConfiguration(configuration);
|
||||
getTask().getResolvedDependencies().processConfiguration(getTask().getProject(), configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
|||
|
||||
@Override
|
||||
void populateResolvedDependencies(Configuration configuration) {
|
||||
getTask().getResolvedDependencies().processConfiguration(configuration);
|
||||
getTask().getResolvedDependencies().processConfiguration(getTask().getProject(), configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -7,6 +7,11 @@ subprojects {
|
|||
apply plugin: 'java'
|
||||
group = 'org.example.projects'
|
||||
version = '1.2.3'
|
||||
if (it.name == 'bravo') {
|
||||
dependencies {
|
||||
implementation(project(':charlie'))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bootJar {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,11 @@ subprojects {
|
|||
apply plugin: 'java'
|
||||
group = 'org.example.projects'
|
||||
version = '1.2.3'
|
||||
if (it.name == 'bravo') {
|
||||
dependencies {
|
||||
implementation(project(':charlie'))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bootJar {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,11 @@ subprojects {
|
|||
apply plugin: 'java'
|
||||
group = 'org.example.projects'
|
||||
version = '1.2.3'
|
||||
if (it.name == 'bravo') {
|
||||
dependencies {
|
||||
implementation(project(':charlie'))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bootWar {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,11 @@ subprojects {
|
|||
apply plugin: 'java'
|
||||
group = 'org.example.projects'
|
||||
version = '1.2.3'
|
||||
if (it.name == 'bravo') {
|
||||
dependencies {
|
||||
implementation(project(':charlie'))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bootWar {
|
||||
|
|
|
|||
Loading…
Reference in New Issue