|
|
|
@ -47,21 +47,17 @@ import org.apache.commons.compress.archivers.zip.ZipFile;
|
|
|
|
|
import org.gradle.api.Action;
|
|
|
|
|
import org.gradle.api.DomainObjectSet;
|
|
|
|
|
import org.gradle.api.Project;
|
|
|
|
|
import org.gradle.api.artifacts.ArtifactCollection;
|
|
|
|
|
import org.gradle.api.artifacts.Configuration;
|
|
|
|
|
import org.gradle.api.artifacts.DependencySet;
|
|
|
|
|
import org.gradle.api.artifacts.LenientConfiguration;
|
|
|
|
|
import org.gradle.api.artifacts.ModuleVersionIdentifier;
|
|
|
|
|
import org.gradle.api.artifacts.ProjectDependency;
|
|
|
|
|
import org.gradle.api.artifacts.ResolvableDependencies;
|
|
|
|
|
import org.gradle.api.artifacts.ResolvedArtifact;
|
|
|
|
|
import org.gradle.api.artifacts.ResolvedConfiguration;
|
|
|
|
|
import org.gradle.api.artifacts.ResolvedModuleVersion;
|
|
|
|
|
import org.gradle.api.artifacts.component.ComponentArtifactIdentifier;
|
|
|
|
|
import org.gradle.api.artifacts.component.ModuleComponentIdentifier;
|
|
|
|
|
import org.gradle.api.artifacts.component.ProjectComponentIdentifier;
|
|
|
|
|
import org.gradle.api.artifacts.result.ResolvedArtifactResult;
|
|
|
|
|
import org.gradle.api.internal.file.archive.ZipCopyAction;
|
|
|
|
|
import org.gradle.api.tasks.bundling.AbstractArchiveTask;
|
|
|
|
|
import org.gradle.api.tasks.bundling.Jar;
|
|
|
|
|
import org.gradle.internal.component.external.model.ModuleComponentArtifactIdentifier;
|
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
import org.junit.jupiter.api.io.TempDir;
|
|
|
|
@ -718,23 +714,21 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
|
|
|
|
this.task.classpath(classesJavaMain, resourcesMain, jarFile("first-library.jar"), jarFile("second-library.jar"),
|
|
|
|
|
jarFile("third-library-SNAPSHOT.jar"), jarFile("fourth-library.jar"),
|
|
|
|
|
jarFile("first-project-library.jar"), jarFile("second-project-library-SNAPSHOT.jar"));
|
|
|
|
|
Set<ResolvedArtifact> artifacts = new LinkedHashSet<>();
|
|
|
|
|
artifacts.add(mockLibraryArtifact("first-library.jar", "com.example", "first-library", "1.0.0"));
|
|
|
|
|
artifacts.add(mockLibraryArtifact("second-library.jar", "com.example", "second-library", "1.0.0"));
|
|
|
|
|
artifacts
|
|
|
|
|
.add(mockLibraryArtifact("third-library-SNAPSHOT.jar", "com.example", "third-library", "1.0.0.SNAPSHOT"));
|
|
|
|
|
artifacts.add(mockLibraryArtifact("fourth-library.jar", "com.example", "fourth-library", "1.0.0"));
|
|
|
|
|
artifacts
|
|
|
|
|
.add(mockProjectArtifact("first-project-library.jar", "com.example", "first-project-library", "1.0.0"));
|
|
|
|
|
artifacts.add(mockProjectArtifact("second-project-library-SNAPSHOT.jar", "com.example",
|
|
|
|
|
Set<ResolvedArtifactResult> resolvedArtifacts = new LinkedHashSet<>();
|
|
|
|
|
resolvedArtifacts.add(mockArtifact("first-library.jar", "com.example", "first-library", "1.0.0"));
|
|
|
|
|
resolvedArtifacts.add(mockArtifact("second-library.jar", "com.example", "second-library", "1.0.0"));
|
|
|
|
|
resolvedArtifacts
|
|
|
|
|
.add(mockArtifact("third-library-SNAPSHOT.jar", "com.example", "third-library", "1.0.0.SNAPSHOT"));
|
|
|
|
|
resolvedArtifacts.add(mockArtifact("fourth-library.jar", "com.example", "fourth-library", "1.0.0"));
|
|
|
|
|
resolvedArtifacts
|
|
|
|
|
.add(mockArtifact("first-project-library.jar", "com.example", "first-project-library", "1.0.0"));
|
|
|
|
|
resolvedArtifacts.add(mockArtifact("second-project-library-SNAPSHOT.jar", "com.example",
|
|
|
|
|
"second-project-library", "1.0.0.SNAPSHOT"));
|
|
|
|
|
ResolvedConfiguration resolvedConfiguration = mock(ResolvedConfiguration.class);
|
|
|
|
|
LenientConfiguration lenientConfiguration = mock(LenientConfiguration.class);
|
|
|
|
|
given(resolvedConfiguration.getLenientConfiguration()).willReturn(lenientConfiguration);
|
|
|
|
|
given(lenientConfiguration.getArtifacts()).willReturn(artifacts);
|
|
|
|
|
Configuration configuration = mock(Configuration.class);
|
|
|
|
|
given(configuration.getResolvedConfiguration()).willReturn(resolvedConfiguration);
|
|
|
|
|
ArtifactCollection artifacts = mock(ArtifactCollection.class);
|
|
|
|
|
given(artifacts.getResolvedArtifacts()).willReturn(this.project.provider(() -> resolvedArtifacts));
|
|
|
|
|
ResolvableDependencies resolvableDependencies = mock(ResolvableDependencies.class);
|
|
|
|
|
given(resolvableDependencies.getArtifacts()).willReturn(artifacts);
|
|
|
|
|
Configuration configuration = mock(Configuration.class);
|
|
|
|
|
given(configuration.getIncoming()).willReturn(resolvableDependencies);
|
|
|
|
|
DependencySet dependencies = mock(DependencySet.class);
|
|
|
|
|
DomainObjectSet<ProjectDependency> projectDependencies = mock(DomainObjectSet.class);
|
|
|
|
@ -757,37 +751,21 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
|
|
|
|
FileCopyUtils.copy("override=%s\n".formatted(override).getBytes(StandardCharsets.ISO_8859_1), target);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
abstract void populateResolvedDependencies(Configuration configuration);
|
|
|
|
|
|
|
|
|
|
private ResolvedArtifact mockLibraryArtifact(String fileName, String group, String module, String version) {
|
|
|
|
|
ModuleComponentIdentifier moduleComponentIdentifier = mock(ModuleComponentIdentifier.class);
|
|
|
|
|
ComponentArtifactIdentifier libraryArtifactId = mock(ComponentArtifactIdentifier.class);
|
|
|
|
|
given(libraryArtifactId.getComponentIdentifier()).willReturn(moduleComponentIdentifier);
|
|
|
|
|
ResolvedArtifact libraryArtifact = mockArtifact(fileName, group, module, version);
|
|
|
|
|
given(libraryArtifact.getId()).willReturn(libraryArtifactId);
|
|
|
|
|
return libraryArtifact;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ResolvedArtifact mockProjectArtifact(String fileName, String group, String module, String version) {
|
|
|
|
|
ProjectComponentIdentifier projectComponentIdentifier = mock(ProjectComponentIdentifier.class);
|
|
|
|
|
ComponentArtifactIdentifier projectArtifactId = mock(ComponentArtifactIdentifier.class);
|
|
|
|
|
given(projectArtifactId.getComponentIdentifier()).willReturn(projectComponentIdentifier);
|
|
|
|
|
ResolvedArtifact projectArtifact = mockArtifact(fileName, group, module, version);
|
|
|
|
|
given(projectArtifact.getId()).willReturn(projectArtifactId);
|
|
|
|
|
return projectArtifact;
|
|
|
|
|
private void populateResolvedDependencies(Configuration configuration) {
|
|
|
|
|
getTask().resolvedArtifacts(configuration.getIncoming().getArtifacts().getResolvedArtifacts());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ResolvedArtifact mockArtifact(String fileName, String group, String module, String version) {
|
|
|
|
|
ModuleVersionIdentifier moduleVersionIdentifier = mock(ModuleVersionIdentifier.class);
|
|
|
|
|
given(moduleVersionIdentifier.getGroup()).willReturn(group);
|
|
|
|
|
given(moduleVersionIdentifier.getName()).willReturn(module);
|
|
|
|
|
given(moduleVersionIdentifier.getVersion()).willReturn(version);
|
|
|
|
|
ResolvedModuleVersion moduleVersion = mock(ResolvedModuleVersion.class);
|
|
|
|
|
given(moduleVersion.getId()).willReturn(moduleVersionIdentifier);
|
|
|
|
|
ResolvedArtifact libraryArtifact = mock(ResolvedArtifact.class);
|
|
|
|
|
private ResolvedArtifactResult mockArtifact(String fileName, String group, String module, String version) {
|
|
|
|
|
ModuleComponentArtifactIdentifier moduleId = mock(ModuleComponentArtifactIdentifier.class);
|
|
|
|
|
ModuleComponentIdentifier componentId = mock(ModuleComponentIdentifier.class);
|
|
|
|
|
given(moduleId.getComponentIdentifier()).willReturn(componentId);
|
|
|
|
|
given(componentId.getGroup()).willReturn(group);
|
|
|
|
|
given(componentId.getModule()).willReturn(module);
|
|
|
|
|
given(componentId.getVersion()).willReturn(version);
|
|
|
|
|
ResolvedArtifactResult libraryArtifact = mock(ResolvedArtifactResult.class);
|
|
|
|
|
File file = new File(this.temp, fileName).getAbsoluteFile();
|
|
|
|
|
given(libraryArtifact.getFile()).willReturn(file);
|
|
|
|
|
given(libraryArtifact.getModuleVersion()).willReturn(moduleVersion);
|
|
|
|
|
given(libraryArtifact.getId()).willReturn(moduleId);
|
|
|
|
|
return libraryArtifact;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|