Hi Peter,

I would consider this as a Maven Archetype issue.
Regarding the properties, the MavenSession has a deprecated method getExecutionProperties(), which is split up into getSystemProperties() and getUserProperties(). When using the Invoker it doesn't make sense to add SystemProperties (again), userProperties (-Dkey=value entries) should be enough. But it could be I missed a usecase, which also implies there are not enough integration tests.

AFAIK we're never creating a new ProjectBuildingRequest, we should be using the original or a clone of it, so the suggestion to set both types of properties seems weird.

If you can create a JIRA issue for ARCHETYPE with a small integration test for the plugin, it shouldn't be so hard to fix it.

thanks,
Robert

On Mon, 13 Feb 2017 16:35:18 +0100, Petar Tahchiev <[email protected]> wrote:

Hi guys,

I'm writing here to ask what I have found is a bug or not. I have a project and I want to create an archetype out of it. So I use the following command:

mvn archetype:create-from-project
-Darchetype.properties=src/main/resources/archetype.properties

It used to work fine with maven-archetype<=2.4 but now with 3.0 it fails
with:

Caused by: org.apache.maven.plugin.MojoFailureException: Error reading
parent POM of project: com.nemesis:bom:1.5.0.BUILD-SNAPSHOT
    at
org.apache.maven.archetype.mojos.CreateArchetypeFromProjectMojo.execute(CreateArchetypeFromProjectMojo.java:269)
    at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)

I started debugging and I found out that the problem is in this commit:

https://github.com/apache/maven-archetype/commit/624f9affdc27c8efe6443e03e89259dbe51d08dd

which migrates the plugin to Maven3.

Furthermore debugging and stacktrace analysis revealed this:


*[ERROR] Failed to determine Java version for profile doclint-java8-disable
@ org.jboss:jboss-parent:19,
/home/petar/.m2/repository/org/jboss/jboss-parent/19/jboss-parent-19.pom,
line 746, column 15*
and indeed inside my parent pom.xml I have included the jboss bom like this:

            <dependency>
                <groupId>org.drools</groupId>
                <artifactId>drools-bom</artifactId>
                <type>pom</type>
                <version>${drools.version}</version>
                <scope>import</scope>
            </dependency>

which has a parent the jboss-parent.

Now if you debug further more in the maven-archetype-plugin you will see
here:

https://github.com/apache/maven-archetype/blob/master/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java#L439

we create a new DefaultProjectBuildingRequest and don't set any system
properties to it
so it eventually gets passed down to maven-core which cannot find
"java.version"
system property (because there are no properties passed) and it adds the
error that I see.

Now I have a several questions: why have we left the ProjectBuildingRequest
without system properties? Also the ProjectBuildingRequest has no
userProperties set - is this OK? I can fix the system properties with:

buildingRequest.setSystemProperties( System.getProperties() );
buildingRequest.setUserProperties( configurationProperties );

but is this correct?


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to