mirror of https://github.com/apache/maven.git
*** empty log message ***
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162908 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
42491c6022
commit
b85639283f
|
@ -0,0 +1,7 @@
|
|||
maven
|
||||
maven2
|
||||
ibiblio
|
||||
target
|
||||
maven2.tar.gz
|
||||
poms.tar.gz
|
||||
reaper.tar.gz
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-reporeaper</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>Maven Repo Reaper</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xstream</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xpp3</groupId>
|
||||
<artifactId>xpp3</artifactId>
|
||||
<version>1.1.3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus</artifactId>
|
||||
<version>0.14-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
|
||||
. $MBOOT_HOME/maven.functions
|
||||
|
||||
findAndSetMavenRepoLocal
|
||||
|
||||
CP=
|
||||
CP=$CP:$repoLocal/maven/jars/maven-pom-converter-1.0-SNAPSHOT.jar
|
||||
CP=$CP:$repoLocal/asm/jars/asm-1.3.4.jar
|
||||
CP=$CP:$repoLocal/classworlds/jars/classworlds-1.1-SNAPSHOT.jar
|
||||
CP=$CP:$repoLocal/commons-cli/jars/commons-cli-1.0-beta-2.jar
|
||||
CP=$CP:$repoLocal/commons-httpclient/jars/commons-httpclient-2.0-rc2.jar
|
||||
CP=$CP:$repoLocal/commons-lang/jars/commons-lang-1.0.1.jar
|
||||
CP=$CP:$repoLocal/commons-logging/jars/commons-logging-1.0.3.jar
|
||||
CP=$CP:$repoLocal/jetty/jars/jetty-4.2.10.jar
|
||||
CP=$CP:$repoLocal/junit/jars/junit-3.8.1.jar
|
||||
CP=$CP:$repoLocal/log4j/jars/log4j-1.1.3.jar
|
||||
CP=$CP:$repoLocal/logkit/jars/logkit-1.0.1.jar
|
||||
CP=$CP:$repoLocal/marmalade/jars/marmalade-core-0.1.jar
|
||||
CP=$CP:$repoLocal/marmalade/jars/marmalade-el-ognl-0.1.jar
|
||||
CP=$CP:$repoLocal/maven/jars/maven-artifact-2.0-SNAPSHOT.jar
|
||||
CP=$CP:$repoLocal/maven/jars/maven-core-2.0-SNAPSHOT.jar
|
||||
CP=$CP:$repoLocal/maven/jars/maven-model-2.0-SNAPSHOT.jar
|
||||
CP=$CP:$repoLocal/maven/jars/maven-model-2.0-SNAPSHOT.jar
|
||||
CP=$CP:$repoLocal/maven/jars/maven-plugin-2.0-SNAPSHOT.jar
|
||||
CP=$CP:$repoLocal/maven/jars/wagon-api-0.9-SNAPSHOT.jar
|
||||
CP=$CP:$repoLocal/maven/jars/wagon-http-0.9-SNAPSHOT.jar
|
||||
CP=$CP:$repoLocal/modello/jars/modello-1.0-SNAPSHOT.jar
|
||||
CP=$CP:$repoLocal/ognl/jars/ognl-2.5.1.jar
|
||||
CP=$CP:$repoLocal/plexus/jars/plexus-0.14-SNAPSHOT.jar
|
||||
CP=$CP:$repoLocal/plexus/jars/plexus-compiler-api-1.0.jar
|
||||
CP=$CP:$repoLocal/plexus/jars/plexus-compiler-javac-1.0.jar
|
||||
CP=$CP:$repoLocal/plexus/jars/plexus-i18n-1.0-beta-2-SNAPSHOT.jar
|
||||
CP=$CP:$repoLocal/plexus/jars/plexus-jetty-httpd-1.0-SNAPSHOT.jar
|
||||
CP=$CP:$repoLocal/qdox/jars/qdox-1.2.jar
|
||||
CP=$CP:$repoLocal/servletapi/jars/servletapi-2.3.jar
|
||||
CP=$CP:$repoLocal/surefire/jars/surefire-booter-1.0.jar
|
||||
CP=$CP:$repoLocal/tagalog/jars/tagalog-0.1.jar
|
||||
CP=$CP:$repoLocal/xpp3/jars/xpp3-1.1.3.3.jar
|
||||
CP=$CP:$repoLocal/xstream/jars/xstream-1.0-SNAPSHOT.jar
|
||||
|
||||
java -classpath $CP org.apache.maven.converter.MavenPomConverterCli "$@"
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
CP=
|
||||
CP=$CP:target/classes
|
||||
CP=$CP:lib/plexus-0.14-SNAPSHOT.jar
|
||||
CP=$CP:lib/dom4j-1.4.jar
|
||||
CP=$CP:target/maven-reporeaper-1.0-SNAPSHOT.jar
|
||||
CP=$CP:lib/maven-reporeaper-1.0-SNAPSHOT.jar
|
||||
CP=$CP:lib/xstream-1.0-SNAPSHOT.jar
|
||||
CP=$CP:lib/maven-model-2.0-SNAPSHOT.jar
|
||||
|
||||
java -cp $CP org.apache.maven.converter.RepoReaper "$@"
|
|
@ -0,0 +1,27 @@
|
|||
package org.apache.maven.converter;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/*
|
||||
* LICENSE
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class AbstractMavenRepository
|
||||
implements MavenRepository
|
||||
{
|
||||
private File repository;
|
||||
|
||||
public void setRepository( File repository )
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public File getRepository()
|
||||
{
|
||||
return repository;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package org.apache.maven.converter;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 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 java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
|
||||
public class Fix
|
||||
{
|
||||
public static void main( String[] args )
|
||||
throws Exception
|
||||
{
|
||||
SAXReader r = new SAXReader();
|
||||
|
||||
Document d = r.read( new FileReader( args[0] ) );
|
||||
|
||||
Element root = d.getRootElement();
|
||||
|
||||
Element deps = root.element( "dependencies" );
|
||||
|
||||
for ( Iterator i = deps.elementIterator( "dependency" ); i.hasNext(); )
|
||||
{
|
||||
Element e = (Element) i.next();
|
||||
|
||||
Element id = e.element( "id" );
|
||||
|
||||
if ( id != null )
|
||||
{
|
||||
String text = id.getText();
|
||||
|
||||
id.detach();
|
||||
|
||||
e.addElement( "groupId" ).addText( text );
|
||||
|
||||
e.addElement( "artifactId" ).addText( text );
|
||||
|
||||
Element v = e.element( "version" );
|
||||
|
||||
v.detach();
|
||||
|
||||
e.add( v );
|
||||
|
||||
Element u = e.element( "url" );
|
||||
|
||||
if ( u != null )
|
||||
{
|
||||
u.detach();
|
||||
|
||||
e.add( u );
|
||||
}
|
||||
|
||||
Element p = e.element( "properties" );
|
||||
|
||||
if ( p != null )
|
||||
{
|
||||
p.detach();
|
||||
|
||||
e.add( p );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File f = new File( args[0] );
|
||||
|
||||
f.delete();
|
||||
|
||||
OutputStream os = new FileOutputStream( args[0] );
|
||||
|
||||
OutputFormat format = new OutputFormat();
|
||||
|
||||
format.setIndentSize( 2 );
|
||||
|
||||
format.setNewlines( true );
|
||||
|
||||
format.setTrimText( true );
|
||||
|
||||
XMLWriter writer = new XMLWriter( format );
|
||||
|
||||
writer.setOutputStream( os );
|
||||
|
||||
writer.write( d );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package org.apache.maven.converter;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 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 java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
|
||||
public class Fix2
|
||||
{
|
||||
public static void main( String[] args )
|
||||
throws Exception
|
||||
{
|
||||
SAXReader r = new SAXReader();
|
||||
|
||||
Document d = r.read( new FileReader( args[0] ) );
|
||||
|
||||
Element root = d.getRootElement();
|
||||
|
||||
Element id = root.element( "id" );
|
||||
|
||||
if ( id != null )
|
||||
{
|
||||
System.out.println( id.getName() );
|
||||
|
||||
id.setName( "artifactId" );
|
||||
}
|
||||
|
||||
File f = new File( args[0] );
|
||||
|
||||
f.delete();
|
||||
|
||||
OutputStream os = new FileOutputStream( args[0] );
|
||||
|
||||
OutputFormat format = new OutputFormat();
|
||||
|
||||
format.setIndentSize( 2 );
|
||||
|
||||
format.setNewlines( true );
|
||||
|
||||
format.setTrimText( true );
|
||||
|
||||
XMLWriter writer = new XMLWriter( format );
|
||||
|
||||
writer.setOutputStream( os );
|
||||
|
||||
writer.write( d );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package org.apache.maven.converter;
|
||||
|
||||
/*
|
||||
* LICENSE
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Maven1Repository
|
||||
extends AbstractMavenRepository
|
||||
{
|
||||
public Iterator getArtifactsByType( String type )
|
||||
throws Exception
|
||||
{
|
||||
List files = FileUtils.getFiles( getRepository(), "*/" + type + "s/*." + type, "" );
|
||||
|
||||
Collections.sort( files );
|
||||
|
||||
return files.iterator();
|
||||
}
|
||||
|
||||
public String getPomForArtifact( String artifactPath )
|
||||
throws Exception
|
||||
{
|
||||
int i = artifactPath.indexOf( '/' );
|
||||
|
||||
String groupId = artifactPath.substring( 0, i );
|
||||
|
||||
i = artifactPath.indexOf( '/', groupId.length() + 1 );
|
||||
|
||||
String artifactId = artifactPath.substring( i + 1 );
|
||||
|
||||
artifactId = artifactId.substring( 0, artifactId.length() - 4 );
|
||||
|
||||
System.out.println( "groupId: " + groupId );
|
||||
|
||||
System.out.println( "artifactId: " + artifactId );
|
||||
|
||||
String pomPath = groupId + "/poms/" + artifactId + ".pom";
|
||||
|
||||
File pom = new File( getRepository(), pomPath );
|
||||
|
||||
if ( !pom.exists() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return pomPath;
|
||||
}
|
||||
|
||||
public void installArtifact( File artifact, Model model )
|
||||
throws Exception
|
||||
{
|
||||
throw new Exception( "Not implemented." );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
package org.apache.maven.converter;
|
||||
|
||||
/*
|
||||
* LICENSE
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
|
||||
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Maven2Repository
|
||||
extends AbstractMavenRepository
|
||||
{
|
||||
public Iterator getArtifactsByType( String type )
|
||||
throws Exception
|
||||
{
|
||||
throw new Exception( "Not implemented." );
|
||||
}
|
||||
|
||||
public void installArtifact( File artifact, Model model )
|
||||
throws Exception
|
||||
{
|
||||
String type = model.getType();
|
||||
|
||||
if ( type.equals( "jar" ) )
|
||||
{
|
||||
installJar( artifact, model );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception( "This installer can only handle jars." );
|
||||
}
|
||||
}
|
||||
|
||||
public String getPomForArtifact( String artifactPath )
|
||||
throws Exception
|
||||
{
|
||||
throw new Exception( "Not implemented" );
|
||||
}
|
||||
|
||||
private void installJar( File artifact, Model model )
|
||||
throws Exception
|
||||
{
|
||||
String groupId = model.getGroupId();
|
||||
|
||||
String dest = groupId.replace( '.', File.separatorChar );
|
||||
|
||||
dest += File.separator + model.getArtifactId();
|
||||
|
||||
dest += File.separator + model.getVersion();
|
||||
|
||||
dest += File.separator + model.getArtifactId() + "-" + model.getVersion() + ".jar";
|
||||
|
||||
File destFile = new File( getRepository(), dest );
|
||||
|
||||
if ( !destFile.getParentFile().mkdirs() )
|
||||
{
|
||||
throw new Exception( "Could not make directories " + dest );
|
||||
}
|
||||
|
||||
System.out.println( "Installing " + destFile.getAbsolutePath() );
|
||||
|
||||
FileUtils.copyFile( artifact, destFile );
|
||||
|
||||
installMD5( destFile );
|
||||
|
||||
installPom( destFile, model );
|
||||
}
|
||||
|
||||
private void installPom( File artifact, Model model )
|
||||
throws Exception
|
||||
{
|
||||
File pom = new File( artifact.getAbsolutePath() + ".pom" );
|
||||
|
||||
System.out.println( "Installing " + pom );
|
||||
|
||||
MavenXpp3Writer v4Writer = new MavenXpp3Writer();
|
||||
|
||||
Writer output = new FileWriter( pom );
|
||||
|
||||
v4Writer.write( output, model );
|
||||
|
||||
output.close();
|
||||
|
||||
installMD5( pom );
|
||||
}
|
||||
|
||||
private void installMD5( File artifact )
|
||||
throws Exception
|
||||
{
|
||||
MessageDigest digester = MessageDigest.getInstance( "MD5" );
|
||||
|
||||
if ( digester == null )
|
||||
{
|
||||
throw new Exception( "Could not get MD5 message digester." );
|
||||
}
|
||||
|
||||
byte[] data = IOUtil.toByteArray( new FileInputStream( artifact ) );
|
||||
|
||||
digester.digest( data );
|
||||
|
||||
String sum = encode( digester.digest() );
|
||||
|
||||
File md5 = new File( artifact.getAbsolutePath() + ".md5" );
|
||||
|
||||
OutputStream output = new FileOutputStream( md5 );
|
||||
|
||||
PrintWriter writer = new PrintWriter( output );
|
||||
|
||||
writer.println( sum.getBytes() );
|
||||
|
||||
writer.close();
|
||||
|
||||
output.close();
|
||||
|
||||
System.out.println( "Installing " + md5 );
|
||||
}
|
||||
|
||||
protected String encode( byte[] binaryData )
|
||||
throws Exception
|
||||
{
|
||||
if ( binaryData.length != 16 )
|
||||
{
|
||||
throw new Exception( "Error in input data." );
|
||||
}
|
||||
|
||||
String retValue = "";
|
||||
|
||||
for ( int i = 0; i < 16; i++ )
|
||||
{
|
||||
String t = Integer.toHexString( binaryData[i] & 0xff );
|
||||
|
||||
if ( t.length() == 1 )
|
||||
{
|
||||
retValue += ( "0" + t );
|
||||
}
|
||||
else
|
||||
{
|
||||
retValue += t;
|
||||
}
|
||||
}
|
||||
|
||||
return retValue.trim();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package org.apache.maven.converter;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class MavenPomConverter
|
||||
{
|
||||
/*
|
||||
private boolean interactive;
|
||||
|
||||
public void setInteractive( boolean interactive )
|
||||
{
|
||||
this.interactive = interactive;
|
||||
}
|
||||
|
||||
public void convert( String inputFile, String outputFile )
|
||||
throws MavenPomConvertionException
|
||||
{
|
||||
if ( interactive )
|
||||
throw new MavenPomConvertionException( "The tool doesn't do interactive convertion yet." );
|
||||
|
||||
MavenV300Xpp3Reader v3reader = new MavenV300Xpp3Reader();
|
||||
|
||||
try
|
||||
{
|
||||
v3reader.read( new FileReader( inputFile ) );
|
||||
}
|
||||
catch( FileNotFoundException ex )
|
||||
{
|
||||
throw new MavenPomConvertionException( "Could not read input file: " + inputFile, ex);
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
throw new MavenPomConvertionException( "Exception while reading the model.", ex );
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package org.apache.maven.converter;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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.codehaus.plexus.embed.Embedder;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class MavenPomConverterCli
|
||||
{
|
||||
/*
|
||||
private Embedder plexus = new Embedder();
|
||||
|
||||
public static void main( String[] args )
|
||||
{
|
||||
try
|
||||
{
|
||||
new MavenPomConverterCli().execute( args );
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
ex.printStackTrace( System.err );
|
||||
}
|
||||
}
|
||||
|
||||
public void execute( String[] args )
|
||||
throws Exception
|
||||
{
|
||||
start();
|
||||
|
||||
stop();
|
||||
}
|
||||
|
||||
private void start()
|
||||
throws Exception
|
||||
{
|
||||
plexus.start();
|
||||
}
|
||||
|
||||
private void stop()
|
||||
{
|
||||
try
|
||||
{
|
||||
plexus.stop();
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.apache.maven.converter;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class MavenPomConvertionException
|
||||
extends Exception
|
||||
{
|
||||
public MavenPomConvertionException( String msg )
|
||||
{
|
||||
super( msg );
|
||||
}
|
||||
|
||||
public MavenPomConvertionException( String msg, Throwable cause )
|
||||
{
|
||||
super( msg, cause );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package org.apache.maven.converter;
|
||||
|
||||
/*
|
||||
* LICENSE
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface MavenRepository
|
||||
{
|
||||
void setRepository( File repository );
|
||||
|
||||
File getRepository();
|
||||
|
||||
Iterator getArtifactsByType( String type )
|
||||
throws Exception;
|
||||
|
||||
String getPomForArtifact( String artifactPath )
|
||||
throws Exception;
|
||||
|
||||
public void installArtifact( File artifact, Model model )
|
||||
throws Exception;
|
||||
}
|
|
@ -0,0 +1,957 @@
|
|||
package org.apache.maven.converter;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004, Jason van Zyl and Trygve Laugstøl
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.CiManagement;
|
||||
import org.apache.maven.model.Contributor;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Developer;
|
||||
import org.apache.maven.model.DistributionManagement;
|
||||
import org.apache.maven.model.IssueManagement;
|
||||
import org.apache.maven.model.License;
|
||||
import org.apache.maven.model.MailingList;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Organization;
|
||||
import org.apache.maven.model.Parent;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.model.Resource;
|
||||
import org.apache.maven.model.Scm;
|
||||
import org.apache.maven.model.Site;
|
||||
import org.apache.maven.model.SourceModification;
|
||||
import org.apache.maven.model.UnitTest;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
|
||||
import org.apache.maven.model.v300.io.xpp3.MavenV300Xpp3Reader;
|
||||
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PomV3ToV4Converter
|
||||
{
|
||||
private org.apache.maven.model.v300.Model v3ParentModel;
|
||||
|
||||
public static void main( String[] args )
|
||||
{
|
||||
PomV3ToV4Converter converter = new PomV3ToV4Converter();
|
||||
|
||||
try
|
||||
{
|
||||
converter.work( args );
|
||||
|
||||
System.exit( 0 );
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
ex.printStackTrace( System.err );
|
||||
|
||||
System.exit( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
public void work( String[] args )
|
||||
throws Exception
|
||||
{
|
||||
if ( args.length != 1 )
|
||||
{
|
||||
throw new Exception( "Usage: converter <file> | <directory" );
|
||||
}
|
||||
|
||||
File input = new File( args[0] );
|
||||
|
||||
List files;
|
||||
|
||||
if ( !input.isDirectory() )
|
||||
{
|
||||
if ( !input.isFile() )
|
||||
{
|
||||
throw new Exception( "The input file isn't a file nor a directory: '" + input.getAbsolutePath() + "'." );
|
||||
}
|
||||
|
||||
files = new LinkedList();
|
||||
|
||||
files.add( input );
|
||||
}
|
||||
else
|
||||
{
|
||||
files = FileUtils.getFiles( input, "**/project.xml", "**/xdocs/**" );
|
||||
}
|
||||
|
||||
for ( Iterator it = files.iterator(); it.hasNext(); )
|
||||
{
|
||||
input = (File) it.next();
|
||||
|
||||
try
|
||||
{
|
||||
convertFile( input, new File( input.getParentFile(), "pom.xml" ) );
|
||||
|
||||
info( "Converted: " + input.getAbsolutePath() );
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
info( "Could not convert: " + input.getAbsolutePath() );
|
||||
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void convertFile( File input, File outputFile )
|
||||
throws Exception
|
||||
{
|
||||
Model model = convertFile( input );
|
||||
|
||||
MavenXpp3Writer v4Writer = new MavenXpp3Writer();
|
||||
|
||||
// dump to console
|
||||
Writer output = new OutputStreamWriter( System.out );
|
||||
|
||||
v4Writer.write( output, model );
|
||||
|
||||
output.flush();
|
||||
|
||||
// write the new pom.xml
|
||||
// File outputFile = new File( currentFile.getParentFile(), "pom.xml" );
|
||||
|
||||
System.err.println( "Writing new pom to: " + outputFile.getAbsolutePath() );
|
||||
|
||||
output = new FileWriter( outputFile );
|
||||
|
||||
v4Writer.write( output, model );
|
||||
|
||||
output.close();
|
||||
}
|
||||
|
||||
public Model convertFile( File input )
|
||||
throws Exception
|
||||
{
|
||||
org.apache.maven.model.v300.Model v3Model = loadV3Pom( input );
|
||||
|
||||
return convertModel( input, v3Model );
|
||||
}
|
||||
|
||||
public Model convertModel( File file, org.apache.maven.model.v300.Model v3Model )
|
||||
throws Exception
|
||||
{
|
||||
Model v4Model = populateModel( file, v3Model );
|
||||
|
||||
return v4Model;
|
||||
}
|
||||
|
||||
private Model populateModel( File file, org.apache.maven.model.v300.Model v3Model )
|
||||
throws Exception
|
||||
{
|
||||
Model v4Model = new Model();
|
||||
|
||||
v4Model.setModelVersion( "4.0.0" );
|
||||
|
||||
v4Model.setParent( getParent( file, v3Model ) );
|
||||
|
||||
// Group id
|
||||
String groupId = v3Model.getGroupId();
|
||||
|
||||
if( isEmpty( groupId ) && isEmpty( v3ParentModel.getGroupId() ) )
|
||||
{
|
||||
throw new Exception( "Missing 'groupId' from both pom and the extended pom." );
|
||||
}
|
||||
|
||||
v4Model.setGroupId( groupId );
|
||||
|
||||
// Artifact id
|
||||
String artifactId = v3Model.getArtifactId();
|
||||
|
||||
if ( isEmpty( artifactId ) )
|
||||
{
|
||||
throw new Exception( "Missing element 'artifactId'." );
|
||||
}
|
||||
|
||||
v4Model.setArtifactId( artifactId );
|
||||
|
||||
// Version
|
||||
String version = v3Model.getCurrentVersion();
|
||||
|
||||
if( isEmpty( version ) && isEmpty( v3ParentModel.getCurrentVersion() ) )
|
||||
{
|
||||
throw new Exception( "Missing 'currentVersion' from both pom and the extended pom." );
|
||||
}
|
||||
|
||||
v4Model.setVersion( version );
|
||||
|
||||
v4Model.setName( v3Model.getName() );
|
||||
|
||||
v4Model.setShortDescription( v3Model.getShortDescription() );
|
||||
|
||||
v4Model.setDescription( v3Model.getDescription() );
|
||||
|
||||
v4Model.setUrl( v3Model.getUrl() );
|
||||
|
||||
v4Model.setOrganization( getOrganization( v3Model ) );
|
||||
|
||||
v4Model.setLogo( v3Model.getLogo() );
|
||||
|
||||
v4Model.setIssueManagement( getIssueManagement( v3Model ) );
|
||||
|
||||
v4Model.setCiManagement( getCiManagement( v3Model ) );
|
||||
|
||||
v4Model.setInceptionYear( v3Model.getInceptionYear() );
|
||||
|
||||
if ( !isEmpty( v3Model.getGumpRepositoryId() ) )
|
||||
{
|
||||
warn( "The 'gumpRepositoryId' is removed from the version 4 pom." );
|
||||
}
|
||||
|
||||
v4Model.setRepositories( getRepositories( v3Model ) );
|
||||
|
||||
v4Model.setDevelopers( getDevelopers( v3Model ) );
|
||||
|
||||
v4Model.setContributors( getContributors( v3Model ) );
|
||||
|
||||
v4Model.setDependencies( getDependencies( v3Model ) );
|
||||
|
||||
v4Model.setLicenses( getLicenses( v3Model ) );
|
||||
|
||||
List versions = v3Model.getVersions();
|
||||
|
||||
if ( versions != null )
|
||||
{
|
||||
warn( "The <versions> list is removed in the version 4 of the pom." );
|
||||
}
|
||||
|
||||
List branches = v3Model.getBranches();
|
||||
|
||||
if ( branches != null )
|
||||
{
|
||||
warn( "The <branches> list is removed in the version 4 of the pom." );
|
||||
}
|
||||
|
||||
v4Model.setReports( returnList( v3Model.getReports() ) );
|
||||
|
||||
v4Model.setScm( getScm( v3Model ) );
|
||||
|
||||
v4Model.setBuild( getBuild( v3Model ) );
|
||||
|
||||
v4Model.setDistributionManagement( getDistributionManagement( v3Model ) );
|
||||
|
||||
v4Model.setPackage( v3Model.getPackage() );
|
||||
|
||||
return v4Model;
|
||||
}
|
||||
|
||||
private Parent getParent( File file, org.apache.maven.model.v300.Model v3Model )
|
||||
throws Exception
|
||||
{
|
||||
Parent parent = new Parent();
|
||||
|
||||
String extend = v3Model.getExtend();
|
||||
|
||||
if ( isEmpty( extend ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final String basedir = "${basedir}";
|
||||
|
||||
int i = extend.indexOf( basedir );
|
||||
|
||||
if ( i >= 0 )
|
||||
{
|
||||
extend = extend.substring( 0, i ) +
|
||||
file.getParentFile() + File.separator +
|
||||
extend.substring( i + basedir.length() + 1 );
|
||||
}
|
||||
|
||||
File extendFile = new File( extend );
|
||||
|
||||
if ( !extendFile.isAbsolute() )
|
||||
{
|
||||
extendFile = new File( file.getParentFile(), extend );
|
||||
}
|
||||
|
||||
if ( !extendFile.isFile() )
|
||||
{
|
||||
throw new Exception( "Could not find the file the pom extends: '" + extendFile.getAbsolutePath() + "' is not a file." );
|
||||
}
|
||||
|
||||
// try to find the parent pom.
|
||||
v3ParentModel = loadV3Pom( extendFile );
|
||||
|
||||
String groupId = v3ParentModel.getGroupId();
|
||||
|
||||
if ( isEmpty( groupId ) )
|
||||
{
|
||||
throw new Exception( "Missing groupId from the extended pom." );
|
||||
}
|
||||
|
||||
parent.setGroupId( groupId );
|
||||
|
||||
String artifactId = v3ParentModel.getArtifactId();
|
||||
|
||||
if ( isEmpty( artifactId ) )
|
||||
{
|
||||
throw new Exception( "Missing 'artifactId' from the extended pom." );
|
||||
}
|
||||
|
||||
parent.setArtifactId( artifactId );
|
||||
|
||||
String version = v3ParentModel.getCurrentVersion();
|
||||
|
||||
if ( isEmpty( version ) )
|
||||
{
|
||||
throw new Exception( "Missing 'currentVersion' from the extended pom." );
|
||||
}
|
||||
|
||||
parent.setVersion( version );
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
private Organization getOrganization( org.apache.maven.model.v300.Model v3Model )
|
||||
{
|
||||
Organization organization = new Organization();
|
||||
|
||||
if ( v3Model.getOrganization() == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
organization.setName( v3Model.getOrganization().getName() );
|
||||
|
||||
organization.setUrl( v3Model.getOrganization().getUrl() );
|
||||
|
||||
organization.setLogo( v3Model.getOrganization().getLogo() );
|
||||
|
||||
return organization;
|
||||
}
|
||||
|
||||
private IssueManagement getIssueManagement( org.apache.maven.model.v300.Model v3Model )
|
||||
{
|
||||
String issueTrackingUrl = v3Model.getIssueTrackingUrl();
|
||||
|
||||
if ( isEmpty( issueTrackingUrl ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
IssueManagement issueManagement = new IssueManagement();
|
||||
|
||||
issueManagement.setUrl( issueTrackingUrl );
|
||||
|
||||
return issueManagement;
|
||||
}
|
||||
|
||||
private CiManagement getCiManagement( org.apache.maven.model.v300.Model v3Model )
|
||||
{
|
||||
if ( v3Model.getBuild() == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
String nagEmailAddress = v3Model.getBuild().getNagEmailAddress();
|
||||
|
||||
if ( isEmpty( nagEmailAddress ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
CiManagement ciManagement = new CiManagement();
|
||||
|
||||
ciManagement.setNagEmailAddress( nagEmailAddress );
|
||||
|
||||
return ciManagement;
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// note: these are not SCM repositories but rather artifact repositories
|
||||
private List getRepositories( org.apache.maven.model.v300.Model v3Model )
|
||||
{
|
||||
List repositories = new ArrayList( 1 );
|
||||
|
||||
// warn( "" );
|
||||
|
||||
return returnList( repositories );
|
||||
}
|
||||
|
||||
// TODO:
|
||||
private List getMailingLists( org.apache.maven.model.v300.Model v3Model )
|
||||
{
|
||||
List mailingLists = new ArrayList();
|
||||
|
||||
List v3MailingLists = v3Model.getMailingLists();
|
||||
|
||||
if ( isEmpty( v3MailingLists ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for ( Iterator it = v3MailingLists.iterator(); it.hasNext(); )
|
||||
{
|
||||
org.apache.maven.model.v300.MailingList v3MailingList =
|
||||
(org.apache.maven.model.v300.MailingList) it.next();
|
||||
|
||||
MailingList mailingList = new MailingList();
|
||||
|
||||
mailingList.setName( v3MailingList.getName() );
|
||||
|
||||
mailingList.setSubscribe( v3MailingList.getSubscribe() );
|
||||
|
||||
mailingList.setUnsubscribe( v3MailingList.getUnsubscribe() );
|
||||
|
||||
mailingList.setArchive( v3MailingList.getArchive() );
|
||||
|
||||
mailingLists.add( mailingList );
|
||||
}
|
||||
|
||||
return mailingLists;
|
||||
}
|
||||
|
||||
private List getDevelopers( org.apache.maven.model.v300.Model v3Model )
|
||||
{
|
||||
List developers = new ArrayList();
|
||||
|
||||
List v3Developers = v3Model.getDevelopers();
|
||||
|
||||
if ( isEmpty( v3Developers ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for ( Iterator it = v3Developers.iterator(); it.hasNext(); )
|
||||
{
|
||||
org.apache.maven.model.v300.Developer v3Developer =
|
||||
(org.apache.maven.model.v300.Developer) it.next();
|
||||
|
||||
Developer developer = new Developer();
|
||||
|
||||
developer.setId( nullIfEmpty( v3Developer.getId() ) );
|
||||
|
||||
developer.setName( nullIfEmpty( v3Developer.getName() ) );
|
||||
|
||||
developer.setEmail( nullIfEmpty( v3Developer.getEmail() ) );
|
||||
|
||||
developer.setOrganization( nullIfEmpty( v3Developer.getOrganization() ) );
|
||||
|
||||
developer.setTimezone( nullIfEmpty( v3Developer.getTimezone() ) );
|
||||
|
||||
developer.setUrl( nullIfEmpty( v3Developer.getUrl() ) );
|
||||
|
||||
developer.setRoles( returnList( v3Developer.getRoles() ) );
|
||||
|
||||
developers.add( developer );
|
||||
}
|
||||
|
||||
return developers;
|
||||
}
|
||||
|
||||
private List getContributors( org.apache.maven.model.v300.Model v3Model )
|
||||
{
|
||||
List contributors = new ArrayList();
|
||||
|
||||
List v3Contributors = v3Model.getContributors();
|
||||
|
||||
if ( isEmpty( v3Contributors ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for ( Iterator it = v3Contributors.iterator(); it.hasNext(); )
|
||||
{
|
||||
org.apache.maven.model.v300.Contributor v3Contributor =
|
||||
(org.apache.maven.model.v300.Contributor) it.next();
|
||||
|
||||
Contributor contributor = new Contributor();
|
||||
|
||||
contributor.setName( nullIfEmpty( v3Contributor.getName() ) );
|
||||
|
||||
contributor.setEmail( nullIfEmpty( v3Contributor.getEmail() ) );
|
||||
|
||||
contributor.setOrganization( nullIfEmpty( v3Contributor.getOrganization() ) );
|
||||
|
||||
contributor.setTimezone( nullIfEmpty( v3Contributor.getTimezone() ) );
|
||||
|
||||
contributor.setUrl( nullIfEmpty( v3Contributor.getUrl() ) );
|
||||
|
||||
contributor.setRoles( returnList( v3Contributor.getRoles() ) );
|
||||
|
||||
contributors.add( contributor );
|
||||
}
|
||||
|
||||
return contributors;
|
||||
}
|
||||
|
||||
private List getDependencies( org.apache.maven.model.v300.Model v3Model )
|
||||
throws Exception
|
||||
{
|
||||
List dependencies = new ArrayList();
|
||||
|
||||
List v3Dependencies = v3Model.getDependencies();
|
||||
|
||||
if ( isEmpty( v3Dependencies ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for ( Iterator it = v3Dependencies.iterator(); it.hasNext(); )
|
||||
{
|
||||
org.apache.maven.model.v300.Dependency v3Dependency =
|
||||
(org.apache.maven.model.v300.Dependency) it.next();
|
||||
|
||||
Dependency dependency = new Dependency();
|
||||
|
||||
String id = nullIfEmpty( v3Dependency.getId() );
|
||||
|
||||
String groupId = nullIfEmpty( v3Dependency.getGroupId() );
|
||||
|
||||
String artifactId = nullIfEmpty( v3Dependency.getArtifactId() );
|
||||
|
||||
// old school
|
||||
if ( !isEmpty( id ) )
|
||||
{
|
||||
dependency.setGroupId( id );
|
||||
|
||||
dependency.setArtifactId( id );
|
||||
|
||||
if ( !isEmpty( groupId ) )
|
||||
{
|
||||
warn( "Both <dependency.id> and <dependency.groupId> is set, using <groupId> (id: " + id + ", groupId: " + groupId + ")." );
|
||||
}
|
||||
|
||||
if ( !isEmpty( artifactId ) )
|
||||
{
|
||||
warn( "Both <dependency.id> and <dependency.artifactId> is set, using <artifactId> (id: " + id + ", artifactId: " + artifactId + ")." );
|
||||
}
|
||||
}
|
||||
// new school
|
||||
else
|
||||
{
|
||||
if ( isEmpty( groupId ) )
|
||||
{
|
||||
fatal( "Missing dependency.groupId." );
|
||||
}
|
||||
|
||||
if ( isEmpty( artifactId ) )
|
||||
{
|
||||
fatal( "Missing dependency.artifactId." );
|
||||
}
|
||||
|
||||
dependency.setGroupId( groupId );
|
||||
|
||||
dependency.setArtifactId( artifactId );
|
||||
}
|
||||
|
||||
dependency.setType( nullIfEmpty( v3Dependency.getType() ) );
|
||||
|
||||
dependency.setVersion( nullIfEmpty( v3Dependency.getVersion() ) );
|
||||
|
||||
dependency.setUrl( nullIfEmpty( v3Dependency.getUrl() ) );
|
||||
|
||||
dependency.setProperties( v3Dependency.getProperties() );
|
||||
|
||||
dependencies.add( dependency );
|
||||
}
|
||||
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
private List getLicenses( org.apache.maven.model.v300.Model v3Model )
|
||||
{
|
||||
List licenses = new ArrayList();
|
||||
|
||||
List v3Licenses = v3Model.getLicenses();
|
||||
|
||||
if ( isEmpty( v3Licenses ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for ( Iterator it = v3Licenses.iterator(); it.hasNext(); )
|
||||
{
|
||||
org.apache.maven.model.v300.License v3License =
|
||||
(org.apache.maven.model.v300.License) it.next();
|
||||
|
||||
License license = new License();
|
||||
|
||||
license.setName( nullIfEmpty( v3License.getName() ) );
|
||||
|
||||
license.setUrl( nullIfEmpty( v3License.getUrl() ) );
|
||||
|
||||
license.setComments( nullIfEmpty( v3License.getComments() ) );
|
||||
|
||||
licenses.add( license );
|
||||
}
|
||||
|
||||
return licenses;
|
||||
}
|
||||
|
||||
private Scm getScm( org.apache.maven.model.v300.Model v3Model )
|
||||
{
|
||||
if ( v3Model.getRepository() == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Scm scm = new Scm();
|
||||
|
||||
// warn( "connection: " + v3Model.getRepository().getConnection() );
|
||||
|
||||
// warn( "developerConnection: " + v3Model.getRepository().getDeveloperConnection() );
|
||||
|
||||
// warn( "url: " + v3Model.getRepository().getUrl() );
|
||||
|
||||
scm.setConnection( v3Model.getRepository().getConnection() );
|
||||
|
||||
scm.setDeveloperConnection( v3Model.getRepository().getDeveloperConnection() );
|
||||
|
||||
scm.setUrl( v3Model.getRepository().getUrl() );
|
||||
|
||||
return scm;
|
||||
}
|
||||
|
||||
private Build getBuild( org.apache.maven.model.v300.Model v3Model )
|
||||
{
|
||||
org.apache.maven.model.v300.Build v3Build = v3Model.getBuild();
|
||||
|
||||
if ( v3Build == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Build build = new Build();
|
||||
|
||||
build.setSourceDirectory( v3Build.getSourceDirectory() );
|
||||
|
||||
List v3SourceModifications = v3Build.getSourceModifications();
|
||||
|
||||
if ( v3SourceModifications != null && v3SourceModifications.size() > 0 )
|
||||
{
|
||||
List sourceModifications = new ArrayList();
|
||||
|
||||
for ( Iterator it = v3SourceModifications.iterator(); it.hasNext(); )
|
||||
{
|
||||
org.apache.maven.model.v300.SourceModification v3SourceModification =
|
||||
(org.apache.maven.model.v300.SourceModification) it.next();
|
||||
|
||||
SourceModification sourceModification = new SourceModification();
|
||||
|
||||
sourceModification.setClassName( v3SourceModification.getClassName() );
|
||||
|
||||
sourceModification.setIncludes( getIncludes( v3SourceModification.getIncludes() ) );
|
||||
|
||||
sourceModification.setExcludes( getExcludes( v3SourceModification.getExcludes() ) );
|
||||
|
||||
sourceModifications.add( sourceModification );
|
||||
}
|
||||
|
||||
build.setSourceModifications( sourceModifications );
|
||||
}
|
||||
|
||||
build.setUnitTestSourceDirectory( v3Build.getUnitTestSourceDirectory() );
|
||||
|
||||
build.setAspectSourceDirectory( v3Build.getAspectSourceDirectory() );
|
||||
|
||||
org.apache.maven.model.v300.UnitTest v3UnitTest = v3Build.getUnitTest();
|
||||
|
||||
if ( v3UnitTest != null )
|
||||
{
|
||||
UnitTest unitTest = new UnitTest();
|
||||
|
||||
unitTest.setIncludes( getIncludes( v3UnitTest.getIncludes() ) );
|
||||
|
||||
unitTest.setExcludes( getExcludes( v3UnitTest.getExcludes() ) );
|
||||
|
||||
unitTest.setResources( convertResources( v3UnitTest.getResources() ) );
|
||||
|
||||
build.setUnitTest( unitTest );
|
||||
}
|
||||
|
||||
build.setResources( convertResources( v3Build.getResources() ) );
|
||||
|
||||
return build;
|
||||
}
|
||||
|
||||
private DistributionManagement getDistributionManagement( org.apache.maven.model.v300.Model v3Model )
|
||||
throws Exception
|
||||
{
|
||||
DistributionManagement distributionManagement = new DistributionManagement();
|
||||
|
||||
Site site = null;
|
||||
|
||||
String siteAddress = v3Model.getSiteAddress();
|
||||
|
||||
String siteDirectory = v3Model.getSiteDirectory();
|
||||
|
||||
if ( isEmpty( siteAddress ) )
|
||||
{
|
||||
if ( !isEmpty( siteDirectory ) )
|
||||
{
|
||||
site = new Site();
|
||||
|
||||
site.setId( "default" );
|
||||
|
||||
site.setName( "Default Site" );
|
||||
|
||||
site.setUrl( "file://" + siteDirectory );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isEmpty( siteDirectory ) )
|
||||
{
|
||||
throw new Exception( "Missing 'siteDirectory': Both siteAddress and siteDirectory must be set at the same time." );
|
||||
}
|
||||
|
||||
site = new Site();
|
||||
|
||||
site.setId( "default" );
|
||||
|
||||
site.setName( "Default Site" );
|
||||
|
||||
site.setUrl( "scp://" + siteAddress + "/" + siteDirectory );
|
||||
}
|
||||
|
||||
distributionManagement.setSite( site );
|
||||
|
||||
String distributionSite = v3Model.getDistributionSite();
|
||||
|
||||
String distributionDirectory = v3Model.getDistributionDirectory();
|
||||
|
||||
Repository repository = null;
|
||||
|
||||
if ( isEmpty( distributionSite ) )
|
||||
{
|
||||
if ( !isEmpty( distributionDirectory ) )
|
||||
{
|
||||
repository = new Repository();
|
||||
|
||||
repository.setId( "default" );
|
||||
|
||||
repository.setName( "Default Repository" );
|
||||
|
||||
repository.setUrl( "file://" + distributionDirectory );
|
||||
// throw new Exception( "Missing 'distributionSite': Both distributionSite and distributionDirectory must be set." );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isEmpty( distributionDirectory ) )
|
||||
{
|
||||
throw new Exception( "Missing 'distributionDirectory': must be set is 'distributionSite' is set." );
|
||||
}
|
||||
|
||||
repository = new Repository();
|
||||
|
||||
repository.setId( "default" );
|
||||
|
||||
repository.setName( "Default Repository" );
|
||||
|
||||
repository.setUrl( distributionSite + "/" + distributionDirectory );
|
||||
}
|
||||
|
||||
distributionManagement.setRepository( repository );
|
||||
|
||||
if ( site == null && repository == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return distributionManagement;
|
||||
}
|
||||
|
||||
private org.apache.maven.model.v300.Model loadV3Pom( File inputFile )
|
||||
throws Exception
|
||||
{
|
||||
MavenV300Xpp3Reader v3Reader = new MavenV300Xpp3Reader();
|
||||
|
||||
org.apache.maven.model.v300.Model model;
|
||||
|
||||
model = v3Reader.read( new FileReader( inputFile ) );
|
||||
|
||||
String id = model.getId();
|
||||
|
||||
String groupId = model.getGroupId();
|
||||
|
||||
String artifactId = model.getArtifactId();
|
||||
|
||||
if ( !isEmpty( id ) )
|
||||
{
|
||||
int i = id.indexOf( "+" );
|
||||
|
||||
int j = id.indexOf( ":" );
|
||||
|
||||
if ( i > 0 )
|
||||
{
|
||||
model.setGroupId( id.substring( 0, i ) );
|
||||
|
||||
model.setArtifactId( id.replace( '+', '-' ) );
|
||||
}
|
||||
else if ( j > 0 )
|
||||
{
|
||||
model.setGroupId( id.substring( 0, j ) );
|
||||
|
||||
model.setArtifactId( id.substring( j + 1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
model.setGroupId( id );
|
||||
|
||||
model.setArtifactId( id );
|
||||
}
|
||||
|
||||
if ( !isEmpty( groupId ) )
|
||||
{
|
||||
warn( "Both <id> and <groupId> is set, using <groupId>." );
|
||||
|
||||
model.setGroupId( groupId );
|
||||
}
|
||||
|
||||
if ( !isEmpty( artifactId ) )
|
||||
{
|
||||
warn( "Both <id> and <artifactId> is set, using <artifactId>." );
|
||||
|
||||
model.setArtifactId( artifactId );
|
||||
}
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
private List getIncludes( List includes )
|
||||
{
|
||||
if ( includes == null || includes.size() == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return includes;
|
||||
}
|
||||
|
||||
private List getExcludes( List excludes )
|
||||
{
|
||||
if ( excludes == null || excludes.size() == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return excludes;
|
||||
}
|
||||
|
||||
private List convertResources( List v3Resources )
|
||||
{
|
||||
List resources = new ArrayList();
|
||||
|
||||
if ( v3Resources == null || v3Resources.size() == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for ( Iterator it = v3Resources.iterator(); it.hasNext(); )
|
||||
{
|
||||
org.apache.maven.model.v300.Resource v3Resource =
|
||||
(org.apache.maven.model.v300.Resource) it.next();
|
||||
|
||||
Resource resource = new Resource();
|
||||
|
||||
resource.setDirectory( v3Resource.getDirectory() );
|
||||
|
||||
resource.setTargetPath( v3Resource.getTargetPath() );
|
||||
|
||||
resource.setIncludes( getIncludes( v3Resource.getIncludes() ) );
|
||||
|
||||
resource.setExcludes( getExcludes( v3Resource.getExcludes() ) );
|
||||
|
||||
resources.add( resource );
|
||||
}
|
||||
|
||||
return resources;
|
||||
}
|
||||
/*
|
||||
private void assertNotEmpty( String fieldName, String value )
|
||||
throws Exception
|
||||
{
|
||||
if ( value == null || value.trim().length() == 0 )
|
||||
{
|
||||
throw new Exception( "Missing required field: '" + fieldName + "'." );
|
||||
}
|
||||
}
|
||||
*/
|
||||
private List returnList( List list )
|
||||
{
|
||||
if ( list == null || list.size() == 0 )
|
||||
return null;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private boolean isEmpty( String value )
|
||||
{
|
||||
return value == null || value.trim().length() == 0;
|
||||
}
|
||||
|
||||
private boolean isEmpty( List list )
|
||||
{
|
||||
return list == null || list.size() == 0;
|
||||
}
|
||||
|
||||
private String nullIfEmpty( String string )
|
||||
{
|
||||
if ( string == null || string.trim().length() == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
private void fatal( String msg )
|
||||
throws Exception
|
||||
{
|
||||
System.err.println( "[FATAL] " + msg );
|
||||
|
||||
throw new Exception( msg );
|
||||
}
|
||||
|
||||
private void warn( String msg )
|
||||
{
|
||||
System.err.println( "[WARN] " + msg );
|
||||
|
||||
System.err.flush();
|
||||
}
|
||||
|
||||
private void info( String msg )
|
||||
{
|
||||
System.err.println( msg );
|
||||
|
||||
System.err.flush();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,357 @@
|
|||
package org.apache.maven.converter;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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 java.io.File;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl </a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class RepoReaper
|
||||
{
|
||||
MavenRepository inRepository = new Maven1Repository();
|
||||
|
||||
MavenRepository outRepository = new Maven2Repository();
|
||||
|
||||
public static void main( String[] args )
|
||||
throws Exception
|
||||
{
|
||||
if ( args.length != 2 )
|
||||
{
|
||||
System.err.println( "Usage: repoReaper <input repo> <output repo>" );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
File inbase = new File( args[0] );
|
||||
|
||||
File outbase = new File( args[1] );
|
||||
|
||||
if ( !inbase.exists() )
|
||||
{
|
||||
System.err.println( "input repo doesn't exist: " + args[0] );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !outbase.exists() )
|
||||
{
|
||||
System.err.println( "output repo doesn't exist: " + args[0] );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
new RepoReaper().work( inbase, outbase );
|
||||
}
|
||||
|
||||
public void work( File inbase, File outbase )
|
||||
throws Exception
|
||||
{
|
||||
inRepository.setRepository( inbase );
|
||||
|
||||
System.out.println( "Input basedir: " + inbase.getAbsolutePath() );
|
||||
|
||||
outRepository.setRepository( outbase );
|
||||
|
||||
System.out.println( "Output basedir: " + outbase.getAbsolutePath() );
|
||||
|
||||
Iterator files = inRepository.getArtifactsByType( "jar" );
|
||||
|
||||
while( files.hasNext() )
|
||||
{
|
||||
File file = (File) files.next();
|
||||
|
||||
String filePath = file.getAbsolutePath().substring( inbase.getAbsolutePath().length() + 1 );
|
||||
|
||||
Model project;
|
||||
|
||||
String pomPath = inRepository.getPomForArtifact( filePath );
|
||||
|
||||
if ( pomPath == null )
|
||||
{
|
||||
warning( "Missing pom for artifact: " + filePath );
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// project = convertPom( pomPath, new File( inRepository.getRepository(), pomPath ) );
|
||||
|
||||
PomV3ToV4Converter converter = new PomV3ToV4Converter();
|
||||
|
||||
project = converter.convertFile( new File( inRepository.getRepository(), pomPath ) );
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
warning( "Could not parse: '" + pomPath + "'.");
|
||||
|
||||
Throwable t = ex;
|
||||
|
||||
while ( t != null )
|
||||
{
|
||||
warning( " " + ex.getMessage() );
|
||||
|
||||
t = t.getCause();
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( project != null )
|
||||
{
|
||||
/*
|
||||
File tmp = File.createTempFile( "maven-repo-reaper", "tmp" );
|
||||
|
||||
write( filePath, project );
|
||||
*/
|
||||
outRepository.installArtifact( new File( inbase, filePath ), project );
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
private Model convertPom( String fileName, File file )
|
||||
throws Exception
|
||||
{
|
||||
System.out.println( "Processing " + fileName );
|
||||
|
||||
SAXReader r = new SAXReader();
|
||||
|
||||
Model project = new Model();
|
||||
|
||||
Document pom = r.read( new FileReader( file ) );
|
||||
|
||||
Element root = pom.getRootElement();
|
||||
|
||||
Element modelVersion = root.element( "modelVersion" );
|
||||
|
||||
if ( modelVersion != null )
|
||||
{
|
||||
if ( modelVersion.getText().equals( "4.0.0") )
|
||||
{
|
||||
System.out.println( "This pom is already v4.0.0: " + fileName );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
fatal( "Invalid pom, <modelVersion> exists but isn't '4.0.0': " + fileName );
|
||||
}
|
||||
|
||||
project.setModelVersion( "4.0.0" );
|
||||
|
||||
// Fixing <id> => <groupId>+<artifactId>
|
||||
Element id = root.element( "id" );
|
||||
|
||||
Element groupId = root.element( "groupId" );
|
||||
|
||||
Element artifactId = root.element( "artifactId" );
|
||||
|
||||
if ( groupId != null )
|
||||
{
|
||||
project.setGroupId( groupId.getText() );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( id == null )
|
||||
{
|
||||
fatal( "Missing both <id> and <groupId>" );
|
||||
}
|
||||
|
||||
project.setGroupId( id.getText() );
|
||||
}
|
||||
|
||||
if ( artifactId != null )
|
||||
{
|
||||
project.setArtifactId( artifactId.getText() );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( id == null )
|
||||
{
|
||||
fatal( "Missing both <id> and <artifactId>" );
|
||||
}
|
||||
|
||||
project.setArtifactId( id.getText() );
|
||||
}
|
||||
|
||||
Element currentVersion = root.element( "currentVersion" );
|
||||
|
||||
if ( currentVersion == null )
|
||||
{
|
||||
int start = -1;
|
||||
|
||||
for ( int i = 0; i < fileName.length(); i++ )
|
||||
{
|
||||
if ( Character.isDigit( fileName.charAt( i ) ) )
|
||||
{
|
||||
start = i;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( start == -1 )
|
||||
{
|
||||
fatal( "Missing <currentVersion>." );
|
||||
}
|
||||
|
||||
String ver = fileName.substring( start, fileName.length() - 4 );
|
||||
|
||||
project.setVersion( ver );
|
||||
|
||||
warning( "Missing <currentVersion>, found the version from the filename, version: " + ver );
|
||||
}
|
||||
else
|
||||
{
|
||||
project.setVersion( currentVersion.getText() );
|
||||
}
|
||||
|
||||
Element dependencies = root.element( "dependencies" );
|
||||
|
||||
if ( dependencies != null )
|
||||
{
|
||||
Iterator it = dependencies.elementIterator( "dependency" );
|
||||
|
||||
while( it.hasNext() )
|
||||
{
|
||||
Dependency d = new Dependency();
|
||||
|
||||
Element dependency = (Element) it.next();
|
||||
|
||||
id = dependency.element( "id" );
|
||||
|
||||
groupId = dependency.element( "groupId" );
|
||||
|
||||
artifactId = dependency.element( "artifactId" );
|
||||
|
||||
Element type = dependency.element( "type" );
|
||||
|
||||
Element version = dependency.element( "version" );
|
||||
|
||||
if ( groupId == null )
|
||||
{
|
||||
if ( id == null )
|
||||
{
|
||||
warning( "Missing both dependency.id and dependency.groupId." );
|
||||
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
d.setGroupId( id.getText() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d.setGroupId( groupId.getText() );
|
||||
}
|
||||
|
||||
if ( artifactId == null )
|
||||
{
|
||||
if ( id == null )
|
||||
{
|
||||
warning( "Missing both dependency.id and dependency.artifactId. groupId: " + groupId.getText() );
|
||||
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
d.setArtifactId( id.getText() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d.setArtifactId( artifactId.getText() );
|
||||
}
|
||||
|
||||
if ( type != null )
|
||||
{
|
||||
d.setType( type.getText() );
|
||||
}
|
||||
|
||||
if ( version == null )
|
||||
{
|
||||
warning( "Missing dependency.version for " + d.getGroupId() + ":" + d.getArtifactId() );
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
d.setVersion( version.getText() );
|
||||
|
||||
if ( d.getGroupId().trim().equals( "${pom.groupId}" ) )
|
||||
{
|
||||
d.setGroupId( project.getGroupId() );
|
||||
}
|
||||
|
||||
if ( d.getArtifactId().trim().equals( "${pom.artifactId}" ) )
|
||||
{
|
||||
d.setArtifactId( project.getArtifactId() );
|
||||
}
|
||||
|
||||
if ( d.getType().trim().equals( "${pom.type}" ) )
|
||||
{
|
||||
d.setType( project.getType() );
|
||||
}
|
||||
|
||||
if ( d.getVersion().trim().equals( "${pom.version}" ) )
|
||||
{
|
||||
d.setVersion( project.getVersion() );
|
||||
}
|
||||
|
||||
project.getDependencies().add( d );
|
||||
}
|
||||
}
|
||||
|
||||
return project;
|
||||
}*/
|
||||
/*
|
||||
private static void write( File output, Model project )
|
||||
throws Exception
|
||||
{
|
||||
output.getParentFile().mkdirs();
|
||||
|
||||
XStream xstream = new XStream();
|
||||
|
||||
xstream.alias( "project", Model.class );
|
||||
xstream.alias( "dependency", Dependency.class );
|
||||
|
||||
// String xml = xstream.toXML( project );
|
||||
|
||||
// System.out.println( xml );
|
||||
|
||||
FileWriter writer = new FileWriter( output );
|
||||
|
||||
xstream.toXML( project, new PrettyPrintXMLWriter( writer ) );
|
||||
|
||||
writer.close();
|
||||
}
|
||||
*/
|
||||
private void fatal( String msg )
|
||||
throws Exception
|
||||
{
|
||||
throw new Exception( msg );
|
||||
}
|
||||
|
||||
private void warning( String msg )
|
||||
{
|
||||
System.err.println( msg );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package org.apache.maven.converter.project;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004, Jason van Zyl and Trygve Laugstøl
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Model300Converter
|
||||
implements ModelConverter
|
||||
{
|
||||
// ----------------------------------------------------------------------
|
||||
// ModelConverter Implementation
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public Object convert( Object fromModel )
|
||||
throws ModelConversionException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package org.apache.maven.converter.project;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004, Jason van Zyl and Trygve Laugstøl
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ModelConversionException extends Exception
|
||||
{
|
||||
public ModelConversionException( String msg )
|
||||
{
|
||||
super( msg );
|
||||
}
|
||||
|
||||
public ModelConversionException( String msg, Throwable cause )
|
||||
{
|
||||
super( msg, cause );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package org.apache.maven.converter.project;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004, Jason van Zyl and Trygve Laugstøl
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ModelConverter
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param model The model to convert from.
|
||||
* @return Returns the new model.
|
||||
* @throws ModelConversionException
|
||||
*/
|
||||
Object convert( Object model )
|
||||
throws ModelConversionException;
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package org.apache.maven.converter.tmp;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Dependency
|
||||
{
|
||||
private String groupId;
|
||||
private String artifactId;
|
||||
private String type;
|
||||
private String version;
|
||||
/**
|
||||
* @return Returns the artifactId.
|
||||
*/
|
||||
public String getArtifactId()
|
||||
{
|
||||
return artifactId;
|
||||
}
|
||||
/**
|
||||
* @param artifactId The artifactId to set.
|
||||
*/
|
||||
public void setArtifactId( String artifactId )
|
||||
{
|
||||
this.artifactId = artifactId;
|
||||
}
|
||||
/**
|
||||
* @return Returns the groupId.
|
||||
*/
|
||||
public String getGroupId()
|
||||
{
|
||||
return groupId;
|
||||
}
|
||||
/**
|
||||
* @param groupId The groupId to set.
|
||||
*/
|
||||
public void setGroupId( String groupId )
|
||||
{
|
||||
this.groupId = groupId;
|
||||
}
|
||||
/**
|
||||
* @return Returns the type.
|
||||
*/
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
/**
|
||||
* @param type The type to set.
|
||||
*/
|
||||
public void setType( String type )
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
/**
|
||||
* @return Returns the version.
|
||||
*/
|
||||
public String getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
/**
|
||||
* @param version The version to set.
|
||||
*/
|
||||
public void setVersion( String version )
|
||||
{
|
||||
this.version = version;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package org.apache.maven.converter.tmp;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Project
|
||||
{
|
||||
private String groupId;
|
||||
private String artifactId;
|
||||
private String version;
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* @return Returns the artifactId.
|
||||
*/
|
||||
public String getArtifactId()
|
||||
{
|
||||
return artifactId;
|
||||
}
|
||||
/**
|
||||
* @param artifactId The artifactId to set.
|
||||
*/
|
||||
public void setArtifactId( String artifactId )
|
||||
{
|
||||
this.artifactId = artifactId;
|
||||
}
|
||||
/**
|
||||
* @return Returns the groupId.
|
||||
*/
|
||||
public String getGroupId()
|
||||
{
|
||||
return groupId;
|
||||
}
|
||||
/**
|
||||
* @param groupId The groupId to set.
|
||||
*/
|
||||
public void setGroupId( String groupId )
|
||||
{
|
||||
this.groupId = groupId;
|
||||
}
|
||||
/**
|
||||
* @return Returns the type.
|
||||
*/
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
/**
|
||||
* @param type The type to set.
|
||||
*/
|
||||
public void setType( String type )
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
/**
|
||||
* @return Returns the version.
|
||||
*/
|
||||
public String getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
/**
|
||||
* @param version The version to set.
|
||||
*/
|
||||
public void setVersion( String version )
|
||||
{
|
||||
this.version = version;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package org.apache.maven.converter;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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 java.io.File;
|
||||
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ReaperTest
|
||||
extends PlexusTestCase
|
||||
{
|
||||
public void testReaper()
|
||||
throws Exception
|
||||
{
|
||||
RepoReaper reaper = new RepoReaper();
|
||||
/*
|
||||
File inbase = new File( System.getProperty( "user.home" ), ".maven/repository" );
|
||||
|
||||
File outbase = new File( getTestFile( "target/outrepo" ) );
|
||||
*/
|
||||
File inbase = new File( "ibiblio" );
|
||||
|
||||
File outbase = new File( "maven" );
|
||||
|
||||
FileUtils.deleteDirectory( outbase );
|
||||
|
||||
reaper.work( inbase, outbase );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue