mirror of https://github.com/apache/maven.git
allow version spec/release version of an extension
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@225480 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
826413b74a
commit
5d46a03299
|
@ -57,5 +57,5 @@ public interface ArtifactFactory
|
||||||
|
|
||||||
Artifact createProjectArtifact( String groupId, String artifactId, String version, String scope );
|
Artifact createProjectArtifact( String groupId, String artifactId, String version, String scope );
|
||||||
|
|
||||||
Artifact createExtensionArtifact( String groupId, String artifactId, String version );
|
Artifact createExtensionArtifact( String groupId, String artifactId, VersionRange versionRange );
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,9 +86,9 @@ public class DefaultArtifactFactory
|
||||||
return createArtifact( groupId, artifactId, version, scope, "pom" );
|
return createArtifact( groupId, artifactId, version, scope, "pom" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Artifact createExtensionArtifact( String groupId, String artifactId, String version )
|
public Artifact createExtensionArtifact( String groupId, String artifactId, VersionRange versionRange )
|
||||||
{
|
{
|
||||||
return createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, "jar" );
|
return createArtifact( groupId, artifactId, versionRange, Artifact.SCOPE_RUNTIME, "jar", null, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
|
public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||||
|
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||||
|
import org.apache.maven.artifact.versioning.VersionRange;
|
||||||
import org.apache.maven.model.Extension;
|
import org.apache.maven.model.Extension;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.codehaus.plexus.PlexusConstants;
|
import org.codehaus.plexus.PlexusConstants;
|
||||||
|
@ -31,6 +33,7 @@ import org.codehaus.plexus.PlexusContainerException;
|
||||||
import org.codehaus.plexus.context.Context;
|
import org.codehaus.plexus.context.Context;
|
||||||
import org.codehaus.plexus.context.ContextException;
|
import org.codehaus.plexus.context.ContextException;
|
||||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
||||||
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -53,12 +56,26 @@ public class DefaultExtensionManager
|
||||||
private PlexusContainer container;
|
private PlexusContainer container;
|
||||||
|
|
||||||
public void addExtension( Extension extension, MavenProject project, ArtifactRepository localRepository )
|
public void addExtension( Extension extension, MavenProject project, ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException, PlexusContainerException
|
throws ArtifactResolutionException, PlexusContainerException, InvalidVersionSpecificationException
|
||||||
{
|
{
|
||||||
// TODO: version may be null
|
// TODO: this is duplicated with DefaultMavenProjectBuilder. Push into artifact factory.
|
||||||
Artifact artifact = artifactFactory.createExtensionArtifact( extension.getGroupId(), extension.getArtifactId(),
|
String version;
|
||||||
extension.getVersion() );
|
|
||||||
|
|
||||||
|
if ( StringUtils.isEmpty( extension.getVersion() ) )
|
||||||
|
{
|
||||||
|
version = "RELEASE";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
version = extension.getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
VersionRange versionRange = VersionRange.createFromVersionSpec( version );
|
||||||
|
Artifact artifact = artifactFactory.createExtensionArtifact( extension.getGroupId(), extension.getArtifactId(),
|
||||||
|
versionRange );
|
||||||
|
|
||||||
|
if ( artifact != null )
|
||||||
|
{
|
||||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( artifact ),
|
ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( artifact ),
|
||||||
project.getArtifact(),
|
project.getArtifact(),
|
||||||
project.getRemoteArtifactRepositories(),
|
project.getRemoteArtifactRepositories(),
|
||||||
|
@ -70,6 +87,7 @@ public class DefaultExtensionManager
|
||||||
container.addJarResource( a.getFile() );
|
container.addJarResource( a.getFile() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void contextualize( Context context )
|
public void contextualize( Context context )
|
||||||
throws ContextException
|
throws ContextException
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.maven.extension;
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
|
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||||
import org.apache.maven.model.Extension;
|
import org.apache.maven.model.Extension;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.codehaus.plexus.PlexusContainerException;
|
import org.codehaus.plexus.PlexusContainerException;
|
||||||
|
@ -31,5 +32,5 @@ import org.codehaus.plexus.PlexusContainerException;
|
||||||
public interface ExtensionManager
|
public interface ExtensionManager
|
||||||
{
|
{
|
||||||
void addExtension( Extension extension, MavenProject project, ArtifactRepository localRepository )
|
void addExtension( Extension extension, MavenProject project, ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException, PlexusContainerException;
|
throws ArtifactResolutionException, PlexusContainerException, InvalidVersionSpecificationException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,11 @@ package org.apache.maven.lifecycle;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
|
||||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
||||||
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
|
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||||
import org.apache.maven.execution.MavenExecutionResponse;
|
import org.apache.maven.execution.MavenExecutionResponse;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.extension.ExtensionManager;
|
import org.apache.maven.extension.ExtensionManager;
|
||||||
|
@ -144,6 +145,10 @@ public class DefaultLifecycleExecutor
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException( "Unable to initialise extensions", e );
|
throw new LifecycleExecutionException( "Unable to initialise extensions", e );
|
||||||
}
|
}
|
||||||
|
catch ( InvalidVersionSpecificationException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( "Unable to initialise extensions", e );
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
response.setFinish( new Date() );
|
response.setFinish( new Date() );
|
||||||
|
|
Loading…
Reference in New Issue