You are viewing a plain text version of this content. The canonical link for it is here.
Posted to m2-dev@maven.apache.org by br...@apache.org on 2005/03/24 11:30:58 UTC
cvs commit: maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/transform SnapshotTransformation.java
brett 2005/03/24 02:30:58
Modified: maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy
DeployMojo.java
maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install
InstallMojo.java
maven-artifact/src/main/java/org/apache/maven/artifact/installer
ArtifactInstaller.java
maven-artifact/src/main/java/org/apache/maven/artifact/metadata
AbstractArtifactMetadata.java ArtifactMetadata.java
SnapshotArtifactMetadata.java
maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout
AbstractArtifactRepositoryLayout.java
DefaultRepositoryLayout.java
LegacyRepositoryLayout.java
maven-artifact/src/main/java/org/apache/maven/artifact/transform
SnapshotTransformation.java
Added: maven-artifact/src/main/java/org/apache/maven/artifact/metadata
ModelMetadata.java
Log:
deploy/install POMs as a type of metadata so they are done atomically
Revision Changes Path
1.7 +12 -15 maven-components/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java
Index: DeployMojo.java
===================================================================
RCS file: /home/cvs/maven-components/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DeployMojo.java 24 Mar 2005 08:45:36 -0000 1.6
+++ DeployMojo.java 24 Mar 2005 10:30:58 -0000 1.7
@@ -20,6 +20,8 @@
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.deployer.ArtifactDeployer;
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
+import org.apache.maven.artifact.metadata.ArtifactMetadata;
+import org.apache.maven.artifact.metadata.ModelMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.AbstractPlugin;
import org.apache.maven.plugin.PluginExecutionException;
@@ -85,23 +87,18 @@
}
// Deploy the POM
- Artifact pomArtifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(),
- project.getVersion(), "pom" );
-
- File pom = new File( project.getFile().getParentFile(), "pom.xml" );
+ Artifact artifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(),
+ project.getPackaging() );
+ if ( !"pom".equals( project.getPackaging() ) )
+ {
+ File pom = new File( project.getFile().getParentFile(), "pom.xml" );
+ ArtifactMetadata metadata = new ModelMetadata( artifact, pom );
+ artifact.addMetadata( metadata );
+ }
try
{
- deployer.deploy( pom, pomArtifact, deploymentRepository, localRepository );
-
- //Deploy artifact
- if ( !"pom".equals( project.getPackaging() ) )
- {
- Artifact artifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(),
- project.getVersion(), project.getPackaging() );
-
- deployer.deploy( project.getBuild().getDirectory(), artifact, deploymentRepository, localRepository );
- }
+ deployer.deploy( project.getBuild().getDirectory(), artifact, deploymentRepository, localRepository );
}
catch ( ArtifactDeploymentException e )
{
1.12 +12 -15 maven-components/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java
Index: InstallMojo.java
===================================================================
RCS file: /home/cvs/maven-components/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- InstallMojo.java 22 Mar 2005 13:30:48 -0000 1.11
+++ InstallMojo.java 24 Mar 2005 10:30:58 -0000 1.12
@@ -20,6 +20,8 @@
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.installer.ArtifactInstallationException;
import org.apache.maven.artifact.installer.ArtifactInstaller;
+import org.apache.maven.artifact.metadata.ArtifactMetadata;
+import org.apache.maven.artifact.metadata.ModelMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.AbstractPlugin;
import org.apache.maven.plugin.PluginExecutionException;
@@ -63,24 +65,19 @@
public void execute()
throws PluginExecutionException
{
- // Install the POM
- Artifact pomArtifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(),
- project.getVersion(), "pom" );
+ Artifact artifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(),
+ project.getPackaging() );
- File pom = new File( project.getFile().getParentFile(), "pom.xml" );
+ if ( !"pom".equals( project.getPackaging() ) )
+ {
+ File pom = new File( project.getFile().getParentFile(), "pom.xml" );
+ ArtifactMetadata metadata = new ModelMetadata( artifact, pom );
+ artifact.addMetadata( metadata );
+ }
try
{
- installer.install( pom, pomArtifact, localRepository );
-
- //Install artifact
- if ( !"pom".equals( project.getPackaging() ) )
- {
- Artifact artifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(),
- project.getVersion(), project.getPackaging() );
-
- installer.install( project.getBuild().getDirectory(), artifact, localRepository );
- }
+ installer.install( project.getBuild().getDirectory(), artifact, localRepository );
}
catch ( ArtifactInstallationException e )
{
1.5 +2 -2 maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/installer/ArtifactInstaller.java
Index: ArtifactInstaller.java
===================================================================
RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/installer/ArtifactInstaller.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ArtifactInstaller.java 24 Mar 2005 08:45:36 -0000 1.4
+++ ArtifactInstaller.java 24 Mar 2005 10:30:58 -0000 1.5
@@ -30,7 +30,7 @@
String ROLE = ArtifactInstaller.class.getName();
/**
- * Install an artifact from a particular directory. The artifact handler is used to determine the filename
+ * Install an artifact from a particular directory. The artifact handler is used to determine the filenameSuffix
* of the source file.
*
* @param basedir the directory where the artifact is stored
1.2 +11 -6 maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/AbstractArtifactMetadata.java
Index: AbstractArtifactMetadata.java
===================================================================
RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/AbstractArtifactMetadata.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractArtifactMetadata.java 23 Mar 2005 14:55:15 -0000 1.1
+++ AbstractArtifactMetadata.java 24 Mar 2005 10:30:58 -0000 1.2
@@ -27,14 +27,19 @@
public abstract class AbstractArtifactMetadata
implements ArtifactMetadata
{
- protected final String filename;
+ protected final String filenameSuffix;
- protected final Artifact artifact;
+ protected Artifact artifact;
protected AbstractArtifactMetadata( Artifact artifact, String filename )
{
this.artifact = artifact;
- this.filename = filename;
+ this.filenameSuffix = filename;
+ }
+
+ public void setArtifact( Artifact artifact )
+ {
+ this.artifact = artifact;
}
public Artifact getArtifact()
@@ -42,8 +47,8 @@
return artifact;
}
- public String getFilename()
+ public String getFilenameSuffix()
{
- return filename;
+ return filenameSuffix;
}
}
1.4 +13 -4 maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadata.java
Index: ArtifactMetadata.java
===================================================================
RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadata.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ArtifactMetadata.java 24 Mar 2005 08:45:37 -0000 1.3
+++ ArtifactMetadata.java 24 Mar 2005 10:30:58 -0000 1.4
@@ -56,9 +56,18 @@
Artifact getArtifact();
/**
- * Get the filename of this metadata.
+ * Get the filenameSuffix of this metadata.
*
- * @return the filename
+ * @return the filenameSuffix
*/
- String getFilename();
+ String getFilenameSuffix();
+
+
+ /**
+ * Set the associated artifact.
+ *
+ * @param artifact the artifact
+ * @todo prefer not to have this, and just modify the artifacts as they are transformed
+ */
+ void setArtifact( Artifact artifact );
}
1.4 +1 -1 maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/SnapshotArtifactMetadata.java
1.1 maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ModelMetadata.java
Index: ModelMetadata.java
===================================================================
package org.apache.maven.artifact.metadata;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed 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 org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.io.IOException;
/**
* Attach a POM to an artifact.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id: ModelMetadata.java,v 1.1 2005/03/24 10:30:58 brett Exp $
*/
public class ModelMetadata
extends AbstractArtifactMetadata
{
private final File file;
public ModelMetadata( Artifact artifact, File file )
{
super( artifact, "pom" );
this.file = file;
}
public void storeInLocalRepository( ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
{
try
{
FileUtils.copyFile( file, new File( localRepository.getBasedir(), localRepository.pathOfMetadata( this ) ) );
}
catch ( ArtifactPathFormatException e )
{
throw new ArtifactMetadataRetrievalException( "Unable to install POM", e );
}
catch ( IOException e )
{
throw new ArtifactMetadataRetrievalException( "Unable to install POM", e );
}
}
public void retrieveFromRemoteRepository( ArtifactRepository remoteRepository, WagonManager wagonManager )
{
// not used - TODO: again indicates bad design?
}
}
1.6 +1 -1 maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/AbstractArtifactRepositoryLayout.java
Index: AbstractArtifactRepositoryLayout.java
===================================================================
RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/AbstractArtifactRepositoryLayout.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractArtifactRepositoryLayout.java 23 Mar 2005 14:55:15 -0000 1.5
+++ AbstractArtifactRepositoryLayout.java 24 Mar 2005 10:30:58 -0000 1.6
@@ -59,7 +59,7 @@
{
String path = basicPathOf( metadata.getArtifact(), metadataLayoutPattern() );
- path = StringUtils.replace( path, "${metadataFilename}", metadata.getFilename() );
+ path = StringUtils.replace( path, "${metadataSuffix}", metadata.getFilenameSuffix() );
return path;
}
1.5 +1 -1 maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/DefaultRepositoryLayout.java
Index: DefaultRepositoryLayout.java
===================================================================
RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/DefaultRepositoryLayout.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultRepositoryLayout.java 23 Mar 2005 14:55:15 -0000 1.4
+++ DefaultRepositoryLayout.java 24 Mar 2005 10:30:58 -0000 1.5
@@ -30,7 +30,7 @@
protected String metadataLayoutPattern()
{
- return "${groupPath}/${artifactId}/${version}/${metadataFilename}";
+ return "${groupPath}/${artifactId}/${version}/${artifactId}-${version}.${metadataSuffix}";
}
protected String groupIdAsPath( String groupId )
1.5 +1 -1 maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/LegacyRepositoryLayout.java
Index: LegacyRepositoryLayout.java
===================================================================
RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/LegacyRepositoryLayout.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- LegacyRepositoryLayout.java 24 Mar 2005 08:45:37 -0000 1.4
+++ LegacyRepositoryLayout.java 24 Mar 2005 10:30:58 -0000 1.5
@@ -30,7 +30,7 @@
protected String metadataLayoutPattern()
{
- return "${groupPath}/poms/${artifactId}-${version}-${metadataFilename}";
+ return "${groupPath}/poms/${artifactId}-${version}.${metadataSuffix}";
}
protected String groupIdAsPath( String groupId )
1.7 +10 -0 maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java
Index: SnapshotTransformation.java
===================================================================
RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SnapshotTransformation.java 24 Mar 2005 08:45:37 -0000 1.6
+++ SnapshotTransformation.java 24 Mar 2005 10:30:58 -0000 1.7
@@ -24,6 +24,9 @@
import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
+import java.util.Iterator;
+import java.util.List;
+
/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @author <a href="mailto:mmaczka@interia.pl">Michal Maczka</a>
@@ -218,8 +221,15 @@
// TODO: note, we could currently transform this in place, as it is only used through the deploy mojo,
// which creates the artifact and then disposes of it
+ List list = artifact.getMetadataList();
artifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), metadata.getVersion(),
artifact.getScope(), artifact.getType(), artifact.getClassifier() );
+ for ( Iterator i = list.iterator(); i.hasNext(); )
+ {
+ ArtifactMetadata m = (ArtifactMetadata) i.next();
+ m.setArtifact( artifact );
+ artifact.addMetadata( m );
+ }
artifact.addMetadata( metadata );
}
return artifact;