o Fixed a configuration issue for the DefaultRepositoryLayout in components.xml...it needed a requirement on the ArtifactHandlerManager.

o Fixed a formatting issue for the layout in DefaultRepositoryLayout relating to groupId's.
o Revamped the repoclean tool to use an Artifact-centric approach to converting, cleaning, and reporting on repositories.
o Added the ability for repoclean to report on the health of an existing v3 or v4 repository, using a DefaultArtifactDiscoverer (Default* being the prefix given to the new repo layout going forward) and a V4PomRewriter implementation.
o Tested repoclean by converting my local m1 repository to a m2 repository.


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163669 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-03-23 04:53:30 +00:00
parent 5b29c8a7dd
commit 80880d071e
52 changed files with 1489 additions and 6948 deletions

View File

@ -20,12 +20,14 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.StringUtils;
/**
* @author jdcasey
*/
public abstract class AbstractArtifactRepositoryLayout
extends AbstractLogEnabled
implements ArtifactRepositoryLayout
{

View File

@ -25,7 +25,7 @@ public class DefaultRepositoryLayout
protected String layoutPattern()
{
return "${groupId}/${artifactId}/${version}/${artifactId}-${version}-${classifier}.${extension}";
return "${groupPath}/${artifactId}/${version}/${artifactId}-${version}-${classifier}.${extension}";
}
protected String groupIdAsPath( String groupId )

View File

@ -71,6 +71,11 @@
<role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
<role-hint>default</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>
<component>

View File

@ -1,10 +1,15 @@
#!/bin/sh
echo ""
echo "*******************"
echo "* NOTE: Usage for this script is: 'sh ./install.sh /path/to/install/target /path/to/local/repo'"
echo "*******************"
echo ""
if [ $# == 0 ]; then
echo ""
echo "*******************"
echo "* Usage: 'sh ./install.sh /path/to/install/target /path/to/local/repo'"
echo "*******************"
echo ""
exit 0
fi
(
# First, ensure that the repoclean library has been built.
@ -26,20 +31,25 @@ ret=$?; if [ $ret != 0 ]; then exit $ret; fi
echo "-----------------------------------------------------------------------"
echo ""
mkdir -p $1/lib && \
mkdir -p $1/lib
echo "Copying application libraries..."
echo ""
cp target/repoclean-1.0-SNAPSHOT.jar $1/lib && \
cp $2/plexus/jars/plexus-container-default-1.0-alpha-2-SNAPSHOT.jar $1/lib && \
cp $2/plexus/jars/plexus-utils-1.0-alpha-2-SNAPSHOT.jar $1/lib && \
cp $2/classworlds/jars/classworlds-1.1-alpha-1.jar $1/lib && \
cp -f target/repoclean-1.0-SNAPSHOT.jar $1/lib
cp -f $2/plexus/jars/plexus-container-default-1.0-alpha-2-SNAPSHOT.jar $1/lib
cp -f $2/plexus/jars/plexus-utils-1.0-alpha-2-SNAPSHOT.jar $1/lib
cp -f $2/classworlds/jars/classworlds-1.1-alpha-1.jar $1/lib
cp -f $2/maven/jars/maven-artifact-2.0-SNAPSHOT.jar $1/lib
cp -f $2/maven/jars/maven-model-2.0-SNAPSHOT.jar $1/lib
cp -f $2/maven/jars/wagon-provider-api-1.0-alpha-2-SNAPSHOT.jar $1/lib
cp -f $2/maven/jars/wagon-file-1.0-alpha-2-SNAPSHOT.jar $1/lib
cp -f $2/maven/jars/wagon-http-lightweight-1.0-alpha-2-SNAPSHOT.jar $1/lib
echo "Copying startup script, and changing its permissions to '+x'..."
echo ""
cp src/main/bash/repoclean.sh $1 && \
cp -f src/main/bash/repoclean.sh $1
chmod +x $1/repoclean.sh
ret=$?; if [ $ret != 0 ]; then exit $ret; fi

View File

@ -24,6 +24,18 @@
<version>1.1-alpha-1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

View File

@ -4,5 +4,10 @@ CP=./lib/repoclean-1.0-SNAPSHOT.jar
CP=$CP:./lib/plexus-container-default-1.0-alpha-2-SNAPSHOT.jar
CP=$CP:./lib/plexus-utils-1.0-alpha-2-SNAPSHOT.jar
CP=$CP:./lib/classworlds-1.1-alpha-1.jar
CP=$CP:./lib/maven-artifact-2.0-SNAPSHOT.jar
CP=$CP:./lib/maven-model-2.0-SNAPSHOT.jar
CP=$CP:./lib/wagon-provider-api-1.0-alpha-2-SNAPSHOT.jar
CP=$CP:./lib/wagon-file-1.0-alpha-2-SNAPSHOT.jar
CP=$CP:./lib/wagon-http-lightweight-1.0-alpha-2-SNAPSHOT.jar
java -classpath ${CP} org.apache.maven.tools.repoclean.Main $* | tee repoclean-log.txt

View File

@ -1,357 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class Build.
*
* @version $Revision$ $Date$
*/
public class Build
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field sourceDirectory
*/
private String sourceDirectory;
/**
* Field scriptSourceDirectory
*/
private String scriptSourceDirectory;
/**
* Field testSourceDirectory
*/
private String testSourceDirectory;
/**
* Field resources
*/
private java.util.List resources;
/**
* Field testResources
*/
private java.util.List testResources;
/**
* Field directory
*/
private String directory;
/**
* Field outputDirectory
*/
private String outputDirectory;
/**
* Field finalName
*/
private String finalName;
/**
* Field testOutputDirectory
*/
private String testOutputDirectory;
/**
* Field plugins
*/
private java.util.List plugins;
/**
* Field pluginManagement
*/
private PluginManagement pluginManagement;
//-----------/
//- Methods -/
//-----------/
/**
* Method addPlugin
*
* @param plugin
*/
public void addPlugin( Plugin plugin )
{
getPlugins().add( plugin );
} //-- void addPlugin(Plugin)
/**
* Method addResource
*
* @param resource
*/
public void addResource( Resource resource )
{
getResources().add( resource );
} //-- void addResource(Resource)
/**
* Method addTestResource
*
* @param resource
*/
public void addTestResource( Resource resource )
{
getTestResources().add( resource );
} //-- void addTestResource(Resource)
/**
* Method getDirectory
*/
public String getDirectory()
{
return this.directory;
} //-- String getDirectory()
/**
* Method getFinalName
*/
public String getFinalName()
{
return this.finalName;
} //-- String getFinalName()
/**
* Method getOutputDirectory
*/
public String getOutputDirectory()
{
return this.outputDirectory;
} //-- String getOutputDirectory()
/**
* Method getPluginManagement
*/
public PluginManagement getPluginManagement()
{
return this.pluginManagement;
} //-- PluginManagement getPluginManagement()
/**
* Method getPlugins
*/
public java.util.List getPlugins()
{
if ( this.plugins == null )
{
this.plugins = new java.util.ArrayList();
}
return this.plugins;
} //-- java.util.List getPlugins()
/**
* Method getResources
*/
public java.util.List getResources()
{
if ( this.resources == null )
{
this.resources = new java.util.ArrayList();
}
return this.resources;
} //-- java.util.List getResources()
/**
* Method getScriptSourceDirectory
*/
public String getScriptSourceDirectory()
{
return this.scriptSourceDirectory;
} //-- String getScriptSourceDirectory()
/**
* Method getSourceDirectory
*/
public String getSourceDirectory()
{
return this.sourceDirectory;
} //-- String getSourceDirectory()
/**
* Method getTestOutputDirectory
*/
public String getTestOutputDirectory()
{
return this.testOutputDirectory;
} //-- String getTestOutputDirectory()
/**
* Method getTestResources
*/
public java.util.List getTestResources()
{
if ( this.testResources == null )
{
this.testResources = new java.util.ArrayList();
}
return this.testResources;
} //-- java.util.List getTestResources()
/**
* Method getTestSourceDirectory
*/
public String getTestSourceDirectory()
{
return this.testSourceDirectory;
} //-- String getTestSourceDirectory()
/**
* Method removePlugin
*
* @param plugin
*/
public void removePlugin( Plugin plugin )
{
getPlugins().remove( plugin );
} //-- void removePlugin(Plugin)
/**
* Method removeResource
*
* @param resource
*/
public void removeResource( Resource resource )
{
getResources().remove( resource );
} //-- void removeResource(Resource)
/**
* Method removeTestResource
*
* @param resource
*/
public void removeTestResource( Resource resource )
{
getTestResources().remove( resource );
} //-- void removeTestResource(Resource)
/**
* Method setDirectory
*
* @param directory
*/
public void setDirectory( String directory )
{
this.directory = directory;
} //-- void setDirectory(String)
/**
* Method setFinalName
*
* @param finalName
*/
public void setFinalName( String finalName )
{
this.finalName = finalName;
} //-- void setFinalName(String)
/**
* Method setOutputDirectory
*
* @param outputDirectory
*/
public void setOutputDirectory( String outputDirectory )
{
this.outputDirectory = outputDirectory;
} //-- void setOutputDirectory(String)
/**
* Method setPluginManagement
*
* @param pluginManagement
*/
public void setPluginManagement( PluginManagement pluginManagement )
{
this.pluginManagement = pluginManagement;
} //-- void setPluginManagement(PluginManagement)
/**
* Method setPlugins
*
* @param plugins
*/
public void setPlugins( java.util.List plugins )
{
this.plugins = plugins;
} //-- void setPlugins(java.util.List)
/**
* Method setResources
*
* @param resources
*/
public void setResources( java.util.List resources )
{
this.resources = resources;
} //-- void setResources(java.util.List)
/**
* Method setScriptSourceDirectory
*
* @param scriptSourceDirectory
*/
public void setScriptSourceDirectory( String scriptSourceDirectory )
{
this.scriptSourceDirectory = scriptSourceDirectory;
} //-- void setScriptSourceDirectory(String)
/**
* Method setSourceDirectory
*
* @param sourceDirectory
*/
public void setSourceDirectory( String sourceDirectory )
{
this.sourceDirectory = sourceDirectory;
} //-- void setSourceDirectory(String)
/**
* Method setTestOutputDirectory
*
* @param testOutputDirectory
*/
public void setTestOutputDirectory( String testOutputDirectory )
{
this.testOutputDirectory = testOutputDirectory;
} //-- void setTestOutputDirectory(String)
/**
* Method setTestResources
*
* @param testResources
*/
public void setTestResources( java.util.List testResources )
{
this.testResources = testResources;
} //-- void setTestResources(java.util.List)
/**
* Method setTestSourceDirectory
*
* @param testSourceDirectory
*/
public void setTestSourceDirectory( String testSourceDirectory )
{
this.testSourceDirectory = testSourceDirectory;
} //-- void setTestSourceDirectory(String)
}

View File

@ -1,123 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class CiManagement.
*
* @version $Revision$ $Date$
*/
public class CiManagement
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field system
*/
private String system;
/**
* Field url
*/
private String url;
/**
* Field notifiers
*/
private java.util.List notifiers;
//-----------/
//- Methods -/
//-----------/
/**
* Method addNotifier
*
* @param notifier
*/
public void addNotifier( Notifier notifier )
{
getNotifiers().add( notifier );
} //-- void addNotifier(Notifier)
/**
* Method getNotifiers
*/
public java.util.List getNotifiers()
{
if ( this.notifiers == null )
{
this.notifiers = new java.util.ArrayList();
}
return this.notifiers;
} //-- java.util.List getNotifiers()
/**
* Method getSystem
*/
public String getSystem()
{
return this.system;
} //-- String getSystem()
/**
* Method getUrl
*/
public String getUrl()
{
return this.url;
} //-- String getUrl()
/**
* Method removeNotifier
*
* @param notifier
*/
public void removeNotifier( Notifier notifier )
{
getNotifiers().remove( notifier );
} //-- void removeNotifier(Notifier)
/**
* Method setNotifiers
*
* @param notifiers
*/
public void setNotifiers( java.util.List notifiers )
{
this.notifiers = notifiers;
} //-- void setNotifiers(java.util.List)
/**
* Method setSystem
*
* @param system
*/
public void setSystem( String system )
{
this.system = system;
} //-- void setSystem(String)
/**
* Method setUrl
*
* @param url
*/
public void setUrl( String url )
{
this.url = url;
} //-- void setUrl(String)
}

View File

@ -1,192 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class Contributor.
*
* @version $Revision$ $Date$
*/
public class Contributor
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field name
*/
private String name;
/**
* Field email
*/
private String email;
/**
* Field url
*/
private String url;
/**
* Field organization
*/
private String organization;
/**
* Field roles
*/
private java.util.List roles;
/**
* Field timezone
*/
private String timezone;
//-----------/
//- Methods -/
//-----------/
/**
* Method addRole
*
* @param string
*/
public void addRole( String string )
{
getRoles().add( string );
} //-- void addRole(String)
/**
* Method getEmail
*/
public String getEmail()
{
return this.email;
} //-- String getEmail()
/**
* Method getName
*/
public String getName()
{
return this.name;
} //-- String getName()
/**
* Method getOrganization
*/
public String getOrganization()
{
return this.organization;
} //-- String getOrganization()
/**
* Method getRoles
*/
public java.util.List getRoles()
{
if ( this.roles == null )
{
this.roles = new java.util.ArrayList();
}
return this.roles;
} //-- java.util.List getRoles()
/**
* Method getTimezone
*/
public String getTimezone()
{
return this.timezone;
} //-- String getTimezone()
/**
* Method getUrl
*/
public String getUrl()
{
return this.url;
} //-- String getUrl()
/**
* Method removeRole
*
* @param string
*/
public void removeRole( String string )
{
getRoles().remove( string );
} //-- void removeRole(String)
/**
* Method setEmail
*
* @param email
*/
public void setEmail( String email )
{
this.email = email;
} //-- void setEmail(String)
/**
* Method setName
*
* @param name
*/
public void setName( String name )
{
this.name = name;
} //-- void setName(String)
/**
* Method setOrganization
*
* @param organization
*/
public void setOrganization( String organization )
{
this.organization = organization;
} //-- void setOrganization(String)
/**
* Method setRoles
*
* @param roles
*/
public void setRoles( java.util.List roles )
{
this.roles = roles;
} //-- void setRoles(java.util.List)
/**
* Method setTimezone
*
* @param timezone
*/
public void setTimezone( String timezone )
{
this.timezone = timezone;
} //-- void setTimezone(String)
/**
* Method setUrl
*
* @param url
*/
public void setUrl( String url )
{
this.url = url;
} //-- void setUrl(String)
}

