Hi,
New to this forum so I start by saying hello to all.
I have come across a real weird issue when creating custom
maven archetypes that I found no way around.
Problem 1.
This particular project structure is meant to be used for backend database objects where I don't want/need to follow the default maven source structure.
The default source folder structure (src/main/java, src/main/resources, src/site) is not really suitable for me so my first question is if it is possible to change this.
The structure I am looking at consists of a number of database related folders (Constraints, Table, Grants etc etc) where I would like these to be created as individual root folders within the project structure where each folder should have a readMe.txt file.
At the project root I also expect to find the pom.xml and a release-descriptor.xml
Example:
The project structure on my custom archetype does not allow me to deviate from the default src/main/... file structure.
The only way I managed to get this to work is by pointing to the src/main/java/ source alternative the src/main/resources
This works but I don't like the file structure
I also have problems getting the release-descriptor.xml into the project root.
If change the archetype.xml to look like this...
<resource>/Constraints/readMe.txt</resource>
<resource>/DBLinks/readMe.txt</resource>
or
<source>/Constraints/readMe.txt</source>
<source>/DBLinks/readMe.txt</source>
where I also moved the archetype folder structure to the rchetype-resources folder maven complains about not being able to find the source/resource in the src/main/java directory.
Problem 2 (and this is a really weird one)
My archetype.xml have a reference to the resource>src/main/resources/Forms/readMe.txt</resource>
After running the mvn install on the project then executing the mvn archetype:generate against my new custom archetype it comes back with the following error...
D:\Applications>mvn archetype:generate -DarchetypeGroupId=au.gov.wa.commerce.archetypes -DarchetypeArtifactId=quickoradb
-DarchetypeVersion=1.0.0-SNAPSHOT
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[WARNING] Archetype not found in any catalog. Falling back to central repository (
http://repo1.maven.org/maven2).
[WARNING] Use -DarchetypeRepository=<your repository> if archetype's repository is elsewhere.
Downloading:
http://repo1.maven.org/maven2/au/gov/wa/commerce/archetypes/quickoradb/1.0.0-SNAPSHOT/maven-metadata.xml
Define value for property 'groupId': : au.gov.wa.commerce
Define value for property 'artifactId': : testQ
Define value for property 'version': 1.0-SNAPSHOT: :
Define value for property 'package': au.gov.wa.commerce: :
Confirm properties configuration:
groupId: au.gov.wa.commerce
artifactId: testQ
version: 1.0-SNAPSHOT
package: au.gov.wa.commerce
Y: :
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: quickoradb:1.0.0-SNAPSHOT
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: au.gov.wa.commerce
[INFO] Parameter: packageName, Value: au.gov.wa.commerce
[INFO] Parameter: package, Value: au.gov.wa.commerce
[INFO] Parameter: artifactId, Value: testQ
[INFO] Parameter: basedir, Value: D:\Applications
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[ERROR] ResourceManager.getResource() parse exception
[ERROR] org.apache.velocity.exception.ParseErrorException: Lexical error: org.apache.velocity.runtime.parser.TokenMgrErr
or: Lexical error at line 11, column 2. Encountered: <EOF> after : ""
at org.apache.velocity.Template.process(Template.java:137)
at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:415)
at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:335)
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1102)
at org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:498)
at org.apache.maven.archetype.old.DefaultOldArchetype.processTemplate(DefaultOldArchetype.java:847)
at org.apache.maven.archetype.old.DefaultOldArchetype.processTemplate(DefaultOldArchetype.java:717)
at org.apache.maven.archetype.old.DefaultOldArchetype.processResources(DefaultOldArchetype.java:758)
at org.apache.maven.archetype.old.DefaultOldArchetype.processTemplates(DefaultOldArchetype.java:674)
at org.apache.maven.archetype.old.DefaultOldArchetype.createArchetype(DefaultOldArchetype.java:329)
at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.processOldArchetype(DefaultArchetypeGenerator.
java:135)
at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(DefaultArchetypeGenerator.ja
va:104)
at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(DefaultArchetypeGenerator.ja
va:143)
at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(DefaultArchetypeGenerator.ja
va:169)
at org.apache.maven.archetype.DefaultArchetypeManager.generateProjectFromArchetype(DefaultArchetypeManager.java:
73)
at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:2
07)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.047s
[INFO] Finished at: Thu Jul 05 10:26:27 WST 2012
[INFO] Final Memory: 7M/18M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project sta
ndalone-pom: Error merging velocity templates -> [Help 1]
The error ...
[ERROR] org.apache.velocity.exception.ParseErrorException: Lexical error: org.apache.velocity.runtime.parser.TokenMgrErr
or: Lexical error at line 11, column 2. Encountered: <EOF> after : ""
btw. The warning thrown is just noise - The archetype is indeed found.
[WARNING] Archetype not found in any catalog. Falling back to central repository (
http://repo1.maven.org/maven2).
[WARNING] Use -DarchetypeRepository=<your repository> if archetype's repository is elsewhere.
If I comment out the line <resource>src/main/resources/Forms/readMe.txt</resource> in my archetype.xml and rebuild the archetype it runs without errors and creates all other folders listed in my archetype.
I have tried to rename this folder and archetype.xml reference but each time I enable this line it fails with the same error.
I have hex edited the archetype.xml to see if there is some unprintable characters in the file but found no issues with it.
The readMe.txt within the Forms folder is also ok.
Any takings on these questions ?
cheers