osgi/osgi.enroute

project archetype: __{impl,app}-artifactId__

maggu2810 opened this issue · 7 comments

After playing around with the enroute.osgi.org approach the last days I would like to check the documentation from the beginning to provide fixes if necessary.

The project archetype generation works some time and didn't some time (at least the result contains errors).
If I execute the following line:

mvn archetype:generate -DarchetypeGroupId=org.osgi.enroute.archetype -DarchetypeArtifactId=project -DarchetypeVersion=7.0.0

sometimes the modules elements look like:

    <modules>
        <module>impl</module>
        <module>app</module>
    <module>__impl-artifactId__</module>
    <module>__app-artifactId__</module>
  </modules>

Also the directories are not names correctly:

$ ls -l quickstart/
total 12
drwxr-xr-x 1 maggu2810 maggu2810   64 Nov 29 22:39 __app-artifactId__
drwxr-xr-x 1 maggu2810 maggu2810   20 Nov 29 22:39 __impl-artifactId__
-rw-r--r-- 1 maggu2810 maggu2810 9763 Nov 29 22:39 pom.xml

I started in an empty directory.
Full log:

$ mvn archetype:generate -DarchetypeGroupId=org.osgi.enroute.archetype -DarchetypeArtifactId=project -DarchetypeVersion=7.0.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=1024M; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256m; support was removed in 8.0
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] >>> maven-archetype-plugin:2.4:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO] 
[INFO] <<< maven-archetype-plugin:2.4:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO] 
[INFO] 
[INFO] --- maven-archetype-plugin:2.4:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] Archetype repository not defined. Using the one from [org.osgi.enroute.archetype:project:7.0.0] found in catalog remote
Define value for property 'groupId': : org.osgi.enroute.examples.quickstart
Define value for property 'artifactId': : quickstart
Define value for property 'version':  1.0-SNAPSHOT: : 
Nov 29, 2018 10:39:02 PM org.apache.velocity.runtime.log.JdkLogChute log
INFO: FileResourceLoader : adding path '.'
Define value for property 'package':  org.osgi.enroute.examples.quickstart.quickstart: : org.osgi.enroute.examples.quickstart.rest
[INFO] Using property: app-artifactId = app
[INFO] Using property: app-target-java-version = 8
[INFO] Using property: impl-artifactId = impl
Confirm properties configuration:
groupId: org.osgi.enroute.examples.quickstart
artifactId: quickstart
version: 1.0-SNAPSHOT
package: org.osgi.enroute.examples.quickstart.rest
app-artifactId: app
app-target-java-version: 8
impl-artifactId: impl
 Y: : 
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: project:7.0.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.osgi.enroute.examples.quickstart
[INFO] Parameter: artifactId, Value: quickstart
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: org.osgi.enroute.examples.quickstart.rest
[INFO] Parameter: packageInPathFormat, Value: org/osgi/enroute/examples/quickstart/rest
[INFO] Parameter: package, Value: org.osgi.enroute.examples.quickstart.rest
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: org.osgi.enroute.examples.quickstart
[INFO] Parameter: impl-artifactId, Value: impl
[INFO] Parameter: app-target-java-version, Value: 8
[INFO] Parameter: app-artifactId, Value: app
[INFO] Parameter: artifactId, Value: quickstart
[WARNING] Don't override file /home/maggu2810/data/shared/workspace/projects/de.maggu2810/enroute/playground/quickstart/pom.xml
[INFO] Parent element not overwritten in /home/maggu2810/data/shared/workspace/projects/de.maggu2810/enroute/playground/quickstart/__impl-artifactId__/pom.xml
[INFO] Parent element not overwritten in /home/maggu2810/data/shared/workspace/projects/de.maggu2810/enroute/playground/quickstart/__app-artifactId__/pom.xml
[INFO] project created from Archetype in dir: /home/maggu2810/data/shared/workspace/projects/de.maggu2810/enroute/playground/quickstart
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  36.821 s
[INFO] Finished at: 2018-11-29T22:39:10+01:00
[INFO] ------------------------------------------------------------------------

Further info:

I tried to remove the artifacts of the archetype first to ensure there is no "corrupt" version in my local Maven repo:

$ rm -rf ~/.m2/repository/org/osgi/enroute/

Ensure current working directory is empty:

$ find
.

Generate stuff using archetype project:

$ mvn archetype:generate -DarchetypeGroupId=org.osgi.enroute.archetype -DarchetypeArtifactId=project -DarchetypeVersion=7.0.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=1024M; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256m; support was removed in 8.0
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] >>> maven-archetype-plugin:2.4:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO] 
[INFO] <<< maven-archetype-plugin:2.4:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO] 
[INFO] 
[INFO] --- maven-archetype-plugin:2.4:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
^Cmaggu2810@m3800 ~/data/shared/workspace/projects/de.maggu2810/enroute/playground $ ^C
maggu2810@m3800 ~/data/shared/workspace/projects/de.maggu2810/enroute/playground $ unset _JAVA_OPTIONS
maggu2810@m3800 ~/data/shared/workspace/projects/de.maggu2810/enroute/playground $ rm -rf ~/.m2/repository/org/osgi/enroute/
maggu2810@m3800 ~/data/shared/workspace/projects/de.maggu2810/enroute/playground $ find
.
maggu2810@m3800 ~/data/shared/workspace/projects/de.maggu2810/enroute/playground $ mvn archetype:generate -DarchetypeGroupId=org.osgi.enroute.archetype -DarchetypeArtifactId=project -DarchetypeVersion=7.0.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=1024M; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256m; support was removed in 8.0
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] >>> maven-archetype-plugin:2.4:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO] 
[INFO] <<< maven-archetype-plugin:2.4:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO] 
[INFO] 
[INFO] --- maven-archetype-plugin:2.4:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] Archetype repository not defined. Using the one from [org.osgi.enroute.archetype:project:7.0.0] found in catalog remote
Downloading from central: https://repo.maven.apache.org/maven2/org/osgi/enroute/archetype/project/7.0.0/project-7.0.0.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/osgi/enroute/archetype/project/7.0.0/project-7.0.0.jar (6.5 kB at 29 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/osgi/enroute/archetype/project/7.0.0/project-7.0.0.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/osgi/enroute/archetype/project/7.0.0/project-7.0.0.pom (4.0 kB at 73 kB/s)
Define value for property 'groupId': : org.osgi.enroute.examples.quickstart
Define value for property 'artifactId': : quickstart
Define value for property 'version':  1.0-SNAPSHOT: : 
Nov 29, 2018 10:54:07 PM org.apache.velocity.runtime.log.JdkLogChute log
INFO: FileResourceLoader : adding path '.'
Define value for property 'package':  org.osgi.enroute.examples.quickstart.quickstart: : org.osgi.enroute.examples.quickstart.rest
[INFO] Using property: app-artifactId = app
[INFO] Using property: app-target-java-version = 8
[INFO] Using property: impl-artifactId = impl
Confirm properties configuration:
groupId: org.osgi.enroute.examples.quickstart
artifactId: quickstart
version: 1.0-SNAPSHOT
package: org.osgi.enroute.examples.quickstart.rest
app-artifactId: app
app-target-java-version: 8
impl-artifactId: impl
 Y: : 
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: project:7.0.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.osgi.enroute.examples.quickstart
[INFO] Parameter: artifactId, Value: quickstart
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: org.osgi.enroute.examples.quickstart.rest
[INFO] Parameter: packageInPathFormat, Value: org/osgi/enroute/examples/quickstart/rest
[INFO] Parameter: package, Value: org.osgi.enroute.examples.quickstart.rest
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: org.osgi.enroute.examples.quickstart
[INFO] Parameter: impl-artifactId, Value: impl
[INFO] Parameter: app-target-java-version, Value: 8
[INFO] Parameter: app-artifactId, Value: app
[INFO] Parameter: artifactId, Value: quickstart
[WARNING] Don't override file /home/maggu2810/data/shared/workspace/projects/de.maggu2810/enroute/playground/quickstart/pom.xml
[INFO] Parent element not overwritten in /home/maggu2810/data/shared/workspace/projects/de.maggu2810/enroute/playground/quickstart/__impl-artifactId__/pom.xml
[INFO] Parent element not overwritten in /home/maggu2810/data/shared/workspace/projects/de.maggu2810/enroute/playground/quickstart/__app-artifactId__/pom.xml
[INFO] project created from Archetype in dir: /home/maggu2810/data/shared/workspace/projects/de.maggu2810/enroute/playground/quickstart
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  24.715 s
[INFO] Finished at: 2018-11-29T22:54:12+01:00
[INFO] ------------------------------------------------------------------------

As you can already see in the lines above the "parent elements" "...-artifactId__/pom.xml" are used.

Inspect the module declarations in the base POM:

$ grep module quickstart/pom.xml 
    <modules>
        <module>impl</module>
        <module>app</module>
    <module>__impl-artifactId__</module>
    <module>__app-artifactId__</module>
  </modules>

This does look like a problem, although it appears to be at least partly an issue with the maven-archetype-plugin. I see that you're using version 2.4 of the archetype plugin. Can you try running the generation using version 3.0.0 or 3.0.1 of the plugin?

It's also possible that there's more than one thing going on here. The list of <module> entries may well be a separate issue from the folder structure.

It seems to make a difference:

$ mvn org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate -DarchetypeGroupId=org.osgi.enroute.archetype -DarchetypeArtifactId=project -DarchetypeVersion=7.0.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=1024M; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256m; support was removed in 8.0
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO] 
[INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO] 
[INFO] 
[INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] Archetype repository not defined. Using the one from [org.osgi.enroute.archetype:project:7.0.0] found in catalog remote
Downloading from central: https://repo.maven.apache.org/maven2/org/osgi/enroute/archetype/archetypes/7.0.0/archetypes-7.0.0.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/osgi/enroute/archetype/archetypes/7.0.0/archetypes-7.0.0.pom (7.0 kB at 112 kB/s)
Define value for property 'groupId': org.osgi.enroute.examples.quickstart
Define value for property 'artifactId': quickstart
Define value for property 'version' 1.0-SNAPSHOT: : 
Define value for property 'package' org.osgi.enroute.examples.quickstart.quickstart: : org.osgi.enroute.examples.quickstart.rest
[INFO] Using property: app-artifactId = app
[INFO] Using property: app-target-java-version = 8
[INFO] Using property: impl-artifactId = impl
Confirm properties configuration:
groupId: org.osgi.enroute.examples.quickstart
artifactId: quickstart
version: 1.0-SNAPSHOT
package: org.osgi.enroute.examples.quickstart.rest
app-artifactId: app
app-target-java-version: 8
impl-artifactId: impl
 Y: : 
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: project:7.0.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.osgi.enroute.examples.quickstart
[INFO] Parameter: artifactId, Value: quickstart
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: org.osgi.enroute.examples.quickstart.rest
[INFO] Parameter: packageInPathFormat, Value: org/osgi/enroute/examples/quickstart/rest
[INFO] Parameter: package, Value: org.osgi.enroute.examples.quickstart.rest
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: org.osgi.enroute.examples.quickstart
[INFO] Parameter: impl-artifactId, Value: impl
[INFO] Parameter: app-target-java-version, Value: 8
[INFO] Parameter: app-artifactId, Value: app
[INFO] Parameter: artifactId, Value: quickstart
[WARNING] Don't override file /home/maggu2810/data/shared/workspace/projects/de.maggu2810/enroute/playground/quickstart/pom.xml
[INFO] Parent element not overwritten in /home/maggu2810/data/shared/workspace/projects/de.maggu2810/enroute/playground/quickstart/impl/pom.xml
[INFO] Parent element not overwritten in /home/maggu2810/data/shared/workspace/projects/de.maggu2810/enroute/playground/quickstart/app/pom.xml
[INFO] Project created from Archetype in dir: /home/maggu2810/data/shared/workspace/projects/de.maggu2810/enroute/playground/quickstart
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  40.673 s
[INFO] Finished at: 2018-11-30T17:03:05+01:00
[INFO] ------------------------------------------------------------------------
$ grep module quickstart/pom.xml
    <modules>
        <module>impl</module>
        <module>app</module>
    </modules>

It seems to make a difference:

Well that's positive. Unfortunately I'm not aware of a way to require that an archetype is used with a particular version of the maven-archetype-plugin...

Would it make sense to change the command on the site to force the version 3.0.1 of the archetype plugin (as I have done in my command above)?

That's probably a good idea