Generated archetype broken for any package name with dot (.)
Description
Attachments
- 10 Apr 2010, 11:06 PM
Activity
Hardy Ferentschik May 4, 2010 at 11:42 AM
The changes I made included a move of the java classes into com.example. I also moved archetype.properties out of the source directory since otherwise it was included into the artifact. In fact the following sequence of commands (as described in Contributing in Hibernate Search) works now:
# archetype creation
> cd hibernate-search-archetype
> mvn archetype:create-from-project -Darchetype.properties=archetype.properties
> cd target/generated-sources/archetype
> mvn install
# archetype usage against local catalog
> cd /tmp
> mvn archetype:generate -DarchetypeCatalog=local
However, I also had to set the groupId in the pom to com.example. Leaving the groupId as org.hibernate screwed up the import statements in the archetype. What happens is that all in all import statements org.hibernate gets replaced with whatever you specify during archetype:generate. The problem with com.example is that the artifact gets deployed at the wrong spot in the repo.
On top of this it is at the moment not clear what happens with the archetype catalog. How and if it gets maintained on the new Jboss Maven repo. I added a comment regarding this issue here.
Last but not least, I am getting more and more frustrated with the archetype plugin. Really the archetype needs its own packaging type. Right now I need a two step process to get the achetype deployed. I can not have an aggregator project where one module is the archetype which gets automatically deployed (as artifact!) when calling 'mvn install' or 'mvn deploy'. Currently there is always this additional step of 'mvn archetype:create-from-project; cd target/generated-sources/archetype; mvn install' From a release perspective this is a pita.
I'll resolve the issue, since the dot(.) problem is kind of resolved. We can visit the archetype generation/deployment at a later point in time.
Gustavo Fernandes May 3, 2010 at 3:52 PM
The attached patch fixed the issue AFAIK. Any reason to further change the archetype, have you found any other issue or problem?
Hardy Ferentschik May 3, 2010 at 2:24 PM
Seems like a bug in 'archetype:create-from-project'. When filtering the java files it wrongly replaces org.hibernate.search with ${groupId), where the variable is the group id specified during the archetype generate phase. It think that it is a bug within the archetype plugin which causes the problem.
I updated the archetype and the process described in this issue works now, however I had to set the groupId in the pom to com.example
.
Given that for now we are not able to update/deploy the archetype catalog on the new maven repo (see comment on [Maven Getting Started - Developers|Maven Getting Started - Developers]), we should just skip the deployment of the archetype for 3.2.
Hardy Ferentschik April 30, 2010 at 2:03 PM
I will look into this
Gustavo Fernandes April 13, 2010 at 1:57 PM
Yes, as long as the archetype is deployed on jboss repo, everyone can create projects from it, either using the command you wrote or the shorter, interactive version:
mvn archetype:generate -DarchetypeCatalog=http://repository.jboss.org/maven2/
which will present a list of all available archetypes in the Jboss nexus and ask for packages, groups, versions, etc
Regarding the manual step, it'd be nice to automate it!
Steps to reproduce:
=====================
$ cd hibernate-search-archetype
$ mvn archetype:create-from-project -Darchetype.properties=src/main/archetype/archetype.properties
...
[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------ [INFO] Total time: 4 seconds
[INFO] Finished at: Sat Apr 10 20:35:58 BST 2010
[INFO] Final Memory: 16M/80M
[INFO] ------------------------------------------------------------------------
$ cd target/generate-sources/archetype
$ mvn install
...
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------ [INFO] Total time: 3 seconds
[INFO] Finished at: Sat Apr 10 20:36:50 BST 2010
[INFO] Final Memory: 18M/80M
[INFO] ------------------------------------------------------------------------
$ cd ~/temp
$ mvn archetype:generate -DarchetypeGroupId=org.hibernate -DarchetypeArtifactId=hibernate-search-quickstart -DarchetypeVersion=3.2.0-SNAPSHOT -DgroupId=my.company -DartifactId=quickstart -Dversion=1.0-SNAPSHOT
...
[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------ [INFO] Total time: 5 seconds
[INFO] Finished at: Sat Apr 10 20:39:17 BST 2010
[INFO] Final Memory: 13M/79M
[INFO] ------------------------------------------------------------------------
$ cd quickstart
$ mvn install
[INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR :
[INFO] ------------------------------------------------------------- [ERROR] /Users/gustavo/temp/quickstart/src/main/java/com/mycomany/Book.java:[25,11] ';' expected
[ERROR] /Users/gustavo/temp/quickstart/src/main/java/com/mycomany/Book.java:[37,10] '.' expected
[ERROR] /Users/gustavo/temp/quickstart/src/main/java/com/mycomany/Book.java:[37,11] ';' expected
[ERROR] /Users/gustavo/temp/quickstart/src/main/java/com/mycomany/Book.java:[37,19] class, interface, or enum expected
[ERROR] /Users/gustavo/temp/quickstart/src/main/java/com/mycomany/Book.java:[37,20] class, interface, or enum expected
[ERROR] /Users/gustavo/temp/quickstart/src/main/java/com/mycomany/Author.java:[25,11] ';' expected