Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
wrapperVersion=3.3.4
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.16/apache-maven-3.9.16-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.10.0/apache-maven-3.10.0-bin.zip
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public interface DistributionStage<NEXT_STEP extends BuildStage<DAEMON_TRIGGER_TYPE>, DAEMON_TRIGGER_TYPE extends DaemonBuildTrigger>
extends BuildStage<DAEMON_TRIGGER_TYPE> {

String DEFAULT_MAVEN_VERSION = "3.9.16";
String DEFAULT_MAVEN_VERSION = "3.10.0";

/**
* Configures EmbeddedMaven to build project with Maven 3 of given version. If the zip file is not cached in directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ void testMultiModuleSampleBuildWithMaven310() {

BuiltProject builtProject = EmbeddedMaven
.withMavenInvokerSet(request, invoker)
.useMaven3Version("3.9.16")
.useMaven3Version("3.10.0")
.build();
builtProject.setMavenLog(logBuffer.toString());

verifyMavenVersion(builtProject, "3.9.16");
verifyMavenVersion(builtProject, "3.10.0");
verifyMultiModuleSample(builtProject, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ void testWarSampleBuildWithMaven310() {

BuiltProject builtProject = EmbeddedMaven
.withMavenInvokerSet(request, invoker)
.useMaven3Version("3.9.16")
.useMaven3Version("3.10.0")
.build();
builtProject.setMavenLog(logBuffer.toString());

verifyWarSampleWithSources(builtProject);
verifyMavenVersion(builtProject, "3.9.16");
verifyMavenVersion(builtProject, "3.10.0");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ class PomEquippedEmbeddedMavenForMultiModuleSampleTestCase {
void testMultiModuleSampleBuildWithMaven310() {
BuiltProject builtProject = EmbeddedMaven
.forProject(workDirExtension.prepareProject(pathToMultiModulePom))
.useMaven3Version("3.9.16")
.useMaven3Version("3.10.0")
.setUserSettingsFile(new File("src/it/settings.xml"))
.setGoals("install")
.addProperty(multiModuleactivateModulesParamKey, multiModuleactivateModulesParamValue)
.addProperty(archiveNameModuleTwoParamKey, archiveNameModuleTwoParamValue)
.setShowVersion(true)
.build();

verifyMavenVersion(builtProject, "3.9.16");
verifyMavenVersion(builtProject, "3.10.0");
verifyMultiModuleSample(builtProject, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ void testWarSampleBuildWithMaven310() {
BuiltProject builtProject = EmbeddedMaven
.forProject(workDirExtension.prepareProject(pathToWarSamplePom))
.setUserSettingsFile(new File("src/it/settings.xml"))
.useMaven3Version("3.9.16")
.useMaven3Version("3.10.0")
.setGoals("clean", "package", "source:jar")
.setShowVersion(true)
.build();

verifyWarSampleWithSources(builtProject);
verifyMavenVersion(builtProject, "3.9.16");
verifyMavenVersion(builtProject, "3.10.0");
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion maven/impl-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-http</artifactId>
<artifactId>maven-resolver-transport-apache</artifactId>
</dependency>

<!-- org.codehaus.plexus -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,22 @@ private static File artifactToFile(final Artifact artifact) throws IllegalArgume
throw new IllegalArgumentException("ArtifactResult must not be null");
}

final File file = artifact.getPath().toFile();

// FIXME: this is not a safe assumption, file can have a different name
if ("pom.xml".equals(artifact.getFile().getName())) {
if ("pom.xml".equals(file.getName())) {

String artifactId = artifact.getArtifactId();
String extension = artifact.getExtension();
String classifier = artifact.getClassifier();

File root = new File(artifact.getFile().getParentFile(), "target/classes");
File root = new File(file.getParentFile(), "target/classes");
if (!Validate.isNullOrEmpty(classifier) && "tests".equals(classifier)) {
// SHRINKRES-102, allow test classes to be packaged as well
root = new File(artifact.getFile().getParentFile(), "target/test-classes");
root = new File(file.getParentFile(), "target/test-classes");
} else if ("war".equals(artifact.getProperty(ArtifactProperties.TYPE, null))) {
// SHRINKRES-263, allow .war files to be packaged as well
root = new File(artifact.getFile().getParentFile(), "target/" + artifactId + "-" + artifact.getVersion());
root = new File(file.getParentFile(), "target/" + artifactId + "-" + artifact.getVersion());
}

try {
Expand All @@ -162,7 +164,7 @@ private static File artifactToFile(final Artifact artifact) throws IllegalArgume
}

} else {
return artifact.getFile();
return file;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ public MavenWorkingSession loadPomFromFile(File pomFile, Properties userProperti
.setSystemProperties(SecurityActions.getProperties()).setProfiles(this.getSettingsDefinedProfiles())
.setPomFile(pomFile).setActiveProfileIds(SettingsXmlProfileSelector.explicitlyActivatedProfiles(profiles))
.setInactiveProfileIds(SettingsXmlProfileSelector.explicitlyDisabledProfiles(profiles))
.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL)
// Maven 3.10 treats models built with a validation level below 2.0 as external (resolved from a
// repository), which disables file based profile activation and restricts interpolation
.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0)
.setProcessPlugins(false);

if (userProperties != null){
Expand Down Expand Up @@ -279,7 +281,7 @@ private List<MavenDependency> filterFromLocal(final List<MavenDependency> depsFo
.noneMatch(result -> MavenConverter.asArtifact(dependency,
getSession().getArtifactTypeRegistry())
.setProperties(Collections.EMPTY_MAP)
.equals(result.getArtifact().setFile(null))))
.equals(result.getArtifact().setPath(null))))
.collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ public WorkspaceRepository getRepository() {
return new WorkspaceRepository("classpath");
}

// Resolver 2.x collects dependencies in parallel, while the caches, DocumentBuilder and XPath are not thread safe
@Override
public File findArtifact(final Artifact artifact) {
public synchronized File findArtifact(final Artifact artifact) {
for (String classpathEntry : classPathEntries) {
final FileInfo fileInfo = getClasspathFileInfo(classpathEntry);
final File file = fileInfo.getFile();
Expand Down Expand Up @@ -340,9 +341,8 @@ private Artifact createFoundArtifact(final File pomFile) {
version = getXPathParentVersionExpression().evaluate(pom);
}

final Artifact foundArtifact = new DefaultArtifact(groupId + ":" + artifactId + ":" + type + ":" + version);
foundArtifact.setFile(pomFile);
return foundArtifact;
return new DefaultArtifact(groupId + ":" + artifactId + ":" + type + ":" + version)
.setPath(pomFile.toPath());
} catch (final Exception e) {
throw new RuntimeException("Could not parse pom.xml: " + pomFile, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
import org.eclipse.aether.util.artifact.DefaultArtifactTypeRegistry;
import org.eclipse.aether.util.graph.manager.ClassicDependencyManager;
import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
import org.eclipse.aether.util.graph.transformer.ConfigurableVersionSelector;
import org.eclipse.aether.util.graph.transformer.ConflictResolver;
import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner;
import org.eclipse.aether.util.graph.transformer.JavaScopeDeriver;
import org.eclipse.aether.util.graph.transformer.JavaScopeSelector;
import org.eclipse.aether.util.graph.transformer.NearestVersionSelector;
import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector;
import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser;
import org.eclipse.aether.util.repository.DefaultMirrorSelector;
Expand Down Expand Up @@ -74,21 +74,21 @@ private enum SWRLocalRepositoryManager {
@Override
public LocalRepositoryManager localRepositoryManager(RepositorySystem system, RepositorySystemSession session,
File localRepositoryPath) {
return system.newLocalRepositoryManager(session, new LocalRepository(localRepositoryPath, "simple"));
return system.newLocalRepositoryManager(session, new LocalRepository(localRepositoryPath.toPath(), "simple"));
}
},
ENHANCED {
@Override
public LocalRepositoryManager localRepositoryManager(RepositorySystem system, RepositorySystemSession session,
File localRepositoryPath) {
return system.newLocalRepositoryManager(session, new LocalRepository(localRepositoryPath, "default"));
return system.newLocalRepositoryManager(session, new LocalRepository(localRepositoryPath.toPath(), "default"));
}
},
LEGACY {
@Override
public LocalRepositoryManager localRepositoryManager(RepositorySystem system, RepositorySystemSession session,
File localRepositoryPath) {
return system.newLocalRepositoryManager(session, new LocalRepository(localRepositoryPath, "simple"));
return system.newLocalRepositoryManager(session, new LocalRepository(localRepositoryPath.toPath(), "simple"));
}
};

Expand Down Expand Up @@ -253,8 +253,8 @@ public DependencyTraverser dependencyTraverser() {
*/
public DependencyGraphTransformer dependencyGraphTransformer() {
DependencyGraphTransformer transformer =
new ConflictResolver(new NearestVersionSelector(), new JavaScopeSelector(),
new SimpleOptionalitySelector(), new JavaScopeDeriver());
new ConflictResolver(new ConfigurableVersionSelector(new ConfigurableVersionSelector.Nearest()),
new JavaScopeSelector(), new SimpleOptionalitySelector(), new JavaScopeDeriver());

return new ChainedDependencyGraphTransformer(transformer, new JavaDependencyContextRefiner());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.logging.Logger;

import org.apache.maven.settings.Settings;
import org.eclipse.aether.ConfigurationProperties;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
Expand Down Expand Up @@ -100,6 +101,13 @@ public DefaultRepositorySystemSession getSession(final Settings settings, boolea
session.setSystemProperties(SecurityActions.getProperties());
session.setConfigProperties(SecurityActions.getProperties());

// Resolver 2.x defaults to level-order (breadth-first) ordering of resolved artifacts, keep the pre-order
// (depth-first) ordering of Resolver 1.x unless explicitly overridden by a system property
if (!session.getConfigProperties().containsKey(ConfigurationProperties.REPOSITORY_SYSTEM_DEPENDENCY_VISITOR)) {
session.setConfigProperty(ConfigurationProperties.REPOSITORY_SYSTEM_DEPENDENCY_VISITOR,
ConfigurationProperties.REPOSITORY_SYSTEM_DEPENDENCY_VISITOR_PREORDER);
}

return session;
}

Expand Down Expand Up @@ -194,6 +202,10 @@ public boolean accept(final DependencyNode node, List<DependencyNode> parents) {

List<MavenDependency> ancestors = new ArrayList<>();
for (DependencyNode parent : parents) {
// Resolver 2.0.24 passes the node itself as the first element of parents
if (parent == node) {
continue;
}
Dependency parentDependency = parent.getDependency();
if (parentDependency != null) {
ancestors.add(MavenConverter.fromDependency(parentDependency));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public ModelSource resolveModel(String groupId, String artifactId, String versio
+ version + " due to " + e.getMessage(), groupId, artifactId, version, e);
}

final File pomFile = pomArtifact.getFile();
final File pomFile = pomArtifact.getPath().toFile();

return new FileModelSource(pomFile);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void artifactDescriptorMissing(RepositoryEvent event) {
*/
@Override
public void artifactInstalled(RepositoryEvent event) {
log.fine("Installed " + event.getArtifact() + " to " + event.getFile());
log.fine("Installed " + event.getArtifact() + " to " + event.getPath());
}

/*
Expand All @@ -99,7 +99,7 @@ public void artifactInstalled(RepositoryEvent event) {
*/
@Override
public void artifactInstalling(RepositoryEvent event) {
log.finer("Installing " + event.getArtifact() + " to " + event.getFile());
log.finer("Installing " + event.getArtifact() + " to " + event.getPath());
}

/*
Expand Down Expand Up @@ -154,7 +154,7 @@ public void metadataDeploying(RepositoryEvent event) {
*/
@Override
public void metadataInstalled(RepositoryEvent event) {
log.fine("Installed " + event.getMetadata() + " to " + event.getFile());
log.fine("Installed " + event.getMetadata() + " to " + event.getPath());
}

/*
Expand All @@ -165,7 +165,7 @@ public void metadataInstalled(RepositoryEvent event) {
*/
@Override
public void metadataInstalling(RepositoryEvent event) {
log.finer("Installing " + event.getMetadata() + " to " + event.getFile());
log.finer("Installing " + event.getMetadata() + " to " + event.getPath());
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void packageDirectoriesWithClasses() throws IOException {
Mockito.when(testPomArtifactMock.getExtension()).thenReturn("xml");
Mockito.when(testPomArtifactMock.getClassifier()).thenReturn("");
Mockito.when(testPomArtifactMock.getVersion()).thenReturn("1.0.0");
Mockito.when(testPomArtifactMock.getFile()).thenReturn(artifactFile);
Mockito.when(testPomArtifactMock.getPath()).thenReturn(artifactFile.toPath());
Mockito.when(testPomArtifactMock.getProperty(ArtifactProperties.TYPE, testPomArtifactMock.getExtension()))
.thenReturn("pom");

Expand Down Expand Up @@ -85,7 +85,7 @@ void packageWar() throws IOException {
Mockito.when(testPomArtifactMock.getExtension()).thenReturn("war");
Mockito.when(testPomArtifactMock.getClassifier()).thenReturn("");
Mockito.when(testPomArtifactMock.getVersion()).thenReturn("1.0.0");
Mockito.when(testPomArtifactMock.getFile()).thenReturn(artifactFile);
Mockito.when(testPomArtifactMock.getPath()).thenReturn(artifactFile.toPath());
Mockito.when(testPomArtifactMock.getProperty(eq(ArtifactProperties.TYPE), any())).thenReturn("war");

ArtifactRequest artifactRequest = new ArtifactRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
*/
class PropertiesInterpolationTestCase {

private static final String FULL_EXTERNAL_INTERPOLATION_PROPERTY = "maven.model.dependencyInterpolation.full";

private static final File INTERPOLATED_REPOSITORY;
static {
String javaVersion = System.getProperty("java.version");
Expand All @@ -62,11 +64,26 @@ void interpolateSettingsXml() {

@Test
void interpolatePomWithSystemScopeXml() {
System.setProperty(FULL_EXTERNAL_INTERPOLATION_PROPERTY, "true");
try {
File[] files = Maven.configureResolver().fromFile("target/settings/profiles/settings.xml")
.resolve("org.jboss.shrinkwrap.test:test-system-scope:pom:1.0.0")
.withTransitivity().asFile();

new ValidationUtil("test-system-scope").validate(files);
} finally {
System.clearProperty(FULL_EXTERNAL_INTERPOLATION_PROPERTY);
}
}

// Maven 3.10 restricts interpolation in models resolved from a repository, so ${basedir} is not interpolated
@Test
void doNotInterpolateSystemScopeOfExternalPomByDefault() {

File[] files = Maven.configureResolver().fromFile("target/settings/profiles/settings.xml")
.resolve("org.jboss.shrinkwrap.test:test-system-scope:pom:1.0.0")
.withTransitivity().asFile();

new ValidationUtil("test-system-scope").validate(files);
Assertions.assertEquals(0, files.length, "System scoped dependency of an external pom is not resolved");
}
}
Loading
Loading