introduced ProjectArtifactFactory component this hides use of deprecated/legacy ArtifactFactory and allows custom project dependency artifact creation logic.
Signed-off-by: Igor Fedorenko <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/8643e009 Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/8643e009 Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/8643e009 Branch: refs/heads/master Commit: 8643e00993d778dbd35d1ae0d39664e7ec7afe3e Parents: ce6f0bf Author: Igor Fedorenko <[email protected]> Authored: Tue Nov 25 15:32:31 2014 -0500 Committer: Igor Fedorenko <[email protected]> Committed: Tue Nov 25 19:11:00 2014 -0500 ---------------------------------------------------------------------- .../internal/DefaultProjectArtifactFactory.java | 53 ++++++++++++++++++++ .../internal/LifecycleDependencyResolver.java | 20 ++++---- .../internal/ProjectArtifactFactory.java | 38 ++++++++++++++ 3 files changed, 101 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven/blob/8643e009/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultProjectArtifactFactory.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultProjectArtifactFactory.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultProjectArtifactFactory.java new file mode 100644 index 0000000..762fc72 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultProjectArtifactFactory.java @@ -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 ); + } + +} http://git-wip-us.apache.org/repos/asf/maven/blob/8643e009/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java index c95da2a..a907636 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java @@ -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 ) { http://git-wip-us.apache.org/repos/asf/maven/blob/8643e009/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ProjectArtifactFactory.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ProjectArtifactFactory.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ProjectArtifactFactory.java new file mode 100644 index 0000000..b4a8107 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/ProjectArtifactFactory.java @@ -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; +}