View File

@ -1,158 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class Dependency.
*
* @version $Revision$ $Date$
*/
public class Dependency
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field groupId
*/
private String groupId;
/**
* Field artifactId
*/
private String artifactId;
/**
* Field version
*/
private String version;
/**
* Field type
*/
private String type = "jar";
/**
* Field scope
*/
private String scope = "compile";
//-----------/
//- Methods -/
//-----------/
/**
* Method getArtifactId
*/
public String getArtifactId()
{
return this.artifactId;
} //-- String getArtifactId()
/**
* Method getGroupId
*/
public String getGroupId()
{
return this.groupId;
} //-- String getGroupId()
/**
* Method getScope
*/
public String getScope()
{
return this.scope;
} //-- String getScope()
/**
* Method getType
*/
public String getType()
{
return this.type;
} //-- String getType()
/**
* Method getVersion
*/
public String getVersion()
{
return this.version;
} //-- String getVersion()
/**
* Method setArtifactId
*
* @param artifactId
*/
public void setArtifactId( String artifactId )
{
this.artifactId = artifactId;
} //-- void setArtifactId(String)
/**
* Method setGroupId
*
* @param groupId
*/
public void setGroupId( String groupId )
{
this.groupId = groupId;
} //-- void setGroupId(String)
/**
* Method setScope
*
* @param scope
*/
public void setScope( String scope )
{
this.scope = scope;
} //-- void setScope(String)
/**
* Method setType
*
* @param type
*/
public void setType( String type )
{
this.type = type;
} //-- void setType(String)
/**
* Method setVersion
*
* @param version
*/
public void setVersion( String version )
{
this.version = version;
} //-- void setVersion(String)
public String toString()
{
return groupId + "/" + type + "s:" + artifactId + "-" + version;
}
public String getId()
{
return groupId + ":" + artifactId + ":" + type + ":" + version;
}
public String getManagementKey()
{
return groupId + ":" + artifactId + ":" + type;
}
}

View File

@ -1,77 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class DependencyManagement.
*
* @version $Revision$ $Date$
*/
public class DependencyManagement
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field dependencies
*/
private java.util.List dependencies;
//-----------/
//- Methods -/
//-----------/
/**
* Method addDependency
*
* @param dependency
*/
public void addDependency( Dependency dependency )
{
getDependencies().add( dependency );
} //-- void addDependency(Dependency)
/**
* Method getDependencies
*/
public java.util.List getDependencies()
{
if ( this.dependencies == null )
{
this.dependencies = new java.util.ArrayList();
}
return this.dependencies;
} //-- java.util.List getDependencies()
/**
* Method removeDependency
*
* @param dependency
*/
public void removeDependency( Dependency dependency )
{
getDependencies().remove( dependency );
} //-- void removeDependency(Dependency)
/**
* Method setDependencies
*
* @param dependencies
*/
public void setDependencies( java.util.List dependencies )
{
this.dependencies = dependencies;
} //-- void setDependencies(java.util.List)
}

View File

@ -1,53 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class Developer.
*
* @version $Revision$ $Date$
*/
public class Developer
extends Contributor
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field id
*/
private String id;
//-----------/
//- Methods -/
//-----------/
/**
* Method getId
*/
public String getId()
{
return this.id;
} //-- String getId()
/**
* Method setId
*
* @param id
*/
public void setId( String id )
{
this.id = id;
} //-- void setId(String)
}

View File

@ -1,75 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class DistributionManagement.
*
* @version $Revision$ $Date$
*/
public class DistributionManagement
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field repository
*/
private Repository repository;
/**
* Field site
*/
private Site site;
//-----------/
//- Methods -/
//-----------/
/**
* Method getRepository
*/
public Repository getRepository()
{
return this.repository;
} //-- Repository getRepository()
/**
* Method getSite
*/
public Site getSite()
{
return this.site;
} //-- Site getSite()
/**
* Method setRepository
*
* @param repository
*/
public void setRepository( Repository repository )
{
this.repository = repository;
} //-- void setRepository(Repository)
/**
* Method setSite
*
* @param site
*/
public void setSite( Site site )
{
this.site = site;
} //-- void setSite(Site)
}

View File

@ -1,53 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class FileSet.
*
* @version $Revision$ $Date$
*/
public class FileSet
extends PatternSet
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field directory
*/
private String directory;
//-----------/
//- Methods -/
//-----------/
/**
* Method getDirectory
*/
public String getDirectory()
{
return this.directory;
} //-- String getDirectory()
/**
* Method setDirectory
*
* @param directory
*/
public void setDirectory( String directory )
{
this.directory = directory;
} //-- void setDirectory(String)
}

View File

@ -1,114 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class Goal.
*
* @version $Revision$ $Date$
*/
public class Goal
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field id
*/
private String id;
/**
* Field disabled
*/
private Boolean disabled;
/**
* Field configuration
*/
private java.util.Properties configuration;
//-----------/
//- Methods -/
//-----------/
/**
* Method addConfiguration
*
* @param key
* @param value
*/
public void addConfiguration( String key, String value )
{
getConfiguration().put( key, value );
} //-- void addConfiguration(String, String)
/**
* Method getConfiguration
*/
public java.util.Properties getConfiguration()
{
if ( this.configuration == null )
{
this.configuration = new java.util.Properties();
}
return this.configuration;
} //-- java.util.Properties getConfiguration()
/**
* Method getId
*/
public String getId()
{
return this.id;
} //-- String getId()
/**
* Method isDisabled
*/
public Boolean isDisabled()
{
return this.disabled;
} //-- Boolean isDisabled()
/**
* Method setConfiguration
*
* @param configuration
*/
public void setConfiguration( java.util.Properties configuration )
{
this.configuration = configuration;
} //-- void setConfiguration(java.util.Properties)
/**
* Method setDisabled
*
* @param disabled
*/
public void setDisabled( Boolean disabled )
{
this.disabled = disabled;
} //-- void setDisabled(Boolean)
/**
* Method setId
*
* @param id
*/
public void setId( String id )
{
this.id = id;
} //-- void setId(String)
}

View File

@ -1,75 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class IssueManagement.
*
* @version $Revision$ $Date$
*/
public class IssueManagement
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field system
*/
private String system;
/**
* Field url
*/
private String url;
//-----------/
//- Methods -/
//-----------/
/**
* Method getSystem
*/
public String getSystem()
{
return this.system;
} //-- String getSystem()
/**
* Method getUrl
*/
public String getUrl()
{
return this.url;
} //-- String getUrl()
/**
* Method setSystem
*
* @param system
*/
public void setSystem( String system )
{
this.system = system;
} //-- void setSystem(String)
/**
* Method setUrl
*
* @param url
*/
public void setUrl( String url )
{
this.url = url;
} //-- void setUrl(String)
}

View File

@ -1,98 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class License.
*
* @version $Revision$ $Date$
*/
public class License
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field name
*/
private String name;
/**
* Field url
*/
private String url;
/**
* Field comments
*/
private String comments;
//-----------/
//- Methods -/
//-----------/
/**
* Method getComments
*/
public String getComments()
{
return this.comments;
} //-- String getComments()
/**
* Method getName
*/
public String getName()
{
return this.name;
} //-- String getName()
/**
* Method getUrl
*/
public String getUrl()
{
return this.url;
} //-- String getUrl()
/**
* Method setComments
*
* @param comments
*/
public void setComments( String comments )
{
this.comments = comments;
} //-- void setComments(String)
/**
* Method setName
*
* @param name
*/
public void setName( String name )
{
this.name = name;
} //-- void setName(String)
/**
* Method setUrl
*
* @param url
*/
public void setUrl( String url )
{
this.url = url;
} //-- void setUrl(String)
}

View File

@ -1,192 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class MailingList.
*
* @version $Revision$ $Date$
*/
public class MailingList
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field name
*/
private String name;
/**
* Field subscribe
*/
private String subscribe;
/**
* Field unsubscribe
*/
private String unsubscribe;
/**
* Field post
*/
private String post;
/**
* Field archive
*/
private String archive;
/**
* Field otherArchives
*/
private java.util.List otherArchives;
//-----------/
//- Methods -/
//-----------/
/**
* Method addOtherArchive
*
* @param string
*/
public void addOtherArchive( String string )
{
getOtherArchives().add( string );
} //-- void addOtherArchive(String)
/**
* Method getArchive
*/
public String getArchive()
{
return this.archive;
} //-- String getArchive()
/**
* Method getName
*/
public String getName()
{
return this.name;
} //-- String getName()
/**
* Method getOtherArchives
*/
public java.util.List getOtherArchives()
{
if ( this.otherArchives == null )
{
this.otherArchives = new java.util.ArrayList();
}
return this.otherArchives;
} //-- java.util.List getOtherArchives()
/**
* Method getPost
*/
public String getPost()
{
return this.post;
} //-- String getPost()
/**
* Method getSubscribe
*/
public String getSubscribe()
{
return this.subscribe;
} //-- String getSubscribe()
/**
* Method getUnsubscribe
*/
public String getUnsubscribe()
{
return this.unsubscribe;
} //-- String getUnsubscribe()
/**
* Method removeOtherArchive
*
* @param string
*/
public void removeOtherArchive( String string )
{
getOtherArchives().remove( string );
} //-- void removeOtherArchive(String)
/**
* Method setArchive
*
* @param archive
*/
public void setArchive( String archive )
{
this.archive = archive;
} //-- void setArchive(String)
/**
* Method setName
*
* @param name
*/
public void setName( String name )
{
this.name = name;
} //-- void setName(String)
/**
* Method setOtherArchives
*
* @param otherArchives
*/
public void setOtherArchives( java.util.List otherArchives )
{
this.otherArchives = otherArchives;
} //-- void setOtherArchives(java.util.List)
/**
* Method setPost
*
* @param post
*/
public void setPost( String post )
{
this.post = post;
} //-- void setPost(String)
/**
* Method setSubscribe
*
* @param subscribe
*/
public void setSubscribe( String subscribe )
{
this.subscribe = subscribe;
} //-- void setSubscribe(String)
/**
* Method setUnsubscribe
*
* @param unsubscribe
*/
public void setUnsubscribe( String unsubscribe )
{
this.unsubscribe = unsubscribe;
} //-- void setUnsubscribe(String)
}

View File

@ -1,867 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class Model.
*
* @version $Revision$ $Date$
*/
public class Model
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field extend
*/
private String extend;
/**
* Field parent
*/
private Parent parent;
/**
* Field modelVersion
*/
private String modelVersion;
/**
* Field groupId
*/
private String groupId;
/**
* Field artifactId
*/
private String artifactId;
/**
* Field packaging
*/
private String packaging = "jar";
/**
* Field modules
*/
private java.util.List modules;
/**
* Field name
*/
private String name;
/**
* Field version
*/
private String version;
/**
* Field description
*/
private String description;
/**
* Field url
*/
private String url;
/**
* Field issueManagement
*/
private IssueManagement issueManagement;
/**
* Field ciManagement
*/
private CiManagement ciManagement;
/**
* Field inceptionYear
*/
private String inceptionYear;
/**
* Field repositories
*/
private java.util.List repositories;
/**
* This may be removed or relocated in the near future. It is
* undecided whether plugins really need a remote repository
* set of their own.
*/
private java.util.List pluginRepositories;
/**
* Field mailingLists
*/
private java.util.List mailingLists;
/**
* Field developers
*/
private java.util.List developers;
/**
* Field contributors
*/
private java.util.List contributors;
/**
* These should ultimately only be compile time dependencies
* when transitive dependencies come into play.
*/
private java.util.List dependencies;
/**
* Field licenses
*/
private java.util.List licenses;
/**
* Field reports
*/
private Reports reports;
/**
* Field scm
*/
private Scm scm;
/**
* Field build
*/
private Build build;
/**
* Field organization
*/
private Organization organization;
/**
* Field distributionManagement
*/
private DistributionManagement distributionManagement;
/**
* Field dependencyManagement
*/
private DependencyManagement dependencyManagement;
//-----------/
//- Methods -/
//-----------/
/**
* Method addContributor
*
* @param contributor
*/
public void addContributor( Contributor contributor )
{
getContributors().add( contributor );
} //-- void addContributor(Contributor)
/**
* Method addDependency
*
* @param dependency
*/
public void addDependency( Dependency dependency )
{
getDependencies().add( dependency );
} //-- void addDependency(Dependency)
/**
* Method addDeveloper
*
* @param developer
*/
public void addDeveloper( Developer developer )
{
getDevelopers().add( developer );
} //-- void addDeveloper(Developer)
/**
* Method addLicense
*
* @param license
*/
public void addLicense( License license )
{
getLicenses().add( license );
} //-- void addLicense(License)
/**
* Method addMailingList
*
* @param mailingList
*/
public void addMailingList( MailingList mailingList )
{
getMailingLists().add( mailingList );
} //-- void addMailingList(MailingList)
/**
* Method addModule
*
* @param string
*/
public void addModule( String string )
{
getModules().add( string );
} //-- void addModule(String)
/**
* Method addPluginRepository
*
* @param repository
*/
public void addPluginRepository( Repository repository )
{
getPluginRepositories().add( repository );
} //-- void addPluginRepository(Repository)
/**
* Method addRepository
*
* @param repository
*/
public void addRepository( Repository repository )
{
getRepositories().add( repository );
} //-- void addRepository(Repository)
/**
* Method getArtifactId
*/
public String getArtifactId()
{
return this.artifactId;
} //-- String getArtifactId()
/**
* Method getBuild
*/
public Build getBuild()
{
return this.build;
} //-- Build getBuild()
/**
* Method getCiManagement
*/
public CiManagement getCiManagement()
{
return this.ciManagement;
} //-- CiManagement getCiManagement()
/**
* Method getContributors
*/
public java.util.List getContributors()
{
if ( this.contributors == null )
{
this.contributors = new java.util.ArrayList();
}
return this.contributors;
} //-- java.util.List getContributors()
/**
* Method getDependencies
*/
public java.util.List getDependencies()
{
if ( this.dependencies == null )
{
this.dependencies = new java.util.ArrayList();
}
return this.dependencies;
} //-- java.util.List getDependencies()
/**
* Method getDependencyManagement
*/
public DependencyManagement getDependencyManagement()
{
return this.dependencyManagement;
} //-- DependencyManagement getDependencyManagement()
/**
* Method getDescription
*/
public String getDescription()
{
return this.description;
} //-- String getDescription()
/**
* Method getDevelopers
*/
public java.util.List getDevelopers()
{
if ( this.developers == null )
{
this.developers = new java.util.ArrayList();
}
return this.developers;
} //-- java.util.List getDevelopers()
/**
* Method getDistributionManagement
*/
public DistributionManagement getDistributionManagement()
{
return this.distributionManagement;
} //-- DistributionManagement getDistributionManagement()
/**
* Method getExtend
*/
public String getExtend()
{
return this.extend;
} //-- String getExtend()
/**
* Method getGroupId
*/
public String getGroupId()
{
return this.groupId;
} //-- String getGroupId()
/**
* Method getInceptionYear
*/
public String getInceptionYear()
{
return this.inceptionYear;
} //-- String getInceptionYear()
/**
* Method getIssueManagement
*/
public IssueManagement getIssueManagement()
{
return this.issueManagement;
} //-- IssueManagement getIssueManagement()
/**
* Method getLicenses
*/
public java.util.List getLicenses()
{
if ( this.licenses == null )
{
this.licenses = new java.util.ArrayList();
}
return this.licenses;
} //-- java.util.List getLicenses()
/**
* Method getMailingLists
*/
public java.util.List getMailingLists()
{
if ( this.mailingLists == null )
{
this.mailingLists = new java.util.ArrayList();
}
return this.mailingLists;
} //-- java.util.List getMailingLists()
/**
* Method getModelVersion
*/
public String getModelVersion()
{
return this.modelVersion;
} //-- String getModelVersion()
/**
* Method getModules
*/
public java.util.List getModules()
{
if ( this.modules == null )
{
this.modules = new java.util.ArrayList();
}
return this.modules;
} //-- java.util.List getModules()
/**
* Method getName
*/
public String getName()
{
return this.name;
} //-- String getName()
/**
* Method getOrganization
*/
public Organization getOrganization()
{
return this.organization;
} //-- Organization getOrganization()
/**
* Method getPackaging
*/
public String getPackaging()
{
return this.packaging;
} //-- String getPackaging()
/**
* Method getParent
*/
public Parent getParent()
{
return this.parent;
} //-- Parent getParent()
/**
* Method getPluginRepositories
*/
public java.util.List getPluginRepositories()
{
if ( this.pluginRepositories == null )
{
this.pluginRepositories = new java.util.ArrayList();
}
return this.pluginRepositories;
} //-- java.util.List getPluginRepositories()
/**
* Method getReports
*/
public Reports getReports()
{
return this.reports;
} //-- Reports getReports()
/**
* Method getRepositories
*/
public java.util.List getRepositories()
{
if ( this.repositories == null )
{
this.repositories = new java.util.ArrayList();
}
return this.repositories;
} //-- java.util.List getRepositories()
/**
* Method getScm
*/
public Scm getScm()
{
return this.scm;
} //-- Scm getScm()
/**
* Method getUrl
*/
public String getUrl()
{
return this.url;
} //-- String getUrl()
/**
* Method getVersion
*/
public String getVersion()
{
return this.version;
} //-- String getVersion()
/**
* Method removeContributor
*
* @param contributor
*/
public void removeContributor( Contributor contributor )
{
getContributors().remove( contributor );
} //-- void removeContributor(Contributor)
/**
* Method removeDependency
*
* @param dependency
*/
public void removeDependency( Dependency dependency )
{
getDependencies().remove( dependency );
} //-- void removeDependency(Dependency)
/**
* Method removeDeveloper
*
* @param developer
*/
public void removeDeveloper( Developer developer )
{
getDevelopers().remove( developer );
} //-- void removeDeveloper(Developer)
/**
* Method removeLicense
*
* @param license
*/
public void removeLicense( License license )
{
getLicenses().remove( license );
} //-- void removeLicense(License)
/**
* Method removeMailingList
*
* @param mailingList
*/
public void removeMailingList( MailingList mailingList )
{
getMailingLists().remove( mailingList );
} //-- void removeMailingList(MailingList)
/**
* Method removeModule
*
* @param string
*/
public void removeModule( String string )
{
getModules().remove( string );
} //-- void removeModule(String)
/**
* Method removePluginRepository
*
* @param repository
*/
public void removePluginRepository( Repository repository )
{
getPluginRepositories().remove( repository );
} //-- void removePluginRepository(Repository)
/**
* Method removeRepository
*
* @param repository
*/
public void removeRepository( Repository repository )
{
getRepositories().remove( repository );
} //-- void removeRepository(Repository)
/**
* Method setArtifactId
*
* @param artifactId
*/
public void setArtifactId( String artifactId )
{
this.artifactId = artifactId;
} //-- void setArtifactId(String)
/**
* Method setBuild
*
* @param build
*/
public void setBuild( Build build )
{
this.build = build;
} //-- void setBuild(Build)
/**
* Method setCiManagement
*
* @param ciManagement
*/
public void setCiManagement( CiManagement ciManagement )
{
this.ciManagement = ciManagement;
} //-- void setCiManagement(CiManagement)
/**
* Method setContributors
*
* @param contributors
*/
public void setContributors( java.util.List contributors )
{
this.contributors = contributors;
} //-- void setContributors(java.util.List)
/**
* Method setDependencies
*
* @param dependencies
*/
public void setDependencies( java.util.List dependencies )
{
this.dependencies = dependencies;
} //-- void setDependencies(java.util.List)
/**
* Method setDependencyManagement
*
* @param dependencyManagement
*/
public void setDependencyManagement( DependencyManagement dependencyManagement )
{
this.dependencyManagement = dependencyManagement;
} //-- void setDependencyManagement(DependencyManagement)
/**
* Method setDescription
*
* @param description
*/
public void setDescription( String description )
{
this.description = description;
} //-- void setDescription(String)
/**
* Method setDevelopers
*
* @param developers
*/
public void setDevelopers( java.util.List developers )
{
this.developers = developers;
} //-- void setDevelopers(java.util.List)
/**
* Method setDistributionManagement
*
* @param distributionManagement
*/
public void setDistributionManagement( DistributionManagement distributionManagement )
{
this.distributionManagement = distributionManagement;
} //-- void setDistributionManagement(DistributionManagement)
/**
* Method setExtend
*
* @param extend
*/
public void setExtend( String extend )
{
this.extend = extend;
} //-- void setExtend(String)
/**
* Method setGroupId
*
* @param groupId
*/
public void setGroupId( String groupId )
{
this.groupId = groupId;
} //-- void setGroupId(String)
/**
* Method setInceptionYear
*
* @param inceptionYear
*/
public void setInceptionYear( String inceptionYear )
{
this.inceptionYear = inceptionYear;
} //-- void setInceptionYear(String)
/**
* Method setIssueManagement
*
* @param issueManagement
*/
public void setIssueManagement( IssueManagement issueManagement )
{
this.issueManagement = issueManagement;
} //-- void setIssueManagement(IssueManagement)
/**
* Method setLicenses
*
* @param licenses
*/
public void setLicenses( java.util.List licenses )
{
this.licenses = licenses;
} //-- void setLicenses(java.util.List)
/**
* Method setMailingLists
*
* @param mailingLists
*/
public void setMailingLists( java.util.List mailingLists )
{
this.mailingLists = mailingLists;
} //-- void setMailingLists(java.util.List)
/**
* Method setModelVersion
*
* @param modelVersion
*/
public void setModelVersion( String modelVersion )
{
this.modelVersion = modelVersion;
} //-- void setModelVersion(String)
/**
* Method setModules
*
* @param modules
*/
public void setModules( java.util.List modules )
{
this.modules = modules;
} //-- void setModules(java.util.List)
/**
* Method setName
*
* @param name
*/
public void setName( String name )
{
this.name = name;
} //-- void setName(String)
/**
* Method setOrganization
*
* @param organization
*/
public void setOrganization( Organization organization )
{
this.organization = organization;
} //-- void setOrganization(Organization)
/**
* Method setPackaging
*
* @param packaging
*/
public void setPackaging( String packaging )
{
this.packaging = packaging;
} //-- void setPackaging(String)
/**
* Method setParent
*
* @param parent
*/
public void setParent( Parent parent )
{
this.parent = parent;
} //-- void setParent(Parent)
/**
* Method setPluginRepositories
*
* @param pluginRepositories
*/
public void setPluginRepositories( java.util.List pluginRepositories )
{
this.pluginRepositories = pluginRepositories;
} //-- void setPluginRepositories(java.util.List)
/**
* Method setReports
*
* @param reports
*/
public void setReports( Reports reports )
{
this.reports = reports;
} //-- void setReports(Reports)
/**
* Method setRepositories
*
* @param repositories
*/
public void setRepositories( java.util.List repositories )
{
this.repositories = repositories;
} //-- void setRepositories(java.util.List)
/**
* Method setScm
*
* @param scm
*/
public void setScm( Scm scm )
{
this.scm = scm;
} //-- void setScm(Scm)
/**
* Method setUrl
*
* @param url
*/
public void setUrl( String url )
{
this.url = url;
} //-- void setUrl(String)
/**
* Method setVersion
*
* @param version
*/
public void setVersion( String version )
{
this.version = version;
} //-- void setVersion(String)
public String getId()
{
StringBuffer id = new StringBuffer();
id.append( getGroupId() );
id.append( ":" );
id.append( getArtifactId() );
id.append( ":" );
id.append( getPackaging() );
id.append( ":" );
id.append( getVersion() );
return id.toString();
}
}

View File

@ -1,114 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class Notifier.
*
* @version $Revision$ $Date$
*/
public class Notifier
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field type
*/
private String type = "email";
/**
* Field address
*/
private String address;
/**
* Field configuration
*/
private java.util.Properties configuration;
//-----------/
//- Methods -/
//-----------/
/**
* Method addConfiguration
*
* @param key
* @param value
*/
public void addConfiguration( String key, String value )
{
getConfiguration().put( key, value );
} //-- void addConfiguration(String, String)
/**
* Method getAddress
*/
public String getAddress()
{
return this.address;
} //-- String getAddress()
/**
* Method getConfiguration
*/
public java.util.Properties getConfiguration()
{
if ( this.configuration == null )
{
this.configuration = new java.util.Properties();
}
return this.configuration;
} //-- java.util.Properties getConfiguration()
/**
* Method getType
*/
public String getType()
{
return this.type;
} //-- String getType()
/**
* Method setAddress
*
* @param address
*/
public void setAddress( String address )
{
this.address = address;
} //-- void setAddress(String)
/**
* Method setConfiguration
*
* @param configuration
*/
public void setConfiguration( java.util.Properties configuration )
{
this.configuration = configuration;
} //-- void setConfiguration(java.util.Properties)
/**
* Method setType
*
* @param type
*/
public void setType( String type )
{
this.type = type;
} //-- void setType(String)
}

View File

@ -1,75 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class Organization.
*
* @version $Revision$ $Date$
*/
public class Organization
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field name
*/
private String name;
/**
* Field url
*/
private String url;
//-----------/
//- Methods -/
//-----------/
/**
* Method getName
*/
public String getName()
{
return this.name;
} //-- String getName()
/**
* Method getUrl
*/
public String getUrl()
{
return this.url;
} //-- String getUrl()
/**
* Method setName
*
* @param name
*/
public void setName( String name )
{
this.name = name;
} //-- void setName(String)
/**
* Method setUrl
*
* @param url
*/
public void setUrl( String url )
{
this.url = url;
} //-- void setUrl(String)
}

View File

@ -1,98 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class Parent.
*
* @version $Revision$ $Date$
*/
public class Parent
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field artifactId
*/
private String artifactId;
/**
* Field groupId
*/
private String groupId;
/**
* Field version
*/
private String version;
//-----------/
//- Methods -/
//-----------/
/**
* Method getArtifactId
*/
public String getArtifactId()
{
return this.artifactId;
} //-- String getArtifactId()
/**
* Method getGroupId
*/
public String getGroupId()
{
return this.groupId;
} //-- String getGroupId()
/**
* Method getVersion
*/
public String getVersion()
{
return this.version;
} //-- String getVersion()
/**
* Method setArtifactId
*
* @param artifactId
*/
public void setArtifactId( String artifactId )
{
this.artifactId = artifactId;
} //-- void setArtifactId(String)
/**
* Method setGroupId
*
* @param groupId
*/
public void setGroupId( String groupId )
{
this.groupId = groupId;
} //-- void setGroupId(String)
/**
* Method setVersion
*
* @param version
*/
public void setVersion( String version )
{
this.version = version;
} //-- void setVersion(String)
}

View File

@ -1,106 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
import java.util.ArrayList;
import java.util.List;
/**
* Class PatternSet.
*
* @version $Revision$ $Date$
*/
public class PatternSet
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field includes
*/
private String includes;
/**
* Field excludes
*/
private String excludes;
//-----------/
//- Methods -/
//-----------/
/**
* Method getExcludes
*/
public String getExcludes()
{
return this.excludes;
} //-- String getExcludes()
/**
* Method getIncludes
*/
public String getIncludes()
{
return this.includes;
} //-- String getIncludes()
/**
* Method setExcludes
*
* @param excludes
*/
public void setExcludes( String excludes )
{
this.excludes = excludes;
} //-- void setExcludes(String)
/**
* Method setIncludes
*
* @param includes
*/
public void setIncludes( String includes )
{
this.includes = includes;
} //-- void setIncludes(String)
public List getDefaultExcludes()
{
List defaultExcludes = new ArrayList();
defaultExcludes.add( "**/*~" );
defaultExcludes.add( "**/#*#" );
defaultExcludes.add( "**/.#*" );
defaultExcludes.add( "**/%*%" );
defaultExcludes.add( "**/._*" );
// CVS
defaultExcludes.add( "**/CVS" );
defaultExcludes.add( "**/CVS/**" );
defaultExcludes.add( "**/.cvsignore" );
// SCCS
defaultExcludes.add( "**/SCCS" );
defaultExcludes.add( "**/SCCS/**" );
// Visual SourceSafe
defaultExcludes.add( "**/vssver.scc" );
// Subversion
defaultExcludes.add( "**/.svn" );
defaultExcludes.add( "**/.svn/**" );
// Mac
defaultExcludes.add( "**/.DS_Store" );
return defaultExcludes;
}
}

View File

@ -1,208 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class Plugin.
*
* @version $Revision$ $Date$
*/
public class Plugin
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field groupId
*/
private String groupId = "maven";
/**
* Field artifactId
*/
private String artifactId;
/**
* Field version
*/
private String version;
/**
* Field disabled
*/
private Boolean disabled;
/**
* Field configuration
*/
private java.util.Properties configuration;
/**
* Field goals
*/
private java.util.List goals;
//-----------/
//- Methods -/
//-----------/
/**
* Method addConfiguration
*
* @param key
* @param value
*/
public void addConfiguration( String key, String value )
{
getConfiguration().put( key, value );
} //-- void addConfiguration(String, String)
/**
* Method addGoal
*
* @param goal
*/
public void addGoal( Goal goal )
{
getGoals().add( goal );
} //-- void addGoal(Goal)
/**
* Method getArtifactId
*/
public String getArtifactId()
{
return this.artifactId;
} //-- String getArtifactId()
/**
* Method getConfiguration
*/
public java.util.Properties getConfiguration()
{
if ( this.configuration == null )
{
this.configuration = new java.util.Properties();
}
return this.configuration;
} //-- java.util.Properties getConfiguration()
/**
* Method getGoals
*/
public java.util.List getGoals()
{
if ( this.goals == null )
{
this.goals = new java.util.ArrayList();
}
return this.goals;
} //-- java.util.List getGoals()
/**
* Method getGroupId
*/
public String getGroupId()
{
return this.groupId;
} //-- String getGroupId()
/**
* Method getVersion
*/
public String getVersion()
{
return this.version;
} //-- String getVersion()
/**
* Method isDisabled
*/
public Boolean isDisabled()
{
return this.disabled;
} //-- Boolean isDisabled()
/**
* Method removeGoal
*
* @param goal
*/
public void removeGoal( Goal goal )
{
getGoals().remove( goal );
} //-- void removeGoal(Goal)
/**
* Method setArtifactId
*
* @param artifactId
*/
public void setArtifactId( String artifactId )
{
this.artifactId = artifactId;
} //-- void setArtifactId(String)
/**
* Method setConfiguration
*
* @param configuration
*/
public void setConfiguration( java.util.Properties configuration )
{
this.configuration = configuration;
} //-- void setConfiguration(java.util.Properties)
/**
* Method setDisabled
*
* @param disabled
*/
public void setDisabled( Boolean disabled )
{
this.disabled = disabled;
} //-- void setDisabled(Boolean)
/**
* Method setGoals
*
* @param goals
*/
public void setGoals( java.util.List goals )
{
this.goals = goals;
} //-- void setGoals(java.util.List)
/**
* Method setGroupId
*
* @param groupId
*/
public void setGroupId( String groupId )
{
this.groupId = groupId;
} //-- void setGroupId(String)
/**
* Method setVersion
*
* @param version
*/
public void setVersion( String version )
{
this.version = version;
} //-- void setVersion(String)
}

View File

@ -1,77 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class PluginManagement.
*
* @version $Revision$ $Date$
*/
public class PluginManagement
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field plugins
*/
private java.util.List plugins;
//-----------/
//- Methods -/
//-----------/
/**
* Method addPlugin
*
* @param plugin
*/
public void addPlugin( Plugin plugin )
{
getPlugins().add( plugin );
} //-- void addPlugin(Plugin)
/**
* Method getPlugins
*/
public java.util.List getPlugins()
{
if ( this.plugins == null )
{
this.plugins = new java.util.ArrayList();
}
return this.plugins;
} //-- java.util.List getPlugins()
/**
* Method removePlugin
*
* @param plugin
*/
public void removePlugin( Plugin plugin )
{
getPlugins().remove( plugin );
} //-- void removePlugin(Plugin)
/**
* Method setPlugins
*
* @param plugins
*/
public void setPlugins( java.util.List plugins )
{
this.plugins = plugins;
} //-- void setPlugins(java.util.List)
}

View File

@ -1,100 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class Reports.
*
* @version $Revision$ $Date$
*/
public class Reports
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field outputDirectory
*/
private String outputDirectory;
/**
* Field plugins
*/
private java.util.List plugins;
//-----------/
//- Methods -/
//-----------/
/**
* Method addPlugin
*
* @param plugin
*/
public void addPlugin( Plugin plugin )
{
getPlugins().add( plugin );
} //-- void addPlugin(Plugin)
/**
* Method getOutputDirectory
*/
public String getOutputDirectory()
{
return this.outputDirectory;
} //-- String getOutputDirectory()
/**
* Method getPlugins
*/
public java.util.List getPlugins()
{
if ( this.plugins == null )
{
this.plugins = new java.util.ArrayList();
}
return this.plugins;
} //-- java.util.List getPlugins()
/**
* Method removePlugin
*
* @param plugin
*/
public void removePlugin( Plugin plugin )
{
getPlugins().remove( plugin );
} //-- void removePlugin(Plugin)
/**
* Method setOutputDirectory
*
* @param outputDirectory
*/
public void setOutputDirectory( String outputDirectory )
{
this.outputDirectory = outputDirectory;
} //-- void setOutputDirectory(String)
/**
* Method setPlugins
*
* @param plugins
*/
public void setPlugins( java.util.List plugins )
{
this.plugins = plugins;
} //-- void setPlugins(java.util.List)
}

View File

@ -1,111 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class Repository.
*
* @version $Revision$ $Date$
*/
public class Repository
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field id
*/
private String id;
/**
* Field name
*/
private String name;
/**
* Field url
*/
private String url;
//-----------/
//- Methods -/
//-----------/
/**
* Method getId
*/
public String getId()
{
return this.id;
} //-- String getId()
/**
* Method getName
*/
public String getName()
{
return this.name;
} //-- String getName()
/**
* Method getUrl
*/
public String getUrl()
{
return this.url;
} //-- String getUrl()
/**
* Method setId
*
* @param id
*/
public void setId( String id )
{
this.id = id;
} //-- void setId(String)
/**
* Method setName
*
* @param name
*/
public void setName( String name )
{
this.name = name;
} //-- void setName(String)
/**
* Method setUrl
*
* @param url
*/
public void setUrl( String url )
{
this.url = url;
} //-- void setUrl(String)
public boolean equals( Object obj )
{
Repository other = (Repository) obj;
boolean retValue = false;
if ( id != null )
{
retValue = id.equals( other.id );
}
return retValue;
}
}

View File

@ -1,53 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class Resource.
*
* @version $Revision$ $Date$
*/
public class Resource
extends FileSet
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field targetPath
*/
private String targetPath;
//-----------/
//- Methods -/
//-----------/
/**
* Method getTargetPath
*/
public String getTargetPath()
{
return this.targetPath;
} //-- String getTargetPath()
/**
* Method setTargetPath
*
* @param targetPath
*/
public void setTargetPath( String targetPath )
{
this.targetPath = targetPath;
} //-- void setTargetPath(String)
}

View File

@ -1,98 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class Scm.
*
* @version $Revision$ $Date$
*/
public class Scm
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field connection
*/
private String connection;
/**
* Field developerConnection
*/
private String developerConnection;
/**
* Field url
*/
private String url;
//-----------/
//- Methods -/
//-----------/
/**
* Method getConnection
*/
public String getConnection()
{
return this.connection;
} //-- String getConnection()
/**
* Method getDeveloperConnection
*/
public String getDeveloperConnection()
{
return this.developerConnection;
} //-- String getDeveloperConnection()
/**
* Method getUrl
*/
public String getUrl()
{
return this.url;
} //-- String getUrl()
/**
* Method setConnection
*
* @param connection
*/
public void setConnection( String connection )
{
this.connection = connection;
} //-- void setConnection(String)
/**
* Method setDeveloperConnection
*
* @param developerConnection
*/
public void setDeveloperConnection( String developerConnection )
{
this.developerConnection = developerConnection;
} //-- void setDeveloperConnection(String)
/**
* Method setUrl
*
* @param url
*/
public void setUrl( String url )
{
this.url = url;
} //-- void setUrl(String)
}

View File

@ -1,98 +0,0 @@
/*
* $Id$
*/
package org.apache.maven.model.v4_0_0;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
/**
* Class Site.
*
* @version $Revision$ $Date$
*/
public class Site
implements java.io.Serializable
{
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field id
*/
private String id;
/**
* Field name
*/
private String name;
/**
* Field url
*/
private String url;
//-----------/
//- Methods -/
//-----------/
/**
* Method getId
*/
public String getId()
{
return this.id;
} //-- String getId()
/**
* Method getName
*/
public String getName()
{
return this.name;
} //-- String getName()
/**
* Method getUrl
*/
public String getUrl()
{
return this.url;
} //-- String getUrl()
/**
* Method setId
*
* @param id
*/
public void setId( String id )
{
this.id = id;
} //-- void setId(String)
/**
* Method setName
*
* @param name
*/
public void setName( String name )
{
this.name = name;
} //-- void setName(String)
/**
* Method setUrl
*
* @param url
*/
public void setUrl( String url )
{
this.url = url;
} //-- void setUrl(String)
}

View File

@ -19,6 +19,11 @@ package org.apache.maven.tools.repoclean;
import org.codehaus.classworlds.ClassWorld;
import org.codehaus.plexus.embed.Embedder;
import org.codehaus.plexus.util.IOUtil;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
/**
* @author jdcasey
@ -26,33 +31,37 @@ import org.codehaus.plexus.embed.Embedder;
public class Main
{
public static void main( String[] inputArgs )
public static void main( String[] args )
{
if ( args.length < 1 )
{
printUsage();
System.exit( 0 );
}
else if ( "-h".equals( args[0].toLowerCase() ) )
{
printHelp();
System.exit( 0 );
}
else if( "-template".equals( args[0] ) )
{
printTemplate();
System.exit( 0 );
}
Embedder embedder = new Embedder();
try
{
embedder.start( new ClassWorld() );
String[] args = inputArgs;
if ( args.length < 2 )
{
printUsage();
System.exit( 0 );
}
boolean reportOnly = false;
if ( args.length > 2 )
{
reportOnly = Boolean.valueOf( args[2] ).booleanValue();
}
RepositoryCleanerConfiguration config = buildConfig(args[0]);
RepositoryCleaner cleaner = null;
try
{
cleaner = (RepositoryCleaner) embedder.lookup( RepositoryCleaner.ROLE );
cleaner.cleanRepository( args[0], args[1], reportOnly );
cleaner.cleanRepository( config );
}
finally
{
@ -68,11 +77,74 @@ public class Main
}
}
private static RepositoryCleanerConfiguration buildConfig( String configPath ) throws IOException
{
Properties props = new Properties();
FileInputStream input = null;
try
{
input = new FileInputStream(configPath);
props.load(input);
}
finally
{
IOUtil.close(input);
}
RepositoryCleanerConfiguration config = new RepositoryCleanerConfiguration();
config.setSourceRepositoryPath(props.getProperty("sourceRepositoryPath"));
config.setSourceRepositoryLayout(props.getProperty("sourceRepositoryLayout", "legacy"));
config.setSourcePomVersion(props.getProperty("sourcePomVersion", "v3"));
config.setTargetRepositoryPath(props.getProperty("targetRepositoryPath"));
config.setTargetRepositoryLayout(props.getProperty("targetRepositoryLayout", "default"));
config.setReportsPath(props.getProperty("reportsPath"));
config.setReportOnly(Boolean.valueOf(props.getProperty("reportOnly")).booleanValue());
return config;
}
private static void printHelp()
{
System.out.println("repoclean: Repository Cleaner/Converter.\n\n" +
"Usage: repoclean -h|-template|<configuration-properties-file>\n\n" +
"Where the configuration properfies file can contain the following options:\n" +
"---------------------------------------------------------------------------\n" +
"sourceRepositoryPath=/path/to/repository/root #[REQUIRED]\n" +
"sourceRepositoryLayout=[legacy|default] #[DEFAULT: legacy]\n" +
"sourcePomType=[v3|v4] #[DEFAULT: v3]\n" +
"targetRepositoryPath=/path/to/repository/root #[REQUIRED]\n" +
"targetRepositoryLayout=[legacy|default] #[DEFAULT: default]\n" +
"reportsPath=/path/to/reports/directory #[REQUIRED]\n" +
"reportOnly=[true|false] #[REQUIRED]\n" +
"\n");
}
private static void printTemplate()
{
System.out.println(
"# ---------------------------------------------------------------------------\n" +
"# repoclean: Repository Cleaner/Converter.\n" +
"# This configuration auto-generated on: " + new java.util.Date() + "\n" +
"# ---------------------------------------------------------------------------\n\n" +
"# [REQUIRED OPTIONS]\n" +
"sourceRepositoryPath=/path/to/repository/root\n" +
"targetRepositoryPath=/path/to/repository/root\n" +
"reportsPath=/path/to/reports/directory\n" +
"reportOnly=[true|false]\n\n" +
"# [DEFAULT VALUE: legacy]\n" +
"#sourceRepositoryLayout=[legacy|default]\n\n" +
"# [DEFAULT VALUE: v3]\n" +
"#sourcePomType=[v3|v4]\n\n" +
"# [DEFAULT VALUE: default]\n" +
"#targetRepositoryLayout=[legacy|default]\n" +
"\n");
}
private static void printUsage()
{
System.out.println( "No repository directory specified.\n\n" + "Usage:\n"
System.out.println( "Required input is missing.\n\n" + "Usage:\n"
+ "--------------------------------------------------\n\n"
+ "repoclean <repository-path> <reports-path> [<report-only (use true|false)>]\n" );
+ "repoclean -h|-template|<configuration-properties-file>\n" );
}
}

View File

@ -1,176 +1,205 @@
package org.apache.maven.tools.repoclean;
/* ====================================================================
* 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.
* ====================================================================
/*
* ==================================================================== 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.apache.maven.tools.repoclean.correlate.ArtifactMd5Correlator;
import org.apache.maven.tools.repoclean.correlate.ArtifactPomCorrelator;
import org.apache.maven.tools.repoclean.patch.V4ModelPatcher;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.construction.ArtifactConstructionSupport;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.tools.repoclean.digest.ArtifactDigestVerifier;
import org.apache.maven.tools.repoclean.discover.ArtifactDiscoverer;
import org.apache.maven.tools.repoclean.report.Reporter;
import org.apache.maven.tools.repoclean.translate.PomV3ToV4Translator;
import org.apache.maven.tools.repoclean.validate.V4ModelIndependenceValidator;
import org.apache.maven.tools.repoclean.rewrite.ArtifactPomRewriter;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.codehaus.plexus.util.IOUtil;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.List;
/**
* @author jdcasey
*/
public class RepositoryCleaner
extends AbstractLogEnabled
implements Contextualizable
{
public static final String ROLE = RepositoryCleaner.class.getName();
private ArtifactPomCorrelator artifactPomCorrelator;
private ArtifactDigestVerifier artifactDigestVerifier;
private ArtifactMd5Correlator artifactMd5Correlator;
private ArtifactConstructionSupport artifactConstructionSupport = new ArtifactConstructionSupport();
private PomV3ToV4Translator pomV3ToV4Translator;
private PlexusContainer container;
private V4ModelIndependenceValidator v4ModelIndependenceValidator;
private V4ModelPatcher v4ModelPatcher;
public void cleanRepository( String repositoryPath, String reportsDir, boolean reportOnly )
public void cleanRepository( RepositoryCleanerConfiguration configuration )
throws Exception
{
Logger logger = getLogger();
File reportsBase = normalizeReportsBase( configuration.getReportsPath() );
File reportsBase = new File( reportsDir );
if ( !reportsBase.exists() )
{
logger.info( "Creating reports directory: \'" + reportsDir + "\'" );
reportsBase.mkdirs();
}
else if ( !reportsBase.isDirectory() )
{
logger.error( "Cannot write reports to \'" + reportsDir + "\' because it is not a directory." );
File sourceRepositoryBase = normalizeSourceRepositoryBase( configuration.getSourceRepositoryPath() );
reportsBase = null;
}
File targetRepositoryBase = normalizeTargetRepositoryBase( configuration.getTargetRepositoryPath() );
File repositoryBase = new File( repositoryPath );
if ( !repositoryBase.exists() )
{
logger.error( "Cannot clean repository \'" + repositoryPath + "\' because it does not exist." );
repositoryBase = null;
}
else if ( !repositoryBase.isDirectory() )
{
logger.error( "Cannot clean repository \'" + repositoryPath + "\' because it is not a directory." );
repositoryBase = null;
}
// do not proceed if we cannot produce reports, or if the repository is
// do not proceed if we cannot produce reports, or if the repository is
// invalid.
if ( reportsBase != null && repositoryBase != null )
if ( reportsBase != null && sourceRepositoryBase != null && targetRepositoryBase != null )
{
logger.info( "Scanning for POMs." );
String[] poms = scanPoms( repositoryPath );
logger.info( "Scanning for artifacts." );
String[] artifacts = scanArtifacts( repositoryPath );
Logger logger = getLogger();
Reporter repoReporter = new Reporter( reportsBase, "repository.report.txt" );
logger.info( "Correlating artifacts to POMs." );
artifactPomCorrelator.correlateArtifactsToPoms( poms, artifacts, repoReporter );
ArtifactDiscoverer artifactDiscoverer = (ArtifactDiscoverer) container.lookup(
ArtifactDiscoverer.ROLE,
configuration.getSourceRepositoryLayout() );
logger.info( "Correlating artifacts to MD5 digest files." );
artifactMd5Correlator.correlateArtifactsToMd5( repositoryBase, artifacts, repoReporter, reportOnly );
logger.info( "Translating POMs to V4 format." );
for ( int i = 0; i < poms.length; i++ )
logger.info( "Discovering artifacts." );
List artifacts = null;
try
{
String pom = poms[i];
artifacts = artifactDiscoverer.discoverArtifacts( sourceRepositoryBase, repoReporter );
}
catch ( Exception e )
{
repoReporter.error( "Error discovering artifacts in source repository.", e );
}
Reporter pomReporter = new Reporter( reportsBase, pom + ".report.txt" );
if ( artifacts != null )
{
ArtifactRepositoryLayout sourceLayout = (ArtifactRepositoryLayout) container.lookup(
ArtifactRepositoryLayout.ROLE,
configuration.getSourceRepositoryLayout() );
logger.info( "Reading POM: \'" + pom + "\'" );
org.apache.maven.model.v3_0_0.Model v3Model = null;
try
ArtifactRepository sourceRepo = new ArtifactRepository( "source",
"file://" + sourceRepositoryBase.getAbsolutePath(),
sourceLayout );
ArtifactRepositoryLayout targetLayout = (ArtifactRepositoryLayout) container.lookup(
ArtifactRepositoryLayout.ROLE,
configuration.getTargetRepositoryLayout() );
ArtifactRepository targetRepo = new ArtifactRepository( "target",
"file://" + targetRepositoryBase.getAbsolutePath(),
targetLayout );
logger.info( "Rewriting POMs and artifact files." );
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
{
v3Model = readV3( repositoryBase, pom );
}
catch ( Exception e )
{
logger.error( "Error reading POM: \'" + pom + "\'", e );
}
Artifact artifact = (Artifact) it.next();
Reporter artifactReporter = new Reporter( reportsBase, artifact.getGroupId() + "_"
+ artifact.getArtifactId() + "_" + artifact.getVersion() + ".report.txt" );
if ( v3Model != null )
{
logger.info( "Translating POM: \'" + pom + "\'" );
org.apache.maven.model.v4_0_0.Model v4Model = pomV3ToV4Translator.translate( v3Model, pomReporter );
logger.info( "Performing validation on resulting v4 model for POM: \'" + pom + "\'" );
boolean isValid = v4ModelIndependenceValidator.validate( v4Model, pomReporter, true );
if ( !isValid )
boolean errorOccurred = false;
try
{
logger.info( "Patching v4 model for POM: \'" + pom + "\' using information glean from path." );
v4ModelPatcher.patchModel( v4Model, pom, pomReporter );
if ( !configuration.reportOnly() )
{
logger.debug("sourceRepo basedir is: \'" + sourceRepo.getBasedir() + "\'");
logger.debug("targetRepo basedir is: \'" + targetRepo.getBasedir() + "\'");
File artifactSource = new File( sourceRepo.getBasedir(), sourceRepo.pathOf( artifact ) );
File artifactTarget = new File( targetRepo.getBasedir(), targetRepo.pathOf( artifact ) );
logger.info( "Re-performing validation on patched v4 model for POM: \'" + pom + "\'" );
isValid = v4ModelIndependenceValidator.validate( v4Model, pomReporter, false );
File targetParent = artifactTarget.getParentFile();
if ( !targetParent.exists() )
{
targetParent.mkdirs();
}
logger.debug( "Copying artifact[" + artifact.getId() + "] from \'"
+ artifactSource + "\' to \'" + artifactTarget + "\'." );
copyArtifact( artifactSource, artifactTarget, artifactReporter );
}
else
{
artifactReporter.info( "Skipping artifact copy (we're in report-only mode)." );
}
}
catch ( Exception e )
{
repoReporter.error("Error transferring artifact[" + artifact.getId() + "] to the target repository.", e);
// if we can't copy the jar over, then skip the rest.
errorOccurred = true;
}
if ( pomReporter.hasError() )
if ( !errorOccurred )
{
repoReporter.warn( "Translation of POM: \'" + pom + "\' encountered errors." );
}
if ( !reportOnly )
{
logger.info( "Writing POM: \'" + pom + "\'" );
logger.debug( "working on digest for artifact[" + artifact.getId() + "] with groupId: \'"
+ artifact.getGroupId() + "\'" );
try
{
writeV4( repositoryBase, pom, v4Model );
artifactDigestVerifier.verifyDigest( artifact, sourceRepo, targetRepo, artifactReporter,
configuration.reportOnly() );
}
catch ( Exception e )
{
logger.error( "Error writing POM: \'" + pom + "\'", e );
repoReporter.error( "Error verifying digest for artifact[" + artifact.getId() + "]", e );
}
}
else
{
logger.info( "NOT writing POM: \'" + pom + "\'; we are in report-only mode." );
}
}
else
{
pomReporter.error( "Cannot translate pom. V3 model is null." );
}
try
{
pomReporter.writeReport();
}
catch ( IOException e )
{
logger.error( "Error writing report for POM: \'" + pom + "\'", e );
if ( !errorOccurred )
{
Artifact pomArtifact = buildPomArtifact( artifact );
ArtifactPomRewriter artifactPomRewriter = (ArtifactPomRewriter) container.lookup(
ArtifactPomRewriter.ROLE,
configuration.getSourcePomVersion() );
File sourcePom = new File( sourceRepositoryBase, sourceRepo.pathOf( pomArtifact ) );
File targetPom = new File( targetRepositoryBase, targetRepo.pathOf( pomArtifact ) );
try
{
artifactPomRewriter.rewrite( artifact, sourcePom, targetPom, artifactReporter,
configuration.reportOnly() );
}
catch ( Exception e )
{
repoReporter.error( "Error rewriting POM for artifact[" + artifact.getId()
+ "] into the target repository.", e );
}
}
try
{
artifactReporter.writeReport();
}
catch ( IOException e )
{
logger.error( "Error writing report for artifact \'" + artifact.getId() + "\'", e );
}
}
}
@ -185,65 +214,119 @@ public class RepositoryCleaner
}
}
private void writeV4( File repositoryBase, String pom, org.apache.maven.model.v4_0_0.Model model ) throws Exception
private void copyArtifact( File artifactSource, File artifactTarget, Reporter reporter ) throws IOException
{
FileWriter writer = null;
InputStream inStream = null;
OutputStream outStream = null;
try
{
File pomFile = new File( repositoryBase, pom );
writer = new FileWriter( pomFile );
org.apache.maven.model.v4_0_0.io.xpp3.MavenXpp3Writer modelWriter = new org.apache.maven.model.v4_0_0.io.xpp3.MavenXpp3Writer();
modelWriter.write( writer, model );
File targetParent = artifactTarget.getParentFile();
if(!targetParent.exists())
{
reporter.info("Creating directory \'" + targetParent + "\'.");
targetParent.mkdirs();
}
inStream = new BufferedInputStream(new FileInputStream(artifactSource));
outStream = new BufferedOutputStream(new FileOutputStream(artifactTarget));
byte[] buffer = new byte[16];
int read = -1;
while((read = inStream.read(buffer)) > -1)
{
outStream.write(buffer, 0, read);
}
outStream.flush();
}
finally
{
IOUtil.close( writer );
IOUtil.close(inStream);
IOUtil.close(outStream);
}
}
private org.apache.maven.model.v3_0_0.Model readV3( File repositoryBase, String pom ) throws Exception
private Artifact buildPomArtifact( Artifact artifact )
{
org.apache.maven.model.v3_0_0.Model model = null;
return artifactConstructionSupport.createArtifact( artifact.getGroupId(), artifact.getArtifactId(),
artifact.getVersion(), artifact.getScope(), "pom" );
}
FileReader reader = null;
try
private File normalizeTargetRepositoryBase( String targetRepositoryPath )
{
Logger logger = getLogger();
File targetRepositoryBase = new File( targetRepositoryPath );
logger.info("Target repository is at: \'" + targetRepositoryBase + "\'");
if ( !targetRepositoryBase.exists() )
{
File pomFile = new File( repositoryBase, pom );
reader = new FileReader( pomFile );
logger.info( "Creating target repository at: \'" + targetRepositoryBase + "\'." );
org.apache.maven.model.v3_0_0.io.xpp3.MavenXpp3Reader modelReader = new org.apache.maven.model.v3_0_0.io.xpp3.MavenXpp3Reader();
model = modelReader.read( reader );
targetRepositoryBase.mkdirs();
}
finally
else if ( !targetRepositoryBase.isDirectory() )
{
IOUtil.close( reader );
logger.error( "Cannot write to target repository \'" + targetRepositoryBase
+ "\' because it is not a directory." );
targetRepositoryBase = null;
}
return model;
return targetRepositoryBase;
}
private String[] scanPoms( String repositoryPath )
private File normalizeSourceRepositoryBase( String sourceRepositoryPath )
{
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( repositoryPath );
scanner.setIncludes( new String[] { "**/poms/*.pom" } );
Logger logger = getLogger();
scanner.scan();
File sourceRepositoryBase = new File( sourceRepositoryPath );
return scanner.getIncludedFiles();
logger.info("Source repository is at: \'" + sourceRepositoryBase + "\'");
if ( !sourceRepositoryBase.exists() )
{
logger.error( "Cannot convert repository \'" + sourceRepositoryBase + "\' because it does not exist." );
sourceRepositoryBase = null;
}
else if ( !sourceRepositoryBase.isDirectory() )
{
logger.error( "Cannot convert repository \'" + sourceRepositoryBase + "\' because it is not a directory." );
sourceRepositoryBase = null;
}
return sourceRepositoryBase;
}
private String[] scanArtifacts( String repositoryPath )
private File normalizeReportsBase( String reportsPath )
{
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( repositoryPath );
scanner.setExcludes( new String[] { "**/poms/*.pom", "**/*.md5" } );
Logger logger = getLogger();
scanner.scan();
File reportsBase = new File( reportsPath );
if ( !reportsBase.exists() )
{
logger.info( "Creating reports directory: \'" + reportsBase + "\'" );
return scanner.getIncludedFiles();
reportsBase.mkdirs();
}
else if ( !reportsBase.isDirectory() )
{
logger.error( "Cannot write reports to \'" + reportsBase + "\' because it is not a directory." );
reportsBase = null;
}
return reportsBase;
}
public void contextualize( Context context )
throws Exception
{
this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
}

View File

@ -0,0 +1,110 @@
package org.apache.maven.tools.repoclean;
/* ====================================================================
* 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 jdcasey
*/
public class RepositoryCleanerConfiguration
{
private String sourceRepositoryPath;
private String sourceRepositoryLayout;
private String sourcePomVersion;
private String targetRepositoryPath;
private String targetRepositoryLayout;
private String reportsPath;
private boolean reportOnly;
public void setSourceRepositoryPath( String sourceRepositoryPath )
{
this.sourceRepositoryPath = sourceRepositoryPath;
}
public String getSourceRepositoryPath()
{
return sourceRepositoryPath;
}
public void setSourceRepositoryLayout( String sourceRepositoryLayout )
{
this.sourceRepositoryLayout = sourceRepositoryLayout;
}
public String getSourceRepositoryLayout()
{
return sourceRepositoryLayout;
}
public void setSourcePomVersion( String sourcePomVersion )
{
this.sourcePomVersion = sourcePomVersion;
}
public String getSourcePomVersion()
{
return sourcePomVersion;
}
public void setTargetRepositoryPath( String targetRepositoryPath )
{
this.targetRepositoryPath = targetRepositoryPath;
}
public String getTargetRepositoryPath()
{
return targetRepositoryPath;
}
public void setTargetRepositoryLayout( String targetRepositoryLayout )
{
this.targetRepositoryLayout = targetRepositoryLayout;
}
public String getTargetRepositoryLayout()
{
return targetRepositoryLayout;
}
public void setReportsPath( String reportsPath )
{
this.reportsPath = reportsPath;
}
public String getReportsPath()
{
return reportsPath;
}
public void setReportOnly( boolean reportOnly )
{
this.reportOnly = reportOnly;
}
public boolean reportOnly()
{
return reportOnly;
}
}

View File

@ -0,0 +1,34 @@
package org.apache.maven.tools.repoclean.artifact;
import org.apache.maven.artifact.handler.AbstractArtifactHandler;
/* ====================================================================
* 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 jdcasey
*/
public class LegacyPluginHandler
extends AbstractArtifactHandler
{
public String directory()
{
return "plugins";
}
}

View File

@ -1,89 +0,0 @@
package org.apache.maven.tools.repoclean.correlate;
/* ====================================================================
* 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.apache.maven.tools.repoclean.digest.ArtifactDigestException;
import org.apache.maven.tools.repoclean.digest.ArtifactDigestor;
import org.apache.maven.tools.repoclean.report.Reporter;
import org.codehaus.plexus.util.DirectoryScanner;
import java.io.File;
import java.util.Arrays;
import java.util.List;
/**
* @author jdcasey
*/
public class ArtifactMd5Correlator
{
public static final String ROLE = ArtifactMd5Correlator.class.getName();
private ArtifactDigestor artifactDigestor;
public void correlateArtifactsToMd5( File repositoryBase, String[] artifacts, Reporter reporter, boolean reportOnly )
{
reporter.info( "Starting artifact-to-MD5 correlation." );
List md5s = scanMd5s( repositoryBase );
for ( int i = 0; i < artifacts.length; i++ )
{
String artifact = artifacts[i];
String md5 = artifact + ".md5";
if ( !md5s.contains( md5 ) )
{
reporter.warn( "Cannot find digest file for artifact: \'" + artifact + "\'." );
if ( !reportOnly )
{
reporter.info( "Creating digest file: \'" + md5 + "\'" );
File artifactFile = new File( repositoryBase, artifact );
File md5File = new File( repositoryBase, md5 );
try
{
artifactDigestor.createArtifactDigest( artifactFile, md5File, ArtifactDigestor.MD5 );
}
catch ( ArtifactDigestException e )
{
reporter.error( "Error creating digest for artifact: \'" + artifact + "\'", e );
}
}
}
}
reporter.info( "Finished artifact-to-MD5 correlation." );
}
private List scanMd5s( File repositoryBase )
{
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( repositoryBase );
scanner.setIncludes( new String[] { "**/*.md5" } );
scanner.scan();
String[] md5s = scanner.getIncludedFiles();
return Arrays.asList( md5s );
}
}

View File

@ -1,85 +0,0 @@
package org.apache.maven.tools.repoclean.correlate;
/* ====================================================================
* 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.apache.maven.tools.repoclean.report.Reporter;
import java.util.Map;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author jdcasey
*/
public class ArtifactPomCorrelator
{
public static final String ROLE = ArtifactPomCorrelator.class.getName();
public void correlateArtifactsToPoms( String[] poms, String[] artifacts, Reporter reporter )
{
reporter.info( "Starting artifact-to-POM correlation." );
Map pomMap = new TreeMap();
for ( int i = 0; i < poms.length; i++ )
{
String key = keyOf( poms[i] );
if ( key == null )
{
reporter.error( "Found POM with invalid name: \'" + poms[i] + "\'" );
}
else
{
pomMap.put( key, poms[i] );
}
}
for ( int i = 0; i < artifacts.length; i++ )
{
String key = keyOf( artifacts[i] );
if ( key == null )
{
reporter.error( "Found artifact with invalid name: \'" + artifacts[i] + "\'" );
}
else if ( !pomMap.containsKey( key ) )
{
reporter.error( "Cannot find POM for artifact: \'" + artifacts[i] + "\'" );
}
}
reporter.info( "Finished artifact-to-POM correlation." );
}
private String keyOf( String artifact )
{
Pattern keyPattern = Pattern.compile( "(.+)\\.(jar|pom)" );
Matcher matcher = keyPattern.matcher( artifact );
String key = null;
if ( matcher.matches() )
{
key = matcher.group( 1 );
}
return key;
}
}

View File

@ -0,0 +1,46 @@
package org.apache.maven.tools.repoclean.digest;
/* ====================================================================
* 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 jdcasey
*/
public class ArtifactDigestVerificationException
extends Exception
{
public ArtifactDigestVerificationException()
{
}
public ArtifactDigestVerificationException( String message )
{
super( message );
}
public ArtifactDigestVerificationException( String message, Throwable cause )
{
super( message, cause );
}
public ArtifactDigestVerificationException( Throwable cause )
{
super( cause );
}
}

View File

@ -0,0 +1,154 @@
package org.apache.maven.tools.repoclean.digest;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.tools.repoclean.report.Reporter;
import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.io.IOException;
/* ====================================================================
* 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 jdcasey
*/
public class ArtifactDigestVerifier
{
public static final String ROLE = ArtifactDigestVerifier.class.getName();
private ArtifactDigestor artifactDigestor;
public void verifyDigest( Artifact artifact, ArtifactRepository sourceRepo, ArtifactRepository targetRepo,
Reporter reporter, boolean reportOnly ) throws Exception
{
File sourceBase = new File( sourceRepo.getBasedir() );
File targetBase = new File( targetRepo.getBasedir() );
// create the digest source file from which to copy/verify.
File digestSourceFile = null;
try
{
digestSourceFile = new File( sourceBase, sourceRepo.pathOf( artifact ) + ".md5" );
}
catch ( ArtifactPathFormatException e )
{
reporter.error( "Error creating java.io.File of digest source for artifact[" + artifact.getId() + "]", e );
throw e;
}
// create the digest target file from which to copy/create.
File digestTargetFile = null;
try
{
digestTargetFile = new File( targetBase, targetRepo.pathOf( artifact ) + ".md5" );
}
catch ( ArtifactPathFormatException e )
{
reporter.error( "Error creating java.io.File of digest target for artifact[" + artifact.getId() + "]", e );
throw e;
}
if(!reportOnly)
{
File targetParent = digestTargetFile.getParentFile();
if ( !targetParent.exists() )
{
reporter.info( "MD5 parent directory \'" + targetParent + "\' does not exist. Creating..." );
targetParent.mkdirs();
}
}
// create the artifact file in the target repo to use for generating a new digest.
File artifactTargetFile = null;
try
{
artifactTargetFile = new File( targetBase, targetRepo.pathOf( artifact ) );
}
catch ( ArtifactPathFormatException e )
{
reporter.error( "Error creating java.io.File for artifact[" + artifact.getId() + "]", e );
throw e;
}
boolean verified = false;
// if the digest source file exists, then verify it.
if ( digestSourceFile.exists() )
{
verified = artifactDigestor.verifyArtifactDigest( artifactTargetFile, digestTargetFile,
ArtifactDigestor.MD5 );
if ( verified )
{
reporter.info( "Source digest file for artifact[" + artifact.getId()
+ "] is okay, so we'll just copy it." );
if ( !reportOnly )
{
try
{
FileUtils.copyFile( digestSourceFile, digestTargetFile );
}
catch ( IOException e )
{
reporter.error( "Cannot copy digest file for artifact[" + artifact.getId()
+ "] from source to target.", e );
throw e;
}
}
else
{
reporter.info( "Skipping transfer of valid MD5 digest file (we're in report-only mode)." );
}
}
else
{
reporter.warn( ".md5 for artifact[" + artifact.getId() + "] in target repository is wrong." );
}
}
else
{
reporter.warn( ".md5 for artifact[" + artifact.getId() + "] is missing in source repository." );
}
// if the .md5 was missing or did not verify correctly, create a new one
// in the target repo.
if ( !verified )
{
reporter.info( "Creating .md5 for artifact[" + artifact.getId() + "] in target repository." );
if ( !reportOnly )
{
artifactDigestor.createArtifactDigest( artifactTargetFile, digestTargetFile, ArtifactDigestor.MD5 );
}
else
{
reporter.info( "Skipping creation of MD5 digest for artifact (we're in report-only mode)." );
}
}
}
}

View File

@ -11,6 +11,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
/**
* @author jdcasey
@ -26,11 +27,50 @@ public class ArtifactDigestor
public void createArtifactDigest( File artifactFile, File digestFile, String algorithm )
throws ArtifactDigestException
{
byte[] digestData = generateArtifactDigest( artifactFile, algorithm );
try
{
writeDigestFile( digestFile, digestData );
}
catch ( IOException e )
{
throw new ArtifactDigestException( "Cannot write digest to file: \'" + digestFile + "\'", e );
}
}
public boolean verifyArtifactDigest( File artifactFile, File digestFile, String algorithm )
throws ArtifactDigestException
{
boolean result = false;
if(artifactFile.exists() && digestFile.exists())
{
byte[] generatedDigest = generateArtifactDigest( artifactFile, algorithm );
byte[] digestFromFile = null;
try
{
digestFromFile = readFile( digestFile );
}
catch ( Exception e )
{
throw new ArtifactDigestException( "Cannot read digest from file: \'" + digestFile + "\'", e );
}
result = Arrays.equals( generatedDigest, digestFromFile );
}
return result;
}
private byte[] generateArtifactDigest( File artifactFile, String algorithm ) throws ArtifactDigestException
{
byte[] data = null;
try
{
data = readArtifactFile( artifactFile );
data = readFile( artifactFile );
}
catch ( IOException e )
{
@ -48,16 +88,8 @@ public class ArtifactDigestor
}
digest.update( data );
byte[] digestData = digest.digest();
try
{
writeDigestFile( digestFile, digestData );
}
catch ( IOException e )
{
throw new ArtifactDigestException( "Cannot write digest to file: \'" + digestFile + "\'", e );
}
return digest.digest();
}
private void writeDigestFile( File digestFile, byte[] digestData ) throws IOException
@ -75,7 +107,7 @@ public class ArtifactDigestor
}
}
private byte[] readArtifactFile( File artifactFile ) throws IOException
private byte[] readFile( File artifactFile ) throws IOException
{
BufferedInputStream in = null;
try
@ -97,4 +129,5 @@ public class ArtifactDigestor
IOUtil.close( in );
}
}
}

View File

@ -0,0 +1,34 @@
package org.apache.maven.tools.repoclean.discover;
import org.apache.maven.tools.repoclean.report.Reporter;
import java.io.File;
import java.util.List;
/* ====================================================================
* 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 jdcasey
*/
public interface ArtifactDiscoverer
{
public static final String ROLE = ArtifactDiscoverer.class.getName();
List discoverArtifacts( File repositoryBase, Reporter reporter ) throws Exception;
}

View File

@ -0,0 +1,113 @@
package org.apache.maven.tools.repoclean.discover;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.construction.ArtifactConstructionSupport;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.tools.repoclean.report.Reporter;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.IOUtil;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
/* ====================================================================
* 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 jdcasey
*/
public class DefaultArtifactDiscoverer
implements ArtifactDiscoverer
{
private ArtifactConstructionSupport artifactConstructionSupport = new ArtifactConstructionSupport();
public List discoverArtifacts( File repositoryBase, Reporter reporter ) throws Exception
{
List artifacts = new ArrayList();
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( repositoryBase );
scanner.setExcludes( new String[] { "**/*.pom", "**/*.md5" } );
scanner.scan();
String[] artifactPaths = scanner.getIncludedFiles();
for ( int i = 0; i < artifactPaths.length; i++ )
{
String path = artifactPaths[i];
Artifact artifact = buildArtifact( repositoryBase, path, reporter );
if(artifact != null)
{
artifacts.add( artifact );
}
}
return artifacts;
}
private Artifact buildArtifact( File repositoryBase, String path, Reporter reporter ) throws Exception
{
Artifact result = null;
int lastDot = path.lastIndexOf('.');
if(lastDot < 0)
{
reporter.error( "Found potential artifact file with invalid name. Path: \'" + path + "\' doesn't seem to contain a file extension." );
}
else
{
String pomPath = path.substring(0, lastDot) + ".pom";
File pomFile = new File(repositoryBase, pomPath);
if(pomFile.exists())
{
FileReader pomReader = null;
try
{
pomReader = new FileReader(pomFile);
MavenXpp3Reader modelReader = new MavenXpp3Reader();
Model model = modelReader.read(pomReader);
result = artifactConstructionSupport.createArtifact( model.getGroupId(), model.getArtifactId(),
model.getVersion(), Artifact.SCOPE_RUNTIME,
model.getPackaging() );
}
finally
{
IOUtil.close(pomReader);
}
}
else
{
reporter.error( "POM not found for potential artifact at \'" + path
+ "\'. Cannot create Artifact instance." );
}
}
return result;
}
}

View File

@ -0,0 +1,107 @@
package org.apache.maven.tools.repoclean.discover;
/*
* ==================================================================== 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.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.construction.ArtifactConstructionSupport;
import org.apache.maven.tools.repoclean.report.Reporter;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.DirectoryScanner;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author jdcasey
*/
public class LegacyArtifactDiscoverer
extends AbstractLogEnabled
implements ArtifactDiscoverer
{
private ArtifactConstructionSupport artifactConstructionSupport = new ArtifactConstructionSupport();
public List discoverArtifacts( File repositoryBase, Reporter reporter )
{
List artifacts = new ArrayList();
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( repositoryBase );
scanner.setExcludes( new String[] { "**/poms/*.pom", "**/*.md5" } );
scanner.scan();
String[] artifactPaths = scanner.getIncludedFiles();
for ( int i = 0; i < artifactPaths.length; i++ )
{
String path = artifactPaths[i];
Artifact artifact = buildArtifact( path, reporter );
if ( artifact != null )
{
artifacts.add( artifact );
}
}
return artifacts;
}
private Artifact buildArtifact( String path, Reporter reporter )
{
Artifact result = null;
// TODO: Need to add more test scenarios to the unit test for this
// pattern.
// I'm not convinced that this will catch everything.
Pattern pathInfoPattern = Pattern.compile( "(.+)\\/(.+)s\\/([-a-zA-Z0-9]+)-([0-9]+[-.0-9a-zA-Z]+)\\..+" );
Matcher matcher = pathInfoPattern.matcher( path );
if ( !matcher.matches() )
{
reporter.info( "Artifact path: \'" + path
+ "\' does not match naming convention. Cannot reliably extract artifact information from path." );
}
else
{
String groupId = matcher.group( 1 );
String type = matcher.group( 2 );
String artifactId = matcher.group( 3 );
String version = matcher.group( 4 );
// Commenting this, since the old repo style didn't have a concept
// of 'maven-plugin'...I've added an additional artifact handler
// specifically for this, with just enough functionality to get the
// pathing right.
//if ( "plugin".equals( type ) )
//{
// type = "maven-plugin";
//}
getLogger().debug( "Extracted artifact information from path:\n" + "groupId: \'" + groupId + "\'\n"
+ "artifactId: \'" + artifactId + "\'\n" + "type: \'" + type + "\'\n" + "version: \'" + version + "\'" );
result = artifactConstructionSupport.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME,
type );
}
return result;
}
}

View File

@ -1,72 +0,0 @@
package org.apache.maven.tools.repoclean.patch;
import org.apache.maven.model.v4_0_0.Model;
import org.apache.maven.tools.repoclean.report.Reporter;
import org.codehaus.plexus.util.StringUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/* ====================================================================
* 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 jdcasey
*/
public class V4ModelPatcher
{
public static final String ROLE = V4ModelPatcher.class.getName();
public void patchModel( Model model, String pomPath, Reporter reporter )
{
// TODO: Need to add more test scenarios to the unit test for this pattern.
// I'm not convinced that this will catch everything.
Pattern pathInfoPattern = Pattern.compile( "(.+)\\/poms\\/([-a-zA-Z0-9]+)-([0-9]+[-.0-9a-zA-Z]+).pom" );
Matcher matcher = pathInfoPattern.matcher( pomPath );
if ( !matcher.matches() )
{
reporter.info( "POM path: \'" + pomPath
+ "\' does not match naming convention. Cannot reliably patch model information from POM path." );
}
String parsedGroup = matcher.group( 1 );
String parsedArtifact = matcher.group( 2 );
String parsedVersion = matcher.group( 3 );
if ( StringUtils.isEmpty( model.getGroupId() ) )
{
reporter.info( "Patching missing Group Id with parsed data: \'" + parsedGroup + "\'" );
model.setGroupId( parsedGroup );
}
if ( StringUtils.isEmpty( model.getArtifactId() ) )
{
reporter.info( "Patching missing Artifact Id with parsed data: \'" + parsedArtifact + "\'" );
model.setArtifactId( parsedArtifact );
}
if ( StringUtils.isEmpty( model.getVersion() ) )
{
reporter.info( "Patching missing Version with parsed data: \'" + parsedVersion + "\'" );
model.setVersion( parsedVersion );
}
}
}

View File

@ -0,0 +1,35 @@
package org.apache.maven.tools.repoclean.rewrite;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.tools.repoclean.report.Reporter;
import java.io.File;
/* ====================================================================
* 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 jdcasey
*/
public interface ArtifactPomRewriter
{
public static final String ROLE = ArtifactPomRewriter.class.getName();
void rewrite( Artifact artifact, File from, File to, Reporter reporter, boolean reportOnly ) throws Exception;
}

View File

@ -0,0 +1,147 @@
package org.apache.maven.tools.repoclean.rewrite;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.model.v3_0_0.io.xpp3.MavenXpp3Reader;
import org.apache.maven.tools.repoclean.report.Reporter;
import org.apache.maven.tools.repoclean.translate.PomV3ToV4Translator;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
/* ====================================================================
* 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 jdcasey
*/
public class V3PomRewriter
implements ArtifactPomRewriter
{
private PomV3ToV4Translator translator;
public void rewrite( Artifact artifact, File from, File to, Reporter reporter, boolean reportOnly )
throws Exception
{
Model v4Model = null;
if ( from.exists() )
{
FileReader fromReader = null;
try
{
org.apache.maven.model.v3_0_0.Model v3Model = null;
try
{
fromReader = new FileReader( from );
MavenXpp3Reader v3Reader = new MavenXpp3Reader();
v3Model = v3Reader.read( fromReader );
}
catch ( Exception e )
{
reporter.error( "Invalid v3 POM at: \'" + from + "\'. Cannot read.", e );
}
if(v3Model != null)
{
v4Model = translator.translate( v3Model, reporter );
}
}
finally
{
IOUtil.close( fromReader );
}
}
else
{
reporter.info( "POM for artifact[" + artifact.getId()
+ "] does not exist in source repository. We will create a skeletal one here." );
v4Model = new Model();
}
if(v4Model != null)
{
validateV4Basics( v4Model, artifact, reporter );
if ( !reportOnly )
{
File toParent = to.getParentFile();
if ( !toParent.exists() )
{
toParent.mkdirs();
}
FileWriter toWriter = null;
try
{
toWriter = new FileWriter( to );
MavenXpp3Writer v4Writer = new MavenXpp3Writer();
v4Writer.write( toWriter, v4Model );
}
finally
{
IOUtil.close( toWriter );
}
}
else
{
reporter.info( "Skipping model write to target repository (we're in report-only mode)." );
}
}
}
private void validateV4Basics( Model model, Artifact artifact, Reporter reporter )
{
if ( StringUtils.isEmpty( model.getModelVersion() ) )
{
reporter.info( "Setting modelVersion on v4 model to \'4.0.0\'" );
model.setModelVersion( "4.0.0" );
}
if ( StringUtils.isEmpty( model.getGroupId() ) )
{
reporter.info( "Setting groupId on model using artifact information." );
model.setGroupId( artifact.getGroupId() );
}
if ( StringUtils.isEmpty( model.getArtifactId() ) )
{
reporter.info( "Setting artifactId on model using artifact information." );
model.setArtifactId( artifact.getArtifactId() );
}
if ( StringUtils.isEmpty( model.getVersion() ) )
{
reporter.info( "Setting version on model using artifact information." );
model.setVersion( artifact.getVersion() );
}
if ( StringUtils.isEmpty( model.getPackaging() ) )
{
reporter.info( "Setting packaging on model using artifact type information." );
model.setPackaging( artifact.getType() );
}
}
}

View File

@ -0,0 +1,133 @@
package org.apache.maven.tools.repoclean.rewrite;
/* ====================================================================
* 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.apache.maven.artifact.Artifact;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.tools.repoclean.report.Reporter;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
/**
* @author jdcasey
*/
public class V4PomRewriter implements ArtifactPomRewriter
{
public void rewrite( Artifact artifact, File from, File to, Reporter reporter, boolean reportOnly ) throws Exception
{
Model model = null;
if(from.exists())
{
FileReader fromReader = null;
try
{
fromReader = new FileReader(from);
MavenXpp3Reader reader = new MavenXpp3Reader();
try
{
model = reader.read( fromReader );
}
catch ( Exception e )
{
reporter.error("Invalid v4 POM at \'" + from + "\'. Cannot read.", e);
}
}
finally
{
IOUtil.close(fromReader);
}
}
else
{
reporter.error( "POM for artifact[" + artifact.getId() + "] does not exist in source repository!" );
}
if ( model != null )
{
validateBasics( model, artifact, reporter );
if ( !reportOnly )
{
File toParent = to.getParentFile();
if ( !toParent.exists() )
{
toParent.mkdirs();
}
FileWriter toWriter = null;
try
{
toWriter = new FileWriter( to );
MavenXpp3Writer writer = new MavenXpp3Writer();
writer.write( toWriter, model );
}
finally
{
IOUtil.close( toWriter );
}
}
else
{
reporter.info( "Skipping model write to target repository (we're in report-only mode)." );
}
}
}
private void validateBasics( Model model, Artifact artifact, Reporter reporter )
{
if(StringUtils.isEmpty( model.getModelVersion() ) )
{
reporter.info("Setting modelVersion on v4 model to \'4.0.0\'");
model.setModelVersion("4.0.0");
}
if(StringUtils.isEmpty(model.getGroupId()))
{
reporter.info("Setting groupId on model using artifact information.");
model.setGroupId(artifact.getGroupId());
}
if(StringUtils.isEmpty(model.getArtifactId()))
{
reporter.info("Setting artifactId on model using artifact information.");
model.setArtifactId(artifact.getArtifactId());
}
if(StringUtils.isEmpty(model.getVersion()))
{
reporter.info("Setting version on model using artifact information.");
model.setVersion(artifact.getVersion());
}
if(StringUtils.isEmpty(model.getPackaging()))
{
reporter.info("Setting packaging on model using artifact type information.");
model.setPackaging(artifact.getType());
}
}
}

View File

@ -1,27 +1,28 @@
package org.apache.maven.tools.repoclean.translate;
import org.apache.maven.model.v4_0_0.Build;
import org.apache.maven.model.v4_0_0.CiManagement;
import org.apache.maven.model.v4_0_0.Contributor;
import org.apache.maven.model.v4_0_0.Dependency;
import org.apache.maven.model.v4_0_0.Developer;
import org.apache.maven.model.v4_0_0.DistributionManagement;
import org.apache.maven.model.v4_0_0.Goal;
import org.apache.maven.model.v4_0_0.IssueManagement;
import org.apache.maven.model.v4_0_0.License;
import org.apache.maven.model.v4_0_0.MailingList;
import org.apache.maven.model.v4_0_0.Model;
import org.apache.maven.model.v4_0_0.Notifier;
import org.apache.maven.model.v4_0_0.Organization;
import org.apache.maven.model.v4_0_0.Plugin;
import org.apache.maven.model.v4_0_0.Reports;
import org.apache.maven.model.v4_0_0.Repository;
import org.apache.maven.model.v4_0_0.Resource;
import org.apache.maven.model.v4_0_0.Scm;
import org.apache.maven.model.v4_0_0.Site;
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.Goal;
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.Notifier;
import org.apache.maven.model.Organization;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.Reports;
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.tools.repoclean.report.Reporter;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.util.ArrayList;
import java.util.Iterator;
@ -30,21 +31,19 @@ import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/* ====================================================================
* 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.
* ====================================================================
/*
* ==================================================================== 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. ====================================================================
*/
/**
@ -84,8 +83,11 @@ public class PomV3ToV4Translator
PomKey pomKey = new PomKey( groupId, artifactId, version );
StringBuffer logHeader = new StringBuffer();
logHeader.append( "Translation of POM {" ).append( v3Model.getGroupId() ).append( ":" )
.append( v3Model.getArtifactId() ).append( ":" ).append( version ).append( "}\n" );
logHeader.append( "Translation of POM {" ).append( v3Model.getGroupId() ).append( ":" ).append(
v3Model.getArtifactId() ).append(
":" ).append(
version ).append(
"}" );
reporter.info( "[START] " + logHeader.toString() );
@ -258,11 +260,15 @@ public class PomV3ToV4Translator
StringBuffer info = new StringBuffer();
info.append( "Using some contrived information for report: \'" ).append( reportName ).append( "\'.\n" )
.append( "\to groupId: \'maven\'\n" ).append( "\to artifactId: \'" ).append( reportPluginName )
.append( "\'\n" ).append( "\to version: \'1.0-SNAPSHOT\'\n" ).append( "\to goal: \'report\'\n" )
.append( "\n" )
.append( "These values were extracted using the v3 report naming convention, but may be wrong." );
info.append( "Using some contrived information for report: \'" ).append( reportName ).append( "\'.\n" ).append(
"\to groupId: \'maven\'\n" ).append(
"\to artifactId: \'" ).append(
reportPluginName ).append(
"\'\n" ).append(
"\to version: \'1.0-SNAPSHOT\'\n" ).append(
"\to goal: \'report\'\n" ).append(
"\n" ).append(
"These values were extracted using the v3 report naming convention, but may be wrong." );
reporter.info( info.toString() );
@ -279,9 +285,9 @@ public class PomV3ToV4Translator
return reports;
}
private org.apache.maven.model.v4_0_0.Organization translateOrganization(
org.apache.maven.model.v3_0_0.Organization v3Organization,
Reporter reporter )
private org.apache.maven.model.Organization translateOrganization(
org.apache.maven.model.v3_0_0.Organization v3Organization,
Reporter reporter )
{
Organization organization = null;
@ -309,8 +315,7 @@ public class PomV3ToV4Translator
{
for ( Iterator it = v3MailingLists.iterator(); it.hasNext(); )
{
org.apache.maven.model.v3_0_0.MailingList v3List = (org.apache.maven.model.v3_0_0.MailingList) it
.next();
org.apache.maven.model.v3_0_0.MailingList v3List = (org.apache.maven.model.v3_0_0.MailingList) it.next();
MailingList list = new MailingList();
list.setArchive( v3List.getArchive() );
list.setName( v3List.getName() );
@ -420,7 +425,8 @@ public class PomV3ToV4Translator
repository.setName( "Default Repository" );
repository.setUrl( "file://" + distributionDirectory );
// throw new Exception( "Missing 'distributionSite': Both distributionSite and distributionDirectory must be set." );
// throw new Exception( "Missing 'distributionSite': Both distributionSite and
// distributionDirectory must be set." );
}
}
else
@ -458,8 +464,7 @@ public class PomV3ToV4Translator
{
for ( Iterator it = v3Developers.iterator(); it.hasNext(); )
{
org.apache.maven.model.v3_0_0.Developer v3Developer = (org.apache.maven.model.v3_0_0.Developer) it
.next();
org.apache.maven.model.v3_0_0.Developer v3Developer = (org.apache.maven.model.v3_0_0.Developer) it.next();
Developer developer = new Developer();
@ -510,8 +515,7 @@ public class PomV3ToV4Translator
{
for ( Iterator it = v3Contributors.iterator(); it.hasNext(); )
{
org.apache.maven.model.v3_0_0.Contributor v3Contributor = (org.apache.maven.model.v3_0_0.Contributor) it
.next();
org.apache.maven.model.v3_0_0.Contributor v3Contributor = (org.apache.maven.model.v3_0_0.Contributor) it.next();
Contributor contributor = new Contributor();
@ -560,23 +564,39 @@ public class PomV3ToV4Translator
plugin.setArtifactId( "surefire" );
plugin.setVersion( "1.0-SNAPSHOT" );
Properties config = new Properties();
Xpp3Dom config = new Xpp3Dom( "configuration" );
String includes = pathPatternsToString( testIncludes );
if ( StringUtils.isNotEmpty( includes ) )
if ( notEmpty( testIncludes ) )
{
config.setProperty( "includes", includes );
Xpp3Dom includes = new Xpp3Dom( "includes" );
for ( Iterator it = testIncludes.iterator(); it.hasNext(); )
{
String includePattern = (String) it.next();
Xpp3Dom include = new Xpp3Dom( "include" );
include.setValue( includePattern );
includes.addChild( include );
}
config.addChild( includes );
}
String excludes = pathPatternsToString( testExcludes );
if ( StringUtils.isNotEmpty( excludes ) )
if ( notEmpty( testExcludes ) )
{
config.setProperty( "excludes", excludes );
Xpp3Dom excludes = new Xpp3Dom( "excludes" );
for ( Iterator it = testExcludes.iterator(); it.hasNext(); )
{
String excludePattern = (String) it.next();
Xpp3Dom exclude = new Xpp3Dom( "exclude" );
exclude.setValue( excludePattern );
excludes.addChild( exclude );
}
config.addChild( excludes );
}
if ( !config.isEmpty() )
if ( config.getChildCount() > 0 )
{
plugin.setConfiguration( config );
}
@ -619,8 +639,8 @@ public class PomV3ToV4Translator
Resource resource = new Resource();
resource.setDirectory( v3Resource.getDirectory() );
resource.setExcludes( pathPatternsToString( v3Resource.getExcludes() ) );
resource.setIncludes( pathPatternsToString( v3Resource.getIncludes() ) );
resource.setExcludes( v3Resource.getExcludes() );
resource.setIncludes( v3Resource.getIncludes() );
resource.setTargetPath( v3Resource.getTargetPath() );
resources.add( resource );
@ -630,24 +650,24 @@ public class PomV3ToV4Translator
return resources;
}
private String pathPatternsToString( List patterns )
{
StringBuffer result = new StringBuffer();
if ( notEmpty( patterns ) )
{
for ( Iterator it = patterns.iterator(); it.hasNext(); )
{
String pattern = (String) it.next();
result.append( "," ).append( pattern );
}
result.setLength( result.length() - 1 );
}
return result.toString();
}
// private String pathPatternsToString( List patterns )
// {
// StringBuffer result = new StringBuffer();
//
// if ( notEmpty( patterns ) )
// {
// for ( Iterator it = patterns.iterator(); it.hasNext(); )
// {
// String pattern = (String) it.next();
//
// result.append( "," ).append( pattern );
// }
//
// result.setLength( result.length() - 1 );
// }
//
// return result.toString();
// }
private boolean notEmpty( List test )
{

View File

@ -1,75 +0,0 @@
package org.apache.maven.tools.repoclean.validate;
import org.apache.maven.model.v4_0_0.Model;
import org.apache.maven.tools.repoclean.report.Reporter;
import org.codehaus.plexus.util.StringUtils;
/* ====================================================================
* 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 jdcasey
*/
public class V4ModelIndependenceValidator
{
public static final String ROLE = V4ModelIndependenceValidator.class.getName();
public boolean validate( Model model, Reporter reporter, boolean warnOnly )
{
boolean isValid = true;
if ( StringUtils.isEmpty( model.getModelVersion() ) )
{
problem( "Model-version declaration is missing in resulting v4 model.", reporter, warnOnly );
isValid = false;
}
if ( StringUtils.isEmpty( model.getGroupId() ) )
{
problem( "Group ID is missing in resulting v4 model.", reporter, warnOnly );
isValid = false;
}
if ( StringUtils.isEmpty( model.getArtifactId() ) )
{
problem( "Artifact ID is missing in resulting v4 model.", reporter, warnOnly );
isValid = false;
}
if ( StringUtils.isEmpty( model.getVersion() ) )
{
problem( "Version is missing in resulting v4 model.", reporter, warnOnly );
isValid = false;
}
return isValid;
}
private void problem( String message, Reporter reporter, boolean warnOnly )
{
if ( warnOnly )
{
reporter.warn( message );
}
else
{
reporter.error( message );
}
}
}

View File

@ -1,5 +1,15 @@
<component-set>
<components>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>plugin</role-hint>
<implementation>org.apache.maven.tools.repoclean.artifact.LegacyPluginHandler</implementation>
</component>
<!--
|
|
@ -10,19 +20,7 @@
<implementation>org.apache.maven.tools.repoclean.RepositoryCleaner</implementation>
<requirements>
<requirement>
<role>org.apache.maven.tools.repoclean.translate.PomV3ToV4Translator</role>
</requirement>
<requirement>
<role>org.apache.maven.tools.repoclean.correlate.ArtifactPomCorrelator</role>
</requirement>
<requirement>
<role>org.apache.maven.tools.repoclean.correlate.ArtifactMd5Correlator</role>
</requirement>
<requirement>
<role>org.apache.maven.tools.repoclean.validate.V4ModelIndependenceValidator</role>
</requirement>
<requirement>
<role>org.apache.maven.tools.repoclean.patch.V4ModelPatcher</role>
<role>org.apache.maven.tools.repoclean.digest.ArtifactDigestVerifier</role>
</requirement>
</requirements>
</component>
@ -32,8 +30,9 @@
|
-->
<component>
<role>org.apache.maven.tools.repoclean.translate.PomV3ToV4Translator</role>
<implementation>org.apache.maven.tools.repoclean.translate.PomV3ToV4Translator</implementation>
<role>org.apache.maven.tools.repoclean.discover.ArtifactDiscoverer</role>
<role-hint>legacy</role-hint>
<implementation>org.apache.maven.tools.repoclean.discover.LegacyArtifactDiscoverer</implementation>
</component>
<!--
|
@ -41,41 +40,24 @@
|
-->
<component>
<role>org.apache.maven.tools.repoclean.correlate.ArtifactMd5Correlator</role>
<implementation>org.apache.maven.tools.repoclean.correlate.ArtifactMd5Correlator</implementation>
<role>org.apache.maven.tools.repoclean.discover.ArtifactDiscoverer</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.tools.repoclean.discover.DefaultArtifactDiscoverer</implementation>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.tools.repoclean.digest.ArtifactDigestVerifier</role>
<implementation>org.apache.maven.tools.repoclean.digest.ArtifactDigestVerifier</implementation>
<requirements>
<requirement>
<role>org.apache.maven.tools.repoclean.digest.ArtifactDigestor</role>
</requirement>
</requirements>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.tools.repoclean.correlate.ArtifactPomCorrelator</role>
<implementation>org.apache.maven.tools.repoclean.correlate.ArtifactPomCorrelator</implementation>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.tools.repoclean.validate.V4ModelIndependenceValidator</role>
<implementation>org.apache.maven.tools.repoclean.validate.V4ModelIndependenceValidator</implementation>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.tools.repoclean.patch.V4ModelPatcher</role>
<implementation>org.apache.maven.tools.repoclean.patch.V4ModelPatcher</implementation>
</component>
<!--
|
|
@ -85,5 +67,39 @@
<role>org.apache.maven.tools.repoclean.digest.ArtifactDigestor</role>
<implementation>org.apache.maven.tools.repoclean.digest.ArtifactDigestor</implementation>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.tools.repoclean.rewrite.ArtifactPomRewriter</role>
<role-hint>v3</role-hint>
<implementation>org.apache.maven.tools.repoclean.rewrite.V3PomRewriter</implementation>
<requirements>
<requirement>
<role>org.apache.maven.tools.repoclean.translate.PomV3ToV4Translator</role>
</requirement>
</requirements>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.tools.repoclean.rewrite.ArtifactPomRewriter</role>
<role-hint>v4</role-hint>
<implementation>org.apache.maven.tools.repoclean.rewrite.V4PomRewriter</implementation>
</component>
<!--
|
|
|
-->
<component>
<role>org.apache.maven.tools.repoclean.translate.PomV3ToV4Translator</role>
<implementation>org.apache.maven.tools.repoclean.translate.PomV3ToV4Translator</implementation>
</component>
</components>
</component-set>

View File

@ -1,64 +0,0 @@
package org.apache.maven.tools.repoclean.patch;
import org.apache.maven.model.v4_0_0.Model;
import org.apache.maven.tools.repoclean.report.Reporter;
import java.io.File;
import junit.framework.TestCase;
/* ====================================================================
* 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 jdcasey
*/
public class V4ModelPatcherTest
extends TestCase
{
public void testShouldPatchWithInfoFromXPP3PomPath()
{
String pomPath = "xpp3/poms/xpp3-1.1.3.3.pom";
Model model = new Model();
V4ModelPatcher patcher = new V4ModelPatcher();
Reporter reporter = new Reporter( new File( "." ), "testXpp3Patching.txt" );
patcher.patchModel( model, pomPath, reporter );
assertEquals( "xpp3", model.getGroupId() );
assertEquals( "xpp3", model.getArtifactId() );
assertEquals( "1.1.3.3", model.getVersion() );
}
public void testShouldPatchWithInfoFromPlexusContainerDefaultPomPath()
{
String pomPath = "plexus/poms/plexus-container-default-1.0-alpha-2-SNAPSHOT.pom";
Model model = new Model();
V4ModelPatcher patcher = new V4ModelPatcher();
Reporter reporter = new Reporter( new File( "." ), "testPlexusPatching.txt" );
patcher.patchModel( model, pomPath, reporter );
assertEquals( "plexus", model.getGroupId() );
assertEquals( "plexus-container-default", model.getArtifactId() );
assertEquals( "1.0-alpha-2-SNAPSHOT", model.getVersion() );
}
}