Author: rafale Date: Mon Feb 18 13:22:31 2008 New Revision: 628869 URL: http://svn.apache.org/viewvc?rev=628869&view=rev Log: fixing roundtrip test on windows
Modified: maven/archetype/trunk/archetype-common/pom.xml 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/generator/DefaultFilesetArchetypeGenerator.java maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripWithProxyTest.java Modified: maven/archetype/trunk/archetype-common/pom.xml URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/pom.xml?rev=628869&r1=628868&r2=628869&view=diff ============================================================================== --- maven/archetype/trunk/archetype-common/pom.xml (original) +++ maven/archetype/trunk/archetype-common/pom.xml Mon Feb 18 13:22:31 2008 @@ -373,7 +373,7 @@ </execution> </executions> </plugin> - <plugin> + <!--plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> @@ -383,7 +383,7 @@ <exclude>**/DefaultRepositoryCrawlerTest.java</exclude> </excludes> </configuration> - </plugin> + </plugin--> </plugins> </build> <reporting> @@ -414,4 +414,4 @@ </build> </profile> </profiles> -</project> \ No newline at end of file +</project> 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=628869&r1=628868&r2=628869&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 Mon Feb 18 13:22:31 2008 @@ -133,16 +133,28 @@ ZipEntry el = (ZipEntry) enumeration.nextElement (); String entry = el.getName (); - if ( entry.startsWith ( "META-INF/maven" ) && entry.endsWith ( "pom.xml" ) ) + if ( entry.startsWith ( "META-INF" ) && entry.endsWith ( "pom.xml" ) ) { pomFileName = entry; } } - return - ( pomFileName == null ) - ? null - : pomManager.readPom ( zipFile.getInputStream ( zipFile.getEntry ( pomFileName ) ) ); + if ( pomFileName == null ) + { + return null; + } + + ZipEntry pom = + zipFile.getEntry ( StringUtils.replace ( pomFileName, File.separator, "/" ) ); + if ( pom == null ) + { + pom = zipFile.getEntry ( StringUtils.replace ( pomFileName, "/", File.separator ) ); + } + if ( pom == null ) + { + return null; + } + return pomManager.readPom ( zipFile.getInputStream ( pom ) ); } public ZipFile getArchetypeZipFile ( File archetypeFile ) @@ -471,10 +483,23 @@ private Reader getArchetypeDescriptorReader ( ZipFile zipFile ) throws IOException { - ZipEntry entry = zipFile.getEntry ( Constants.ARCHETYPE_DESCRIPTOR ); + ZipEntry entry = + zipFile.getEntry ( + StringUtils.replace ( Constants.ARCHETYPE_DESCRIPTOR, File.separator, "/" ) + ); if ( entry == null ) { + getLogger ().debug ( + "No found " + Constants.ARCHETYPE_DESCRIPTOR + " retrying with windows path" + ); + entry = + zipFile.getEntry ( + StringUtils.replace ( Constants.ARCHETYPE_DESCRIPTOR, "/", File.separator ) + ); + } + if ( entry == null ) + { throw new IOException ( "The " + Constants.ARCHETYPE_DESCRIPTOR + " descriptor cannot be found." ); @@ -582,7 +607,21 @@ private Reader getOldArchetypeDescriptorReader ( ZipFile zipFile ) throws IOException { - ZipEntry entry = zipFile.getEntry ( Constants.OLD_ARCHETYPE_DESCRIPTOR ); + ZipEntry entry = + zipFile.getEntry ( + StringUtils.replace ( Constants.OLD_ARCHETYPE_DESCRIPTOR, File.separator, "/" ) + ); + + if ( entry == null ) + { + getLogger ().debug ( + "No found " + Constants.OLD_ARCHETYPE_DESCRIPTOR + " retrying with windows path" + ); + entry = + zipFile.getEntry ( + StringUtils.replace ( Constants.OLD_ARCHETYPE_DESCRIPTOR, "/", File.separator ) + ); + } if ( entry == null ) { @@ -605,8 +644,25 @@ private Reader getOlderArchetypeDescriptorReader ( ZipFile zipFile ) throws IOException { - ZipEntry entry = zipFile.getEntry ( Constants.OLDER_ARCHETYPE_DESCRIPTOR ); + ZipEntry entry = + zipFile.getEntry ( + StringUtils.replace ( Constants.OLDER_ARCHETYPE_DESCRIPTOR, File.separator, "/" ) + ); + if ( entry == null ) + { + getLogger ().debug ( + "No found " + Constants.OLDER_ARCHETYPE_DESCRIPTOR + " retrying with windows path" + ); + entry = + zipFile.getEntry ( + StringUtils.replace ( + Constants.OLDER_ARCHETYPE_DESCRIPTOR, + "/", + File.separator + ) + ); + } if ( entry == null ) { throw new IOException ( Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java?rev=628869&r1=628868&r2=628869&view=diff ============================================================================== --- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java (original) +++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java Mon Feb 18 13:22:31 2008 @@ -684,7 +684,16 @@ ArchetypeGenerationFailure { templateFileName = templateFileName.replace( File.separatorChar, '/' ); - + + if ( !velocity.getEngine ().templateExists ( templateFileName ) + && velocity.getEngine ().templateExists ( + templateFileName.replace ( '/', File.separatorChar ) + ) + ) + { + templateFileName = templateFileName.replace ( '/', File.separatorChar ); + } + getLogger().debug( "Prosessing template " + templateFileName ); if ( failIfExists && outFile.exists() ) Modified: maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripWithProxyTest.java URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripWithProxyTest.java?rev=628869&r1=628868&r2=628869&view=diff ============================================================================== --- maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripWithProxyTest.java (original) +++ maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripWithProxyTest.java Mon Feb 18 13:22:31 2008 @@ -135,7 +135,7 @@ localRepository, null ); File archetypeDirectory = new File( generatedArchetypeDirectory, - "src"+File.separator+"xmain"+File.separator+"resources" ); + "src"+File.separator+"main"+File.separator+"resources" ); File archetypeArchive = archetype.archiveArchetype( archetypeDirectory, new File( generatedArchetypeProject.getBuild().getDirectory() ),