Skip to content
Merged
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
10 changes: 10 additions & 0 deletions maven-compat/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,20 @@ under the License.
<artifactId>plexus-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<!-- We have to migrate one single component that extends maven-core JSR330 component: TestProjectBuilder -->
<plugin>
<groupId>org.eclipse.sisu</groupId>
<artifactId>sisu-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ protected MavenProject getProject(File pom) throws Exception {
private void initRepoSession(ProjectBuildingRequest request) {
File localRepo = new File(request.getLocalRepository().getBasedir());
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
// many maven-compat tests use checkout as local repo; disable this feat to not create uncommited changes
session.setConfigProperty("aether.remoteRepositoryFilter.prefixes.resolvePrefixFiles", "false");
session.setLocalRepositoryManager(new LegacyLocalRepositoryManager(localRepo));
request.setRepositorySession(session);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import org.apache.maven.artifact.Artifact;
import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader;
import org.codehaus.plexus.component.repository.ComponentDescriptor;
import org.codehaus.plexus.testing.PlexusTest;
import org.eclipse.aether.impl.ArtifactDescriptorReader;
import org.eclipse.aether.impl.ArtifactResolver;
Expand All @@ -45,8 +46,12 @@ public void setUp() throws Exception {

projectBuilder = container.lookup(ProjectBuilder.class, "classpath");

// create fake project builder component descriptor
ComponentDescriptor<TestProjectBuilder> fakeProjectBuilder =
new ComponentDescriptor<>(TestProjectBuilder.class, container.getContainerRealm());
fakeProjectBuilder.setRoleClass(ProjectClasspathTest.class);
// the metadata source looks up the default impl, so we have to trick it
container.addComponent(projectBuilder, ProjectBuilder.class, "default");
container.addComponentDescriptor(fakeProjectBuilder);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@
*/
package org.apache.maven.project;

import javax.inject.Named;
import javax.inject.Singleton;

import java.io.File;
import java.io.FileNotFoundException;
import java.net.URISyntaxException;
import java.util.Collections;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.codehaus.plexus.component.annotations.Component;

@Component(role = ProjectBuilder.class, hint = "classpath")
@Singleton
@Named("classpath")
public class TestProjectBuilder extends DefaultProjectBuilder {

@Override
Expand Down
15 changes: 11 additions & 4 deletions maven-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ under the License.
<name>Maven Core</name>
<description>Maven Core classes.</description>

<properties>
<!-- Used in filtering of property file defining the versions of the plugins used in lifecycles -->
<version.maven-ejb-plugin>3.3.0</version.maven-ejb-plugin>
<version.maven-rar-plugin>3.1.0</version.maven-rar-plugin>
</properties>

<dependencies>
<!-- Maven -->
<dependency>
Expand Down Expand Up @@ -166,6 +172,11 @@ under the License.
<artifactId>plexus-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -192,10 +203,6 @@ under the License.
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
</plugin>
<plugin>
<groupId>org.eclipse.sisu</groupId>
<artifactId>sisu-maven-plugin</artifactId>
Expand Down
32 changes: 18 additions & 14 deletions maven-core/src/main/java/org/apache/maven/DefaultMaven.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
*/
package org.apache.maven;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -52,45 +56,45 @@
import org.apache.maven.repository.LocalRepositoryNotAccessibleException;
import org.apache.maven.session.scope.internal.SessionScope;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.Logger;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.WorkspaceReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author Jason van Zyl
*/
@Component(role = Maven.class)
@Singleton
@Named
public class DefaultMaven implements Maven {

@Requirement
private Logger logger;
private final Logger logger = LoggerFactory.getLogger(getClass());

@Requirement
@Inject
protected ProjectBuilder projectBuilder;

@Requirement
@Inject
private LifecycleStarter lifecycleStarter;

@Requirement
@Inject
protected PlexusContainer container;

@Requirement
@Inject
private ExecutionEventCatapult eventCatapult;

@Requirement
@Inject
private LegacySupport legacySupport;

@Requirement
@Inject
private SessionScope sessionScope;

@Requirement
@Inject
private DefaultRepositorySystemSessionFactory repositorySessionFactory;

@Requirement(hint = GraphBuilder.HINT)
@Inject
@Named(GraphBuilder.HINT)
private GraphBuilder graphBuilder;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
*/
package org.apache.maven;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
Expand All @@ -38,22 +42,21 @@
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.artifact.ProjectArtifact;
import org.apache.maven.repository.RepositorySystem;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;

/**
* @deprecated As of 3.2.2, and there is no direct replacement. This is an internal class which was not marked as such,
* but should have been.
*
*/
@Deprecated
@Component(role = ProjectDependenciesResolver.class)
@Singleton
@Named
public class DefaultProjectDependenciesResolver implements ProjectDependenciesResolver {

@Requirement
@Inject
private RepositorySystem repositorySystem;

@Requirement
@Inject
private ResolutionErrorHandler resolutionErrorHandler;

public Set<Artifact> resolve(MavenProject project, Collection<String> scopesToResolve, MavenSession session)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,25 @@
*/
package org.apache.maven.artifact.factory;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.versioning.VersionRange;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;

/**
* DefaultArtifactFactory
*
*/
@Component(role = ArtifactFactory.class)
@Singleton
@Named
@SuppressWarnings("checkstyle:parameternumber")
public class DefaultArtifactFactory implements ArtifactFactory {
@Requirement
@Inject
private ArtifactHandlerManager artifactHandlerManager;

public Artifact createArtifact(String groupId, String artifactId, String version, String scope, String type) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.apache.maven.artifact.handler;

import static java.util.Objects.requireNonNull;

/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @author Jason van Zyl
*
* @since 3.10.0
*/
public final class ArtifactHandlerImpl implements ArtifactHandler {
public static final String LANGUAGE_NONE = "none";
public static final String LANGUAGE_JAVA = "java";

private final String type;
private final String extension;
private final String classifier;
private final String packaging;
private final boolean includesDependencies;
private final String language;
private final boolean addedToClasspath;

public ArtifactHandlerImpl(
String type,
String extension,
String classifier,
String packaging,
boolean includesDependencies,
String language,
boolean addedToClasspath) {
this.type = requireNonNull(type);
this.extension = extension;
this.classifier = classifier;
this.packaging = packaging;
this.includesDependencies = includesDependencies;
this.language = language;
this.addedToClasspath = addedToClasspath;
}

public String getType() {
return type;
}

@Override
public String getExtension() {
if (extension == null) {
return getType();
}
return extension;
}

@Override
public String getClassifier() {
return classifier;
}

@Deprecated
@Override
public String getDirectory() {
return getPackaging() + "s";
}

@Override
public String getPackaging() {
if (packaging == null) {
return getType();
}
return packaging;
}

@Override
public boolean isIncludesDependencies() {
return includesDependencies;
}

@Override
public String getLanguage() {
if (language == null) {
return LANGUAGE_NONE;
}
return language;
}

@Override
public boolean isAddedToClasspath() {
return addedToClasspath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
*/
package org.apache.maven.artifact.handler;

import org.codehaus.plexus.component.annotations.Component;
import javax.inject.Named;
import javax.inject.Singleton;

/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @author Jason van Zyl
*/
@Component(role = ArtifactHandler.class)
@Singleton
@Named
public class DefaultArtifactHandler implements ArtifactHandler {
private String extension;

Expand Down
Loading