mirror of https://github.com/apache/maven.git
introduced ProjectArtifactFactory component
this hides use of deprecated/legacy ArtifactFactory and allows custom project dependency artifact creation logic. Signed-off-by: Igor Fedorenko <ifedorenko@apache.org>
This commit is contained in:
parent
ce6f0bfdb5
commit
8643e00993
|
@ -0,0 +1,53 @@
|
|||
package org.apache.maven.lifecycle.internal;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||
|
||||
@SuppressWarnings( "deprecation" )
|
||||
@Named
|
||||
public class DefaultProjectArtifactFactory
|
||||
implements ProjectArtifactFactory
|
||||
{
|
||||
private final ArtifactFactory artifactFactory;
|
||||
|
||||
@Inject
|
||||
public DefaultProjectArtifactFactory( ArtifactFactory artifactFactory )
|
||||
{
|
||||
this.artifactFactory = artifactFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Artifact> createArtifacts( MavenProject project )
|
||||
throws InvalidDependencyVersionException
|
||||
{
|
||||
return MavenMetadataSource.createArtifacts( artifactFactory, project.getDependencies(), null, null, project );
|
||||
}
|
||||
|
||||
}
|
|
@ -28,10 +28,12 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.apache.maven.RepositoryUtils;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.ArtifactUtils;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.eventspy.internal.EventSpyDispatcher;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.lifecycle.LifecycleExecutionException;
|
||||
|
@ -41,8 +43,6 @@ import org.apache.maven.project.DependencyResolutionResult;
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectDependenciesResolver;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.eclipse.aether.graph.Dependency;
|
||||
import org.eclipse.aether.graph.DependencyFilter;
|
||||
|
@ -60,20 +60,20 @@ import org.eclipse.aether.util.filter.ScopeDependencyFilter;
|
|||
* <p/>
|
||||
* NOTE: This class is not part of any public api and can be changed or deleted without prior notice.
|
||||
*/
|
||||
@Component( role = LifecycleDependencyResolver.class )
|
||||
@Named
|
||||
public class LifecycleDependencyResolver
|
||||
{
|
||||
|
||||
@Requirement
|
||||
@Inject
|
||||
private ProjectDependenciesResolver dependenciesResolver;
|
||||
|
||||
@Requirement
|
||||
@Inject
|
||||
private Logger logger;
|
||||
|
||||
@Requirement
|
||||
private ArtifactFactory artifactFactory;
|
||||
@Inject
|
||||
private ProjectArtifactFactory artifactFactory;
|
||||
|
||||
@Requirement
|
||||
@Inject
|
||||
private EventSpyDispatcher eventSpyDispatcher;
|
||||
|
||||
public LifecycleDependencyResolver()
|
||||
|
@ -116,7 +116,7 @@ public class LifecycleDependencyResolver
|
|||
{
|
||||
try
|
||||
{
|
||||
project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) );
|
||||
project.setDependencyArtifacts( artifactFactory.createArtifacts( project ) );
|
||||
}
|
||||
catch ( InvalidDependencyVersionException e )
|
||||
{
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package org.apache.maven.lifecycle.internal;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
|
||||
/**
|
||||
* Component interface responsible for creation of MavenProject#dependencyArtifacts instances.
|
||||
*
|
||||
* @since 3.2.4
|
||||
* @provisional This interface is part of work in progress and can be changed or removed without notice.
|
||||
*/
|
||||
public interface ProjectArtifactFactory
|
||||
{
|
||||
Set<Artifact> createArtifacts( MavenProject project )
|
||||
throws InvalidDependencyVersionException;
|
||||
}
|
Loading…
Reference in New Issue