You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jd...@apache.org on 2005/04/21 01:39:30 UTC
cvs commit: maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean RepositoryCleaner.java
jdcasey 2005/04/20 16:39:30
Modified: sandbox/repoclean/src/main/resources/META-INF/plexus
components.xml
sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean
RepositoryCleaner.java
Added: sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/layout
AlphaBridgingRepositoryLayout.java
Log:
o Fixed, pending changes to DefaultRepositoryLayout as outlined in MNG-321
PR: MNG-332
Revision Changes Path
1.1 maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/layout/AlphaBridgingRepositoryLayout.java
Index: AlphaBridgingRepositoryLayout.java
===================================================================
package org.apache.maven.tools.repoclean.artifact.layout;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
/*
* 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.
*/
public class AlphaBridgingRepositoryLayout
extends DefaultRepositoryLayout
{
public String pathOfMetadata( ArtifactMetadata metadata )
throws ArtifactPathFormatException
{
Artifact artifact = metadata.getArtifact();
StringBuffer path = new StringBuffer();
path.append( artifact.getGroupId().replace( '.', '/' ) ).append( '/' );
path.append( artifact.getArtifactId() ).append( '/' );
path.append( artifact.getBaseVersion() ).append( '/' );
path.append( metadata.getFilename() );
return path.toString();
}
}
1.8 +15 -0 maven-components/sandbox/repoclean/src/main/resources/META-INF/plexus/components.xml
Index: components.xml
===================================================================
RCS file: /home/cvs/maven-components/sandbox/repoclean/src/main/resources/META-INF/plexus/components.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- components.xml 7 Apr 2005 21:26:21 -0000 1.7
+++ components.xml 20 Apr 2005 23:39:30 -0000 1.8
@@ -1,5 +1,15 @@
<component-set>
<components>
+ <component>
+ <role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
+ <role-hint>alpha-bridging</role-hint>
+ <implementation>org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout</implementation>
+ <requirements>
+ <requirement>
+ <role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
+ </requirement>
+ </requirements>
+ </component>
<!--
|
|
@@ -100,6 +110,11 @@
<implementation>org.apache.maven.tools.repoclean.RepositoryCleaner</implementation>
<requirements>
<requirement>
+ <role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
+ <role-hint>alpha-bridging</role-hint>
+ <field-name>bridgingLayout</field-name>
+ </requirement>
+ <requirement>
<role>org.apache.maven.tools.repoclean.digest.ArtifactDigestVerifier</role>
</requirement>
<requirement>
1.15 +33 -1 maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/RepositoryCleaner.java
Index: RepositoryCleaner.java
===================================================================
RCS file: /home/cvs/maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/RepositoryCleaner.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- RepositoryCleaner.java 20 Apr 2005 21:51:25 -0000 1.14
+++ RepositoryCleaner.java 20 Apr 2005 23:39:30 -0000 1.15
@@ -25,6 +25,8 @@
import org.apache.maven.tools.repoclean.discover.ArtifactDiscoverer;
import org.apache.maven.tools.repoclean.index.ArtifactIndexer;
import org.apache.maven.tools.repoclean.report.FileReporter;
+import org.apache.maven.tools.repoclean.report.ReportWriteException;
+import org.apache.maven.tools.repoclean.report.Reporter;
import org.apache.maven.tools.repoclean.rewrite.ArtifactPomRewriter;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
@@ -62,6 +64,8 @@
private ArtifactDigestVerifier artifactDigestVerifier;
+ private ArtifactRepositoryLayout bridgingLayout;
+
private MailSender mailSender;
private ArtifactIndexer artifactIndexer;
@@ -241,7 +245,7 @@
Logger logger = getLogger();
ArtifactPomRewriter artifactPomRewriter = null;
-
+
try
{
logger.info( "Rewriting up to " + artifacts.size() + " artifacts (Should be " + ( artifacts.size() * 2 )
@@ -337,11 +341,15 @@
File sourcePom = new File( sourceRepositoryBase, sourceRepo.pathOfMetadata( pom ) );
File targetPom = new File( targetRepositoryBase, targetRepo.pathOfMetadata( pom ) );
+
+ File bridgedTargetPom = new File( targetRepositoryBase, bridgingLayout.pathOfMetadata( pom ) );
try
{
artifactPomRewriter.rewrite( artifact, sourcePom, targetPom, artifactReporter,
configuration.reportOnly() );
+
+ bridgePomLocations( targetPom, bridgedTargetPom, artifactReporter );
}
catch ( Exception e )
{
@@ -393,6 +401,30 @@
}
}
+ private void bridgePomLocations( File targetPom, File bridgedTargetPom, Reporter reporter ) throws IOException, ReportWriteException
+ {
+ if(targetPom.equals(bridgedTargetPom))
+ {
+ reporter.warn("Cannot create legacy-compatible copy of POM at: " + targetPom + "; legacy-compatible path is the same as the converted POM itself.");
+ }
+
+ FileInputStream in = null;
+ FileOutputStream out = null;
+
+ try
+ {
+ in = new FileInputStream(targetPom);
+ out = new FileOutputStream(bridgedTargetPom);
+
+ IOUtil.copy(in, out);
+ }
+ finally
+ {
+ IOUtil.close(in);
+ IOUtil.close(out);
+ }
+ }
+
private String buildArtifactReportPath( Artifact artifact )
{
String classifier = artifact.getClassifier();
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org