You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2010/03/14 00:47:18 UTC
svn commit: r922694 - in
/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype:
./ common/
Author: hboutemy
Date: Sat Mar 13 23:47:18 2010
New Revision: 922694
URL: http://svn.apache.org/viewvc?rev=922694&view=rev
Log:
o code formatting
o use IOUtil as much as possible
Modified:
maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/Archetype.java
maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeCreationRequest.java
maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeGenerationRequest.java
maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeGenerationResult.java
maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/DefaultArchetype.java
maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/ArchetypeArtifactManager.java
maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/Constants.java
maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java
maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeFilesResolver.java
maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeRegistryManager.java
maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultPomManager.java
Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/Archetype.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/Archetype.java?rev=922694&r1=922693&r2=922694&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/Archetype.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/Archetype.java Sat Mar 13 23:47:18 2010
@@ -94,11 +94,10 @@ public interface Archetype
*
* @throws java.io.IOException
*/
- File archiveArchetype(
- File archetypeDirectory,
- File outputDirectory,
- String finalName )
+ File archiveArchetype( File archetypeDirectory, File outputDirectory, String finalName )
throws DependencyResolutionRequiredException, IOException;
+
void updateLocalCatalog(org.apache.maven.archetype.catalog.Archetype archetype, String path);
+
void updateLocalCatalog(org.apache.maven.archetype.catalog.Archetype archetype);
}
Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeCreationRequest.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeCreationRequest.java?rev=922694&r1=922693&r2=922694&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeCreationRequest.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeCreationRequest.java Sat Mar 13 23:47:18 2010
@@ -56,11 +56,13 @@ public class ArchetypeCreationRequest
private String postPhase;
- public String getPostPhase() {
+ public String getPostPhase()
+ {
return postPhase;
}
- public ArchetypeCreationRequest setPostPhase(String postPhase) {
+ public ArchetypeCreationRequest setPostPhase( String postPhase )
+ {
this.postPhase = postPhase;
return this;
Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeGenerationRequest.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeGenerationRequest.java?rev=922694&r1=922693&r2=922694&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeGenerationRequest.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeGenerationRequest.java Sat Mar 13 23:47:18 2010
@@ -43,13 +43,13 @@ public class ArchetypeGenerationRequest
private ArtifactRepository localRepository;
- private List remoteArtifactRepositories;
-
+ private List remoteArtifactRepositories;
+
private Proxy activeProxy;
- private List servers = new ArrayList( );
+ private List servers = new ArrayList();
- private List mirrors = new ArrayList( );
+ private List mirrors = new ArrayList();
// Archetype definition
private String archetypeName;
@@ -73,24 +73,24 @@ public class ArchetypeGenerationRequest
private String packageName;
- private Properties properties = new Properties( );
+ private Properties properties = new Properties();
- public ArchetypeGenerationRequest( )
+ public ArchetypeGenerationRequest()
{
}
public ArchetypeGenerationRequest( Archetype archetype )
{
- this.archetypeGroupId = archetype.getGroupId( );
+ this.archetypeGroupId = archetype.getGroupId();
- this.archetypeArtifactId = archetype.getArtifactId( );
+ this.archetypeArtifactId = archetype.getArtifactId();
- this.archetypeVersion = archetype.getVersion( );
+ this.archetypeVersion = archetype.getVersion();
- this.archetypeRepository = archetype.getRepository( );
+ this.archetypeRepository = archetype.getRepository();
}
- public String getArchetypeGroupId( )
+ public String getArchetypeGroupId()
{
return archetypeGroupId;
}
@@ -102,7 +102,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public String getArchetypeArtifactId( )
+ public String getArchetypeArtifactId()
{
return archetypeArtifactId;
}
@@ -114,7 +114,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public String getArchetypeVersion( )
+ public String getArchetypeVersion()
{
return archetypeVersion;
}
@@ -126,7 +126,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public String getArchetypeGoals( )
+ public String getArchetypeGoals()
{
return archetypeGoals;
}
@@ -138,7 +138,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public String getArchetypeName( )
+ public String getArchetypeName()
{
return archetypeName;
}
@@ -150,7 +150,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public String getArchetypeRepository( )
+ public String getArchetypeRepository()
{
return archetypeRepository;
}
@@ -162,7 +162,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public String getArtifactId( )
+ public String getArtifactId()
{
return artifactId;
}
@@ -174,7 +174,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public String getGroupId( )
+ public String getGroupId()
{
return groupId;
}
@@ -186,7 +186,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public String getVersion( )
+ public String getVersion()
{
return version;
}
@@ -198,7 +198,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public String getPackage( )
+ public String getPackage()
{
return packageName;
}
@@ -210,7 +210,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public Properties getProperties( )
+ public Properties getProperties()
{
return properties;
}
@@ -222,7 +222,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public ArtifactRepository getLocalRepository( )
+ public ArtifactRepository getLocalRepository()
{
return localRepository;
}
@@ -234,7 +234,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public String getOutputDirectory( )
+ public String getOutputDirectory()
{
return outputDirectory;
}
@@ -246,7 +246,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public boolean isInteractiveMode( )
+ public boolean isInteractiveMode()
{
return interactiveMode;
}
@@ -258,7 +258,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public boolean isOffline( )
+ public boolean isOffline()
{
return offline;
}
@@ -270,7 +270,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public TransferListener getTransferListener( )
+ public TransferListener getTransferListener()
{
return transferListener;
}
@@ -282,7 +282,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public Proxy getActiveProxy( )
+ public Proxy getActiveProxy()
{
return activeProxy;
}
@@ -301,7 +301,7 @@ public class ArchetypeGenerationRequest
return this;
}
- public List getMirrors( )
+ public List getMirrors()
{
return mirrors;
}
@@ -313,11 +313,11 @@ public class ArchetypeGenerationRequest
return this;
}
- public List getServers( )
+ public List getServers()
{
return servers;
}
-
+
public List getRemoteArtifactRepositories()
{
return remoteArtifactRepositories;
Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeGenerationResult.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeGenerationResult.java?rev=922694&r1=922693&r2=922694&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeGenerationResult.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/ArchetypeGenerationResult.java Sat Mar 13 23:47:18 2010
@@ -24,7 +24,7 @@ public class ArchetypeGenerationResult
{
private Exception cause;
- public Exception getCause( )
+ public Exception getCause()
{
return cause;
}
Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/DefaultArchetype.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/DefaultArchetype.java?rev=922694&r1=922693&r2=922694&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/DefaultArchetype.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/DefaultArchetype.java Sat Mar 13 23:47:18 2010
@@ -26,6 +26,7 @@ import org.apache.maven.archetype.source
import org.apache.maven.archetype.source.ArchetypeDataSourceException;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.IOUtil;
import java.io.File;
import java.io.FileInputStream;
@@ -119,8 +120,11 @@ public class DefaultArchetype
else
{
String fileName = files[i].getAbsolutePath().substring( offset + 1 );
-
- if(File.separatorChar != '/'){ fileName = fileName.replace('\\', '/'); }
+
+ if ( File.separatorChar != '/' )
+ {
+ fileName = fileName.replace( '\\', '/' );
+ }
ZipEntry e = new ZipEntry( fileName );
@@ -128,14 +132,7 @@ public class DefaultArchetype
FileInputStream is = new FileInputStream( files[i] );
- byte[] buf = new byte[4096];
-
- int n;
-
- while ( ( n = is.read( buf ) ) > 0 )
- {
- zos.write( buf, 0, n );
- }
+ IOUtil.copy( is, zos );
is.close();
@@ -162,15 +159,15 @@ public class DefaultArchetype
public ArchetypeCatalog getDefaultLocalCatalog()
{
- return getLocalCatalog("${user.home}/.m2/archetype-catalog.xml");
+ return getLocalCatalog( "${user.home}/.m2/archetype-catalog.xml" );
}
public ArchetypeCatalog getLocalCatalog( String path )
{
try
{
- Properties properties=new Properties();
- properties.setProperty("file", path);
+ Properties properties = new Properties();
+ properties.setProperty( "file", path );
ArchetypeDataSource source = (ArchetypeDataSource) archetypeSources.get( "catalog" );
return source.getArchetypeCatalog( properties );
@@ -183,15 +180,15 @@ public class DefaultArchetype
public ArchetypeCatalog getRemoteCatalog()
{
- return getRemoteCatalog("http://repo1.maven.org/maven2");
+ return getRemoteCatalog( "http://repo1.maven.org/maven2" );
}
public ArchetypeCatalog getRemoteCatalog( String url )
{
try
{
- Properties properties=new Properties();
- properties.setProperty("repository", url);
+ Properties properties = new Properties();
+ properties.setProperty( "repository", url );
ArchetypeDataSource source = (ArchetypeDataSource) archetypeSources.get( "remote-catalog" );
return source.getArchetypeCatalog( properties );
@@ -202,18 +199,20 @@ public class DefaultArchetype
}
}
- public void updateLocalCatalog(org.apache.maven.archetype.catalog.Archetype archetype) {
- updateLocalCatalog(archetype, "${user.home}/.m2/archetype-catalog.xml");
+ public void updateLocalCatalog( org.apache.maven.archetype.catalog.Archetype archetype )
+ {
+ updateLocalCatalog( archetype, "${user.home}/.m2/archetype-catalog.xml" );
}
- public void updateLocalCatalog(org.apache.maven.archetype.catalog.Archetype archetype, String path) {
+ public void updateLocalCatalog( org.apache.maven.archetype.catalog.Archetype archetype, String path )
+ {
try
{
- Properties properties=new Properties();
- properties.setProperty("file", path);
+ Properties properties = new Properties();
+ properties.setProperty( "file", path );
ArchetypeDataSource source = (ArchetypeDataSource) archetypeSources.get( "catalog" );
- source.updateCatalog(properties, archetype);
+ source.updateCatalog( properties, archetype );
}
catch ( ArchetypeDataSourceException e )
{
Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/ArchetypeArtifactManager.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/ArchetypeArtifactManager.java?rev=922694&r1=922693&r2=922694&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/ArchetypeArtifactManager.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/ArchetypeArtifactManager.java Sat Mar 13 23:47:18 2010
@@ -37,7 +37,7 @@ public interface ArchetypeArtifactManage
String ROLE = ArchetypeArtifactManager.class.getName ();
Model getArchetypePom ( File jar )
- throws XmlPullParserException, UnknownArchetype, IOException;
+ throws XmlPullParserException, UnknownArchetype, IOException;
/**
*/
@@ -49,17 +49,17 @@ public interface ArchetypeArtifactManage
final ArtifactRepository localRepository,
final List repositories
)
- throws UnknownArchetype;
+ throws UnknownArchetype;
/**
*/
ClassLoader getArchetypeJarLoader ( File archetypeFile )
- throws UnknownArchetype;
+ throws UnknownArchetype;
/**
*/
ZipFile getArchetypeZipFile ( File archetypeFile )
- throws UnknownArchetype;
+ throws UnknownArchetype;
/**
*/
@@ -105,7 +105,7 @@ public interface ArchetypeArtifactManage
/**
*/
ArchetypeDescriptor getFileSetArchetypeDescriptor ( File archetypeFile )
- throws UnknownArchetype;
+ throws UnknownArchetype;
/**
*/
@@ -117,19 +117,19 @@ public interface ArchetypeArtifactManage
ArtifactRepository localRepository,
List repositories
)
- throws UnknownArchetype;
+ throws UnknownArchetype;
/**
*/
List getFilesetArchetypeResources ( File archetypeFile )
- throws UnknownArchetype;
+ throws UnknownArchetype;
/**
*/
org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor getOldArchetypeDescriptor (
File archetypeFile
)
- throws UnknownArchetype;
+ throws UnknownArchetype;
/**
*/
@@ -141,5 +141,5 @@ public interface ArchetypeArtifactManage
ArtifactRepository localRepository,
List repositories
)
- throws UnknownArchetype;
+ throws UnknownArchetype;
}
Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/Constants.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/Constants.java?rev=922694&r1=922693&r2=922694&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/Constants.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/Constants.java Sat Mar 13 23:47:18 2010
@@ -45,7 +45,7 @@ public interface Constants
String ARTIFACT_ID = "artifactId";
String ARCHETYPE_FILTERED_EXTENSIONS = "archetype.filteredExtensions";
-
+
String ARCHETYPE_LANGUAGES = "archetype.languages";
List DEFAULT_FILTERED_EXTENSIONS =
@@ -58,7 +58,7 @@ public interface Constants
);
List DEFAULT_LANGUAGES =
- Arrays.asList( new String[]{"java", "groovy", "csharp", "aspectj"} );
+ Arrays.asList( new String[]{ "java", "groovy", "csharp", "aspectj" } );
String GROUP_ID = "groupId";
Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java?rev=922694&r1=922693&r2=922694&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java Sat Mar 13 23:47:18 2010
@@ -31,6 +31,7 @@ import org.apache.maven.artifact.reposit
import org.apache.maven.model.Model;
import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@@ -84,13 +85,16 @@ public class DefaultArchetypeArtifactMan
final ArtifactRepository localRepository,
final List repositories
)
- throws UnknownArchetype {
- try {
+ throws UnknownArchetype
+ {
+ try
+ {
File archetype = getArchetype(
groupId,
artifactId,
version );
- if( archetype == null ) {
+ if ( archetype == null )
+ {
archetype =
downloader.download(
groupId,
@@ -108,93 +112,116 @@ public class DefaultArchetypeArtifactMan
}
return archetype;
}
- catch( DownloadNotFoundException ex ) {
+ catch ( DownloadNotFoundException ex )
+ {
throw new UnknownArchetype( ex );
}
- catch( DownloadException ex ) {
+ catch ( DownloadException ex )
+ {
throw new UnknownArchetype( ex );
}
}
public ClassLoader getArchetypeJarLoader( File archetypeFile )
- throws UnknownArchetype {
- try {
+ throws UnknownArchetype
+ {
+ try
+ {
URL[] urls = new URL[1];
urls[0] = archetypeFile.toURI().toURL();
return new URLClassLoader( urls );
}
- catch( MalformedURLException e ) {
+ catch ( MalformedURLException e )
+ {
throw new UnknownArchetype( e );
}
}
public Model getArchetypePom( File jar )
- throws XmlPullParserException, UnknownArchetype, IOException {
+ throws XmlPullParserException, UnknownArchetype, IOException
+ {
String pomFileName = null;
ZipFile zipFile = null;
- try {
+ try
+ {
zipFile = getArchetypeZipFile( jar );
Enumeration enumeration = zipFile.entries();
- while( enumeration.hasMoreElements() ) {
+ while ( enumeration.hasMoreElements() )
+ {
ZipEntry el = (ZipEntry) enumeration.nextElement();
String entry = el.getName();
- if( entry.startsWith( "META-INF" ) && entry.endsWith( "pom.xml" ) ) {
+ if ( entry.startsWith( "META-INF" ) && entry.endsWith( "pom.xml" ) )
+ {
pomFileName = entry;
}
}
- if( pomFileName == null ) {
+ if ( pomFileName == null )
+ {
return null;
}
ZipEntry pom =
zipFile.getEntry( StringUtils.replace( pomFileName, File.separator, "/" ) );
- if( pom == null ) {
+ if ( pom == null )
+ {
pom = zipFile.getEntry( StringUtils.replace( pomFileName, "/", File.separator ) );
}
- if( pom == null ) {
+ if ( pom == null )
+ {
return null;
}
return pomManager.readPom( zipFile.getInputStream( pom ) );
}
- finally {
+ finally
+ {
closeZipFile( zipFile );
}
}
public ZipFile getArchetypeZipFile( File archetypeFile )
- throws UnknownArchetype {
- try {
+ throws UnknownArchetype
+ {
+ try
+ {
return new ZipFile( archetypeFile );
}
- catch( ZipException e ) {
+ catch ( ZipException e )
+ {
throw new UnknownArchetype( e );
}
- catch( IOException e ) {
+ catch ( IOException e )
+ {
throw new UnknownArchetype( e );
}
}
- public boolean isFileSetArchetype( File archetypeFile ) {
+ public boolean isFileSetArchetype( File archetypeFile )
+ {
ZipFile zipFile = null;
- try {
+ try
+ {
zipFile = getArchetypeZipFile( archetypeFile );
return isFileSetArchetype( zipFile );
}
- catch( XmlPullParserException e ) {
+ catch ( XmlPullParserException e )
+ {
return false;
}
- catch( IOException e ) {
+ catch ( IOException e )
+ {
return false;
}
- catch( UnknownArchetype e ) {
+ catch ( UnknownArchetype e )
+ {
return false;
}
- finally {
+ finally
+ {
closeZipFile( zipFile );
}
}
@@ -206,9 +233,11 @@ public class DefaultArchetypeArtifactMan
ArtifactRepository archetypeRepository,
ArtifactRepository localRepository,
List repositories
- ) {
+ )
+ {
ZipFile zipFile = null;
- try {
+ try
+ {
zipFile =
getArchetypeZipFile(
getArchetypeFile(
@@ -223,37 +252,47 @@ public class DefaultArchetypeArtifactMan
return isFileSetArchetype( zipFile );
}
- catch( XmlPullParserException e ) {
+ catch ( XmlPullParserException e )
+ {
return false;
}
- catch( IOException e ) {
+ catch ( IOException e )
+ {
return false;
}
- catch( UnknownArchetype e ) {
+ catch ( UnknownArchetype e )
+ {
return false;
}
- finally {
+ finally
+ {
closeZipFile( zipFile );
}
}
- public boolean isOldArchetype( File archetypeFile ) {
+ public boolean isOldArchetype( File archetypeFile )
+ {
ZipFile zipFile = null;
- try {
+ try
+ {
zipFile = getArchetypeZipFile( archetypeFile );
return isOldArchetype( zipFile );
}
- catch( XmlPullParserException e ) {
+ catch ( XmlPullParserException e )
+ {
return false;
}
- catch( IOException e ) {
+ catch ( IOException e )
+ {
return false;
}
- catch( UnknownArchetype e ) {
+ catch ( UnknownArchetype e )
+ {
return false;
}
- finally {
+ finally
+ {
closeZipFile( zipFile );
}
}
@@ -265,9 +304,11 @@ public class DefaultArchetypeArtifactMan
ArtifactRepository archetypeRepository,
ArtifactRepository localRepository,
List repositories
- ) {
+ )
+ {
ZipFile zipFile = null;
- try {
+ try
+ {
zipFile =
getArchetypeZipFile(
getArchetypeFile(
@@ -282,16 +323,20 @@ public class DefaultArchetypeArtifactMan
return isOldArchetype( zipFile );
}
- catch( XmlPullParserException e ) {
+ catch ( XmlPullParserException e )
+ {
return false;
}
- catch( IOException e ) {
+ catch ( IOException e )
+ {
return false;
}
- catch( UnknownArchetype e ) {
+ catch ( UnknownArchetype e )
+ {
return false;
}
- finally {
+ finally
+ {
closeZipFile( zipFile );
}
}
@@ -303,13 +348,16 @@ public class DefaultArchetypeArtifactMan
ArtifactRepository archetypeRepository,
ArtifactRepository localRepository,
List remoteRepositories
- ) {
- try {
+ )
+ {
+ try
+ {
File archetype = getArchetype(
archetypeGroupId,
archetypeArtifactId,
archetypeVersion );
- if( archetype == null ) {
+ if ( archetype == null )
+ {
archetype =
downloader.download(
archetypeGroupId,
@@ -328,31 +376,38 @@ public class DefaultArchetypeArtifactMan
return archetype.exists();
}
- catch( DownloadException e ) {
+ catch ( DownloadException e )
+ {
getLogger().debug( "Archetype don't exist", e );
return false;
}
- catch( DownloadNotFoundException e ) {
+ catch ( DownloadNotFoundException e )
+ {
getLogger().debug( "Archetype don't exist", e );
return false;
}
}
public ArchetypeDescriptor getFileSetArchetypeDescriptor( File archetypeFile )
- throws UnknownArchetype {
+ throws UnknownArchetype
+ {
ZipFile zipFile = null;
- try {
+ try
+ {
zipFile = getArchetypeZipFile( archetypeFile );
return loadFileSetArchetypeDescriptor( zipFile );
}
- catch( XmlPullParserException e ) {
+ catch ( XmlPullParserException e )
+ {
throw new UnknownArchetype( e );
}
- catch( IOException e ) {
+ catch ( IOException e )
+ {
throw new UnknownArchetype( e );
}
- finally {
+ finally
+ {
closeZipFile( zipFile );
}
}
@@ -365,9 +420,11 @@ public class DefaultArchetypeArtifactMan
ArtifactRepository localRepository,
List repositories
)
- throws UnknownArchetype {
+ throws UnknownArchetype
+ {
ZipFile zipFile = null;
- try {
+ try
+ {
zipFile =
getArchetypeZipFile(
getArchetypeFile(
@@ -382,32 +439,37 @@ public class DefaultArchetypeArtifactMan
return loadFileSetArchetypeDescriptor( zipFile );
}
- catch( XmlPullParserException e ) {
+ catch ( XmlPullParserException e )
+ {
throw new UnknownArchetype( e );
}
- catch( IOException e ) {
+ catch ( IOException e )
+ {
throw new UnknownArchetype( e );
}
- finally {
+ finally
+ {
closeZipFile( zipFile );
}
}
public List getFilesetArchetypeResources( File archetypeFile )
- throws UnknownArchetype {
+ throws UnknownArchetype
+ {
List archetypeResources = new ArrayList();
ZipFile zipFile = null;
- try {
+ try
+ {
zipFile = getArchetypeZipFile( archetypeFile );
Enumeration enumeration = zipFile.entries();
- while( enumeration.hasMoreElements() ) {
+ while ( enumeration.hasMoreElements() )
+ {
ZipEntry entry = (ZipEntry) enumeration.nextElement();
- if( !entry.isDirectory()
- && entry.getName().startsWith( Constants.ARCHETYPE_RESOURCES )
- ) {
+ if ( !entry.isDirectory() && entry.getName().startsWith( Constants.ARCHETYPE_RESOURCES ) )
+ {
// not supposed to be file.seperator
String resource =
StringUtils.replace(
@@ -418,13 +480,16 @@ public class DefaultArchetypeArtifactMan
getLogger().debug( "Found resource " + resource );
// TODO:FIXME
archetypeResources.add( resource );
- } else {
+ }
+ else
+ {
getLogger().debug( "Not resource " + entry.getName() );
}
}
return archetypeResources;
}
- finally {
+ finally
+ {
closeZipFile( zipFile );
}
}
@@ -432,20 +497,25 @@ public class DefaultArchetypeArtifactMan
public org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor getOldArchetypeDescriptor(
File archetypeFile
)
- throws UnknownArchetype {
+ throws UnknownArchetype
+ {
ZipFile zipFile = null;
- try {
+ try
+ {
zipFile = getArchetypeZipFile( archetypeFile );
return loadOldArchetypeDescriptor( zipFile );
}
- catch( XmlPullParserException e ) {
+ catch ( XmlPullParserException e )
+ {
throw new UnknownArchetype( e );
}
- catch( IOException e ) {
+ catch ( IOException e )
+ {
throw new UnknownArchetype( e );
}
- finally {
+ finally
+ {
closeZipFile( zipFile );
}
}
@@ -458,9 +528,11 @@ public class DefaultArchetypeArtifactMan
ArtifactRepository localRepository,
List repositories
)
- throws UnknownArchetype {
+ throws UnknownArchetype
+ {
ZipFile zipFile = null;
- try {
+ try
+ {
zipFile =
getArchetypeZipFile(
getArchetypeFile(
@@ -475,34 +547,44 @@ public class DefaultArchetypeArtifactMan
return loadOldArchetypeDescriptor( zipFile );
}
- catch( XmlPullParserException e ) {
+ catch ( XmlPullParserException e )
+ {
throw new UnknownArchetype( e );
}
- catch( IOException e ) {
+ catch ( IOException e )
+ {
throw new UnknownArchetype( e );
}
- finally {
+ finally
+ {
closeZipFile( zipFile );
}
}
- private void closeZipFile( ZipFile zipFile ) {
- try {
+ private void closeZipFile( ZipFile zipFile )
+ {
+ try
+ {
zipFile.close();
}
- catch( Exception e ) {
+ catch ( Exception e )
+ {
getLogger().error( "Fail to close zipFile" );
}
}
private File getArchetype( String archetypeGroupId,
String archetypeArtifactId,
- String archetypeVersion ) {
+ String archetypeVersion )
+ {
String key = archetypeGroupId + ":" + archetypeArtifactId + ":" + archetypeVersion;
- if( archetypeCache.containsKey( key ) ) {
+ if ( archetypeCache.containsKey( key ) )
+ {
getLogger().debug( "Found archetype " + key + " in cache: " + archetypeCache.get( key ) );
return (File) archetypeCache.get( key );
- } else {
+ }
+ else
+ {
getLogger().debug( "Not found archetype " + key + " in cache" );
return null;
}
@@ -511,18 +593,22 @@ public class DefaultArchetypeArtifactMan
private void setArchetype( String archetypeGroupId,
String archetypeArtifactId,
String archetypeVersion,
- File archetype ) {
+ File archetype )
+ {
String key = archetypeGroupId + ":" + archetypeArtifactId + ":" + archetypeVersion;
archetypeCache.put( key, archetype );
}
- private ZipEntry searchEntry( ZipFile zipFile, String searchString ) {
- getLogger().debug("Searching for "+searchString+" inside "+zipFile);
+ private ZipEntry searchEntry( ZipFile zipFile, String searchString )
+ {
+ getLogger().debug( "Searching for " + searchString + " inside " + zipFile );
Enumeration enu = zipFile.entries();
- while( enu.hasMoreElements() ) {
+ while ( enu.hasMoreElements() )
+ {
ZipEntry entryfound = (ZipEntry) enu.nextElement();
getLogger().debug( "An ENTRY " + entryfound.getName() );
- if( searchString.equals( entryfound.getName() ) ) {
+ if ( searchString.equals( entryfound.getName() ) )
+ {
getLogger().error( "Found entry" );
return entryfound;
}
@@ -531,12 +617,14 @@ public class DefaultArchetypeArtifactMan
}
private Reader getArchetypeDescriptorReader( ZipFile zipFile )
- throws IOException {
+ throws IOException
+ {
ZipEntry entry = searchEntry( zipFile,
StringUtils.replace( Constants.ARCHETYPE_DESCRIPTOR, File.separator, "/" ) );
- if( entry == null ) {
+ if ( entry == null )
+ {
getLogger().debug(
"Not found " + Constants.ARCHETYPE_DESCRIPTOR + " retrying with windows path"
);
@@ -544,7 +632,8 @@ public class DefaultArchetypeArtifactMan
StringUtils.replace( Constants.ARCHETYPE_DESCRIPTOR, "/", File.separator )
);
}
- if( entry == null ) {
+ if ( entry == null )
+ {
throw new IOException(
"The " + Constants.ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
);
@@ -552,7 +641,8 @@ public class DefaultArchetypeArtifactMan
InputStream is = zipFile.getInputStream( entry );
- if( is == null ) {
+ if ( is == null )
+ {
throw new IOException(
"The " + Constants.ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
);
@@ -561,7 +651,8 @@ public class DefaultArchetypeArtifactMan
}
private boolean isFileSetArchetype( ZipFile zipFile )
- throws IOException, XmlPullParserException {
+ throws IOException, XmlPullParserException
+ {
org.apache.maven.archetype.metadata.ArchetypeDescriptor descriptor =
loadFileSetArchetypeDescriptor( zipFile );
@@ -569,7 +660,8 @@ public class DefaultArchetypeArtifactMan
}
private boolean isOldArchetype( ZipFile zipFile )
- throws IOException, XmlPullParserException {
+ throws IOException, XmlPullParserException
+ {
org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor descriptor =
loadOldArchetypeDescriptor( zipFile );
@@ -579,62 +671,70 @@ public class DefaultArchetypeArtifactMan
private org.apache.maven.archetype.metadata.ArchetypeDescriptor loadFileSetArchetypeDescriptor(
ZipFile zipFile
)
- throws IOException, XmlPullParserException {
+ throws IOException, XmlPullParserException
+ {
Reader reader = getArchetypeDescriptorReader( zipFile );
ArchetypeDescriptorXpp3Reader archetypeReader = new ArchetypeDescriptorXpp3Reader();
- try {
+ try
+ {
return archetypeReader.read( reader, true );
}
- catch(IOException e){
- getLogger().debug("Cant not read archetype descriptor", e);
+ catch ( IOException e )
+ {
+ getLogger().debug( "Cant not read archetype descriptor", e );
throw e;
}
- catch(XmlPullParserException e){
- getLogger().error("Cant not parse archetype descriptor", e);
+ catch ( XmlPullParserException e )
+ {
+ getLogger().error( "Cant not parse archetype descriptor", e );
throw e;
}
- finally {
+ finally
+ {
reader.close();
}
}
- private org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor
- loadOldArchetypeDescriptor( ZipFile zipFile )
- throws IOException, XmlPullParserException {
+ private org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor loadOldArchetypeDescriptor( ZipFile zipFile )
+ throws IOException, XmlPullParserException
+ {
ArchetypeDescriptorBuilder builder = new ArchetypeDescriptorBuilder();
org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor descriptor = null;
Reader reader = null;
- try {
+ try
+ {
reader = getOldArchetypeDescriptorReader( zipFile );
descriptor = builder.build( reader );
}
- catch( IOException ex ) {
+ catch ( IOException ex )
+ {
getLogger().debug( "Can not load old archetype", ex );
}
- catch( XmlPullParserException ex ) {
+ catch ( XmlPullParserException ex )
+ {
getLogger().error( "Can not parse old archetype", ex );
}
- finally {
- if( reader != null ) {
- reader.close();
- }
+ finally
+ {
+ IOUtil.close( reader );
}
- if( descriptor == null ) {
- try {
+ if ( descriptor == null )
+ {
+ try
+ {
reader = getOlderArchetypeDescriptorReader( zipFile );
descriptor = builder.build( reader );
}
- finally {
- if( reader != null ) {
- reader.close();
- }
+ finally
+ {
+ IOUtil.close( reader );
}
}
@@ -642,12 +742,14 @@ public class DefaultArchetypeArtifactMan
}
private Reader getOldArchetypeDescriptorReader( ZipFile zipFile )
- throws IOException {
+ throws IOException
+ {
ZipEntry entry = searchEntry( zipFile,
StringUtils.replace( Constants.OLD_ARCHETYPE_DESCRIPTOR, File.separator, "/" )
);
- if( entry == null ) {
+ if ( entry == null )
+ {
getLogger().debug(
"No found " + Constants.OLD_ARCHETYPE_DESCRIPTOR + " retrying with windows path"
);
@@ -656,7 +758,8 @@ public class DefaultArchetypeArtifactMan
);
}
- if( entry == null ) {
+ if ( entry == null )
+ {
throw new IOException(
"The " + Constants.OLD_ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
);
@@ -664,7 +767,8 @@ public class DefaultArchetypeArtifactMan
InputStream is = zipFile.getInputStream( entry );
- if( is == null ) {
+ if ( is == null )
+ {
throw new IOException(
"The " + Constants.OLD_ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
);
@@ -673,12 +777,14 @@ public class DefaultArchetypeArtifactMan
}
private Reader getOlderArchetypeDescriptorReader( ZipFile zipFile )
- throws IOException {
+ throws IOException
+ {
ZipEntry entry = searchEntry( zipFile,
StringUtils.replace( Constants.OLDER_ARCHETYPE_DESCRIPTOR, File.separator, "/" )
);
- if( entry == null ) {
+ if ( entry == null )
+ {
getLogger().debug(
"No found " + Constants.OLDER_ARCHETYPE_DESCRIPTOR + " retrying with windows path"
);
@@ -690,7 +796,8 @@ public class DefaultArchetypeArtifactMan
)
);
}
- if( entry == null ) {
+ if ( entry == null )
+ {
throw new IOException(
"The " + Constants.OLDER_ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
);
@@ -698,7 +805,8 @@ public class DefaultArchetypeArtifactMan
InputStream is = zipFile.getInputStream( entry );
- if( is == null ) {
+ if ( is == null )
+ {
throw new IOException(
"The " + Constants.OLDER_ARCHETYPE_DESCRIPTOR + " descriptor cannot be found."
);
Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeFilesResolver.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeFilesResolver.java?rev=922694&r1=922693&r2=922694&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeFilesResolver.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeFilesResolver.java Sat Mar 13 23:47:18 2010
@@ -371,8 +371,7 @@ public class DefaultArchetypeFilesResolv
private List resolveFiles( File basedir,
List languages )
- throws
- IOException
+ throws IOException
{
String[] languagesArray = (String[]) languages.toArray( new String[languages.size()] );
String[] languagesPathesArray = new String[languagesArray.length];
@@ -415,12 +414,7 @@ public class DefaultArchetypeFilesResolv
{
String language = languagesArray[i];
- if ( StringUtils.countMatches(
- minusSrc,
- File.separator + language + File.separator
- )
- > 0
- )
+ if ( StringUtils.countMatches( minusSrc, File.separator + language + File.separator ) > 0 )
{
String minusLanguage =
StringUtils.prechomp( minusSrc, language + File.separator );
Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeRegistryManager.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeRegistryManager.java?rev=922694&r1=922693&r2=922694&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeRegistryManager.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeRegistryManager.java Sat Mar 13 23:47:18 2010
@@ -65,8 +65,7 @@ public class DefaultArchetypeRegistryMan
String archetypeFilteredExtentions,
File archetypeRegistryFile
)
- throws
- IOException
+ throws IOException
{
List filteredExtensions = new ArrayList();
@@ -102,8 +101,7 @@ public class DefaultArchetypeRegistryMan
public List getLanguages( String archetypeLanguages,
File archetypeRegistryFile )
- throws
- IOException
+ throws IOException
{
List languages = new ArrayList();
@@ -120,11 +118,11 @@ public class DefaultArchetypeRegistryMan
}
catch ( IOException e )
{
- getLogger().warn( "Can not read ~/m2/archetype.xml" );
+ getLogger().warn( "Can not read ~/.m2/archetype.xml" );
}
catch ( XmlPullParserException e )
{
- getLogger().warn( "Can not read ~/m2/archetype.xml" );
+ getLogger().warn( "Can not read ~/.m2/archetype.xml" );
}
if ( languages.isEmpty() )
@@ -136,9 +134,7 @@ public class DefaultArchetypeRegistryMan
}
public ArchetypeRegistry readArchetypeRegistry( File archetypeRegistryFile )
- throws
- IOException,
- XmlPullParserException
+ throws IOException, XmlPullParserException
{
if ( !archetypeRegistryFile.exists() )
{
@@ -151,9 +147,7 @@ public class DefaultArchetypeRegistryMan
}
public ArchetypeRegistry readArchetypeRegistry( Reader reader )
- throws
- IOException,
- XmlPullParserException
+ throws IOException, XmlPullParserException
{
ArchetypeRegistryXpp3Reader xpp3Reader = new ArchetypeRegistryXpp3Reader();
@@ -171,8 +165,7 @@ public class DefaultArchetypeRegistryMan
File archetypeRegistryFile,
ArchetypeRegistry archetypeRegistry
)
- throws
- IOException
+ throws IOException
{
ArchetypeRegistryXpp3Writer writer = new ArchetypeRegistryXpp3Writer();
FileWriter fileWriter = new FileWriter( archetypeRegistryFile );
Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultPomManager.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultPomManager.java?rev=922694&r1=922693&r2=922694&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultPomManager.java (original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultPomManager.java Sat Mar 13 23:47:18 2010
@@ -71,11 +71,7 @@ public class DefaultPomManager
{
public void addModule( File pom,
String artifactId )
- throws
- IOException,
- XmlPullParserException,
- DocumentException,
- InvalidPackaging
+ throws IOException, XmlPullParserException, DocumentException, InvalidPackaging
{
boolean found = false;
@@ -158,9 +154,7 @@ public class DefaultPomManager
public void addParent( File pom,
File parentPom )
- throws
- IOException,
- XmlPullParserException
+ throws IOException, XmlPullParserException
{
Model generatedModel = readPom( pom );
if( null != generatedModel.getParent() )
@@ -190,9 +184,7 @@ public class DefaultPomManager
public void mergePoms( File pom,
File temporaryPom )
- throws
- IOException,
- XmlPullParserException
+ throws IOException, XmlPullParserException
{
Model model = readPom( pom );
Model generatedModel = readPom( temporaryPom );
@@ -269,9 +261,7 @@ public class DefaultPomManager
}
public Model readPom( final File pomFile )
- throws
- IOException,
- XmlPullParserException
+ throws IOException, XmlPullParserException
{ // TODO ensure correct encoding by using default one from method argument !!!
Model model;
@@ -303,9 +293,7 @@ public class DefaultPomManager
public Model readPom( InputStream pomStream )
- throws
- IOException,
- XmlPullParserException
+ throws IOException, XmlPullParserException
{ // TODO ensure correct encoding by using default one from method argument !!!
Model model;
@@ -338,8 +326,7 @@ public class DefaultPomManager
public void writePom( final Model model,
final File pomFile,
final File initialPomFile )
- throws
- IOException
+ throws IOException
{
InputStream inputStream = null;
Writer outputStreamWriter = null;