Maven Archetype

archetype creation broken

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.0-alpha-4
  • Component/s: Plugin
  • Labels:
    None
  • Number of attachments :
    5

Description

  • when creating an archetype ie doing "archetype:create", the template substitution routines mangle characters like © .
  • binary files are also searched through for substitution this often results in exceptions and failed creation.

I think the archetype desperately needs a way of switching off template substitution for anything else but pom.xml. It's hardly useable for us in it's present form.

I can create a testcase if necessary, just ask.

  1. archetype.xml
    03/Apr/06 7:41 PM
    1 kB
    Chris Funk
  2. MNG-19-maven-archetype.patch
    31/Mar/06 4:54 PM
    44 kB
    Adolfo Garcia
  3. MNG-19-maven-archetype.patch
    31/Mar/06 3:38 PM
    40 kB
  1. before-ditech.gif
    7 kB
    03/Apr/06 7:38 PM
  2. ditech.gif
    7 kB
    03/Apr/06 7:39 PM

Issue Links

Activity

Hide
Michal Jastak added a comment -

similar problem observed when trying to create project using an archetype with FreeMarker templates inside, they are parsed with Velocity Engine, which leads us to parser exceptions and stops project creating process

Show
Michal Jastak added a comment - similar problem observed when trying to create project using an archetype with FreeMarker templates inside, they are parsed with Velocity Engine, which leads us to parser exceptions and stops project creating process
Hide
Adolfo Garcia added a comment -

The patch MNG-19-maven-archetype.patch corrects this issue by adding a couple of attributes to the <source> and <resource> elements of the archetype descriptor (archetype.xml). Sources can specify an encoding and resources if they should be filtered and their encoding. For example, you could have the following archetype descriptor:

archetype.xml
<archetype>
  <id>myArchetypeId</id>
  <sources>
    <source encoding="utf-8">src/main/java/MyApp.java</source>
  </sources>
  <resources>
    <resource filtered="false">src/main/resources/image.png</resource>
    <resource encoding="iso-8859-1">src/main/resources/index.html</resource>
    <resource>src/main/resources/labels.properties</resource>
  </resources>
  <testSources>
    <source>src/test/java/MyAppTest.java</source>
  </testSources>
</archetype>

In the previous example, the encoding of MyApp.java is utf-8, while that of MyAppTest.java will be assumed to be the default for the JVM, image.png will not be filtered (processed with Velocity), index.html will be processed, but non-ascii characters will not be broken, since its encoding (iso-8859-1) will be preserved, and labels.properties will be processed using the encoding used by all property files (iso-8859-1).

Now, the attribute encoding defines the encoding used by the source or resource file, so characters are not broken while creating the project, and the attribute filtered defines if the resource should be processed at all by Velocity. Until now, images in an archetype were filtered and broken each time a project was created.

By default all sources, resources, test-sources, test-resources and site-resources are filtered, and it is assumed they use the default Java virtual machine's encoding (just as before, so it is backwards compatible).

Show
Adolfo Garcia added a comment - The patch MNG-19-maven-archetype.patch corrects this issue by adding a couple of attributes to the <source> and <resource> elements of the archetype descriptor (archetype.xml). Sources can specify an encoding and resources if they should be filtered and their encoding. For example, you could have the following archetype descriptor:
archetype.xml
<archetype>
  <id>myArchetypeId</id>
  <sources>
    <source encoding="utf-8">src/main/java/MyApp.java</source>
  </sources>
  <resources>
    <resource filtered="false">src/main/resources/image.png</resource>
    <resource encoding="iso-8859-1">src/main/resources/index.html</resource>
    <resource>src/main/resources/labels.properties</resource>
  </resources>
  <testSources>
    <source>src/test/java/MyAppTest.java</source>
  </testSources>
</archetype>
In the previous example, the encoding of MyApp.java is utf-8, while that of MyAppTest.java will be assumed to be the default for the JVM, image.png will not be filtered (processed with Velocity), index.html will be processed, but non-ascii characters will not be broken, since its encoding (iso-8859-1) will be preserved, and labels.properties will be processed using the encoding used by all property files (iso-8859-1). Now, the attribute encoding defines the encoding used by the source or resource file, so characters are not broken while creating the project, and the attribute filtered defines if the resource should be processed at all by Velocity. Until now, images in an archetype were filtered and broken each time a project was created. By default all sources, resources, test-sources, test-resources and site-resources are filtered, and it is assumed they use the default Java virtual machine's encoding (just as before, so it is backwards compatible).
Hide
Brett Porter added a comment -

thanks!

Show
Brett Porter added a comment - thanks!
Hide
Chris Funk added a comment -

gif images are still broken. attached is a before and after of the gif I am using and the archetype.xml I verified it is using 1.0-alpha-4-SNAPSHOT

Show
Chris Funk added a comment - gif images are still broken. attached is a before and after of the gif I am using and the archetype.xml I verified it is using 1.0-alpha-4-SNAPSHOT
Hide
Adolfo Garcia added a comment -

I was not able to reproduce your problem Chris. I included your gif and a couple of others in an archetype.xml and none of them were corrupted in the projects created using the archetype. Could you check if the images are corrupted inside the archetype's JAR file. I have not seen files get broken when the archetype is generated, but I'm pretty sure they are being copied the way they are in the JAR file when the projects are created.

Show
Adolfo Garcia added a comment - I was not able to reproduce your problem Chris. I included your gif and a couple of others in an archetype.xml and none of them were corrupted in the projects created using the archetype. Could you check if the images are corrupted inside the archetype's JAR file. I have not seen files get broken when the archetype is generated, but I'm pretty sure they are being copied the way they are in the JAR file when the projects are created.
Hide
Sylvain Mougenot added a comment -

Those attributes must be documented in http://maven.apache.org/guides/mini/guide-creating-archetypes.html.
And also a schema should be provided to help.

vote for http://jira.codehaus.org/browse/ARCHETYPE-47

Show
Sylvain Mougenot added a comment - Those attributes must be documented in http://maven.apache.org/guides/mini/guide-creating-archetypes.html. And also a schema should be provided to help. vote for http://jira.codehaus.org/browse/ARCHETYPE-47

People

Vote (5)
Watch (5)

Dates

  • Created:
    Updated:
    Resolved: