[
https://issues.apache.org/jira/browse/ARCHETYPE-688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17887565#comment-17887565
]
Javid commented on ARCHETYPE-688:
---------------------------------
Sure thing. Here you can see part of my archetype-metadata.xml
{code:java}
<requiredProperties>
<requiredProperty key="version">
<defaultValue>1.0.0-SNAPSHOT</defaultValue>
</requiredProperty>
<requiredProperty key="component-name"/>
<requiredProperty key="acronym-app"/>
<requiredProperty key="artifactId">
<defaultValue>${component-name}</defaultValue>
</requiredProperty>
<requiredProperty key="job-name">
<defaultValue>customerJob</defaultValue>
</requiredProperty>
<requiredProperty key="groupId">
<defaultValue>com.mypack.${acronym-app}</defaultValue>
</requiredProperty>
<requiredProperty key="package">
<defaultValue>${groupId}.${artifactId.replaceAll("-",
"").replaceAll("_", "")}</defaultValue>
</requiredProperty>
<requiredProperty key="description">
<defaultValue>${acronym-app} project-arch:
${component-name}</defaultValue>
</requiredProperty> {code}
As you can see, there are several parameters such as "component-name" or
"acronym-app" that contains the hyphen. Here is part of the stack trace when I
execute archetype:generate. I have focused mainly in the Velocity section of
it, as the error is produced there.
{code:java}
mvn -B archetype:generate -DarchetypeGroupId=com.mypack.project
-DarchetypeArtifactId=project-arch -DarchetypeVersion=4.0.0-RELEASE
-Dcomponent-name=greetings -Dacronym-app=project -X
[...]
[DEBUG] Entry found
[DEBUG] Creating ArchetypeConfiguration from fileset descriptor and Properties
[DEBUG] Adding requiredProperty version
[DEBUG] Setting property version=1.0.0-SNAPSHOT
[DEBUG] Setting defaultProperty version=1.0.0-SNAPSHOT
[DEBUG] Adding requiredProperty component-name
[DEBUG] Setting property component-name=greetings
[DEBUG] Adding requiredProperty acronym-app
[DEBUG] Setting property acronym-app=project
[DEBUG] Adding requiredProperty artifactId
[DEBUG] Setting defaultProperty artifactId=${component-name}
[DEBUG] Adding requiredProperty groupId
[DEBUG] Setting defaultProperty groupId=com.${acronym-app}
[DEBUG] Adding requiredProperty package
[DEBUG] Setting defaultProperty package=${groupId}.${artifactId.replaceAll("-",
"").replaceAll("_", "")}
[DEBUG] Adding requiredProperty description
[DEBUG] Setting defaultProperty description=${acronym-app} project-arch:
${component-name}
[DEBUG] Initializing Velocity, Calling init()...
[DEBUG] Starting Apache Velocity v2.3
[DEBUG] Default Properties resource:
org/apache/velocity/runtime/defaults/velocity.properties
[DEBUG] ResourceLoader instantiated:
org.apache.velocity.runtime.resource.loader.FileResourceLoader
[DEBUG] FileResourceLoader: adding path '.'
[DEBUG] initialized (class
org.apache.velocity.runtime.resource.ResourceCacheImpl) with class
java.util.Collections$SynchronizedMap cache map.
[DEBUG] Loaded System Directive: org.apache.velocity.runtime.directive.Stop
[DEBUG] Loaded System Directive: org.apache.velocity.runtime.directive.Define
[DEBUG] Loaded System Directive: org.apache.velocity.runtime.directive.Break
[DEBUG] Loaded System Directive: org.apache.velocity.runtime.directive.Evaluate
[DEBUG] Loaded System Directive: org.apache.velocity.runtime.directive.Macro
[DEBUG] Loaded System Directive: org.apache.velocity.runtime.directive.Parse
[DEBUG] Loaded System Directive: org.apache.velocity.runtime.directive.Include
[DEBUG] Loaded System Directive: org.apache.velocity.runtime.directive.Foreach
[DEBUG] Created '20' parsers.
[DEBUG] "velocimacro.library.path" is not set. Trying default library:
velocimacros.vtl
[DEBUG] Default library velocimacros.vtl not found. Trying old default library:
VM_global_library.vm
[DEBUG] Old default library VM_global_library.vm not found.
[DEBUG] allowInline = true: VMs can be defined inline in templates
[DEBUG] allowInlineToOverride = false: VMs defined inline may NOT replace
previous VM definitions
[DEBUG] allowInlineLocal = false: VMs defined inline will be global in scope if
allowed.
[DEBUG] autoload off: VM system will not automatically reload global library
macros
[ERROR] artifactId.default: Encountered "-name}" at line 1, column 12.
Was expecting one of:
"[" ...
"|" ...
"}" ...
"}" ...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.065 s
[INFO] Finished at: 2024-10-08T12:49:55+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-archetype-plugin:3.3.0:generate (default-cli) on
project standalone-pom: Unparsable default value for property artifactId:
Encountered "-name}" at artifactId.default[line 1, column 12]
[ERROR] Was expecting one of:
[ERROR] "[" ...
[ERROR] "|" ...
[ERROR] "}" ...
[ERROR] "}" ...
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal
org.apache.maven.plugins:maven-archetype-plugin:3.3.0:generate (default-cli) on
project standalone-pom: Unparsable default value for property artifactId
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2
(MojoExecutor.java:347)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute
(MojoExecutor.java:330)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute
(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute
(MojoExecutor.java:175)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000
(MojoExecutor.java:76)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run
(MojoExecutor.java:163)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute
(DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute
(MojoExecutor.java:160)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
(LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
(LifecycleModuleBuilder.java:73)
at
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build
(SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute
(LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced
(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch
(Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode
(Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main
(Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: Unparsable default
value for property artifactId
at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute
(CreateProjectFromArchetypeMojo.java:201)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo
(DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2
(MojoExecutor.java:342)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute
(MojoExecutor.java:330)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute
(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute
(MojoExecutor.java:175)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000
(MojoExecutor.java:76)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run
(MojoExecutor.java:163)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute
(DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute
(MojoExecutor.java:160)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
(LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
(LifecycleModuleBuilder.java:73)
at
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build
(SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute
(LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced
(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch
(Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode
(Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main
(Launcher.java:347)
Caused by: java.lang.IllegalStateException: Unparsable default value for
property artifactId
at
org.apache.maven.archetype.ui.generation.DefaultArchetypeGenerationConfigurator$RequiredPropertyComparator.computePropertyReferences
(DefaultArchetypeGenerationConfigurator.java:352)
at
org.apache.maven.archetype.ui.generation.DefaultArchetypeGenerationConfigurator$RequiredPropertyComparator.<init>
(DefaultArchetypeGenerationConfigurator.java:302)
at
org.apache.maven.archetype.ui.generation.DefaultArchetypeGenerationConfigurator.configureArchetype
(DefaultArchetypeGenerationConfigurator.java:151)
at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute
(CreateProjectFromArchetypeMojo.java:193)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo
(DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2
(MojoExecutor.java:342)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute
(MojoExecutor.java:330)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute
(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute
(MojoExecutor.java:175)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000
(MojoExecutor.java:76)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run
(MojoExecutor.java:163)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute
(DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute
(MojoExecutor.java:160)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
(LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
(LifecycleModuleBuilder.java:73)
at
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build
(SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute
(LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced
(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch
(Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode
(Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main
(Launcher.java:347)
Caused by: org.apache.velocity.runtime.parser.TemplateParseException:
Encountered "-name}" at artifactId.default[line 1, column 12]
Was expecting one of:
"[" ...
"|" ...
"}" ...
"}" ...
at org.apache.velocity.runtime.parser.StandardParser.parse
(StandardParser.java:198)
at org.apache.velocity.runtime.RuntimeInstance.parse
(RuntimeInstance.java:1341)
at org.apache.velocity.runtime.RuntimeSingleton.parse
(RuntimeSingleton.java:266)
at
org.apache.maven.archetype.ui.generation.DefaultArchetypeGenerationConfigurator$RequiredPropertyComparator.computePropertyReferences
(DefaultArchetypeGenerationConfigurator.java:338)
at
org.apache.maven.archetype.ui.generation.DefaultArchetypeGenerationConfigurator$RequiredPropertyComparator.<init>
(DefaultArchetypeGenerationConfigurator.java:302)
at
org.apache.maven.archetype.ui.generation.DefaultArchetypeGenerationConfigurator.configureArchetype
(DefaultArchetypeGenerationConfigurator.java:151)
at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute
(CreateProjectFromArchetypeMojo.java:193)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo
(DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2
(MojoExecutor.java:342)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute
(MojoExecutor.java:330)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute
(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute
(MojoExecutor.java:175)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000
(MojoExecutor.java:76)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run
(MojoExecutor.java:163)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute
(DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute
(MojoExecutor.java:160)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
(LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject
(LifecycleModuleBuilder.java:73)
at
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build
(SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute
(LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced
(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch
(Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode
(Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main
(Launcher.java:347)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please
read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
{code}
As you can see, the error states: "Caused by:
org.apache.velocity.runtime.parser.TemplateParseException: Encountered "-name}"
at artifactId.default[line 1, column 12]" which is caused by the parameter
"component-name" which is not parsed correctly.
As a test, I tried to modify all instances of this parameter in my entire
project to "componentName" and execute again the archetype:generate, but the
error now was: "Caused by:
org.apache.velocity.runtime.parser.TemplateParseException: Encountered "-app}"
at artifactId.default[line 1, column 12]", suggesting that the next parameter
"acronym-app" is not parsed.
You mentioned there is a compatibility configurator, but I fail to understand
how can I trigger the backwards compatibility in the plugin. At least, I could
not find a way to tell the plugin that I want to run it with backwards
compatibility.
Thanks again for you time
> Incompatibities with Velocity in Archetypes
> -------------------------------------------
>
> Key: ARCHETYPE-688
> URL: https://issues.apache.org/jira/browse/ARCHETYPE-688
> Project: Maven Archetype
> Issue Type: Bug
> Components: Archetypes, Generator, Plugin
> Affects Versions: 3.3.0
> Reporter: Javid
> Priority: Major
>
> Hello,
> I am having an issue caused by the new version of the
> maven-archetype-plugin:3.3.0 related with the recent upgrade of velocity 1.7
> to velocity 2.3.
> As it is reported in the [Velocity
> configuration|https://velocity.apache.org/engine/2.3/upgrading.html#vtl-changes_1],
> from version 1.7 to version 2+, the use of hyphens have changed and now they
> are not supported in parameters, causing errors.
> To avoid this, there is a property that allow backwards compatibility
> [detailed
> here|https://velocity.apache.org/engine/2.3/configuration.html#backward-compatibility],
> but I believe there is no way to tell maven-archetype-plugin to allow this
> compatibility in the configuration.
> I have a very complex project that uses hyphens in multiple instances and
> now, it is impossible to generate a project with the new archetype:3.3.0
> version.
> My problem is that changing the hyphen will cause a major impact in some
> other projects that rely on this archetype, so it is not a viable option for
> me to do.
> Could it be possible for you to include a way to modify Velocity
> configuration in maven-archetype-plugin:3.3.0? This would be extremely
> helpful so we can keep up with the future updates
> Thanks in advance!
--
This message was sent by Atlassian Jira
(v8.20.10#820010)