Hi Robert,

this:

````
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.
````
is not true:

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

You can clearly see that if the project.getParent() != null a new
DefaultProjectBuildingRequest(); is created and that new request is missing
the system properties and the user-specified properties.

As suggested I have opened a ticket here:
https://issues.apache.org/jira/browse/ARCHETYPE-518

Also, again, as suggested I have just committed a test-case inside
DefaultArchetypeCreatorIT#testSystemPropertiesAreIncluded

At the moment that test fails with null-pointer exception because the
archetype is using maven-core version 3.0 for its tests.

I've tested with both - with latest maven 3.5.x-SNAPSHOT - I get a
different kind of error
                              - with maven 3.0.4 i get the exact same
null-pointer as the test suggests.


Finally I have also committed 2 lines inside FilesetArchetypeCreator to
resolve the issue:

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

Please let me know if you are OK with this.

Thank you.


2017-02-13 20:54 GMT+02:00 Robert Scholte <[email protected]>:

> 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.CreateArchetypeFromProjectM
>> ojo.execute(CreateArchetypeFromProjectMojo.java:269)
>>     at
>> org.apache.maven.plugin.DefaultBuildPluginManager.executeMoj
>> o(DefaultBuildPluginManager.java:134)
>>     at
>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(Moj
>> oExecutor.java:207)
>>
>> I started debugging and I found out that the problem is in this commit:
>>
>> https://github.com/apache/maven-archetype/commit/624f9affdc2
>> 7c8efe6443e03e89259dbe51d08dd
>>
>> 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/archet
>> ype-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]
>
>


-- 
Regards, Petar!
Karlovo, Bulgaria.
---
Public PGP Key at:
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x19658550C3110611
Key Fingerprint: A369 A7EE 61BC 93A3 CDFF  55A5 1965 8550 C311 0611

Reply via email to