Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsonpath-maven-plugin is not displaying in maven-antrun-plugin version 1.8 #3

Open
shivajithanneeru opened this issue Nov 7, 2019 · 13 comments

Comments

@shivajithanneeru
Copy link

@shivajithanneeru shivajithanneeru commented Nov 7, 2019

The property returned from jsonpath-maven-plugin is not displaying in maven-antrun-plugin version 1.8. It works fine if the version of maven-antrun-plugin is 1.3

pom.xml file:

4.0.0
com.mycompany.app
my-module
1



ca.szc.maven
jsonpath-maven-plugin
1.0.0


read-properties
prepare-package

set-properties


package.json

$.subComponentDetails[0].upgradeVersion
$.subComponentDetails[0].componentName






org.apache.maven.plugins
maven-antrun-plugin
1.8


update-ppdm-package-json
prepare-package

run



$${vsoVersion}






@shivajithanneeru

This comment has been minimized.

Copy link
Author

@shivajithanneeru shivajithanneeru commented Nov 7, 2019

The property returned from jsonpath-maven-plugin is not displaying in maven-antrun-plugin version 1.8. It works fine if the version of maven-antrun-plugin is 1.3

<project> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.app</groupId> <artifactId>my-module</artifactId> <version>1</version> <build> <plugins> <plugin> <groupId>ca.szc.maven</groupId> <artifactId>jsonpath-maven-plugin</artifactId> <version>1.0.0</version> <executions> <execution> <id>read-properties</id> <phase>prepare-package</phase> <goals> <goal>set-properties</goal> </goals> <configuration> <file>package.json</file> <properties> <vsoVersion>$.subComponentDetails[0].upgradeVersion</vsoVersion> <componentName>$.subComponentDetails[0].componentName</componentName> </properties> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.8</version> <executions> <execution> <id>update-ppdm-package-json</id> <phase>prepare-package</phase> <goals> <goal>run</goal> </goals> <configuration> <target> <echo>"${vsoVersion}"</echo> </target> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>

@ASzc

This comment has been minimized.

Copy link
Owner

@ASzc ASzc commented Nov 7, 2019

That is weird.

I notice that you're binding the executions of both plugins to the prepare-package phase. In theory maven is supposed to execute such executions in the order they're defined in the POM, but I'd recommend trying to use different phases.

prepare-package phase is unusually late for the set-properties goal. Try reading it in the phase the package.json is generated in, or if package.json is part of the sources, use the initialize phase.

@shivajithanneeru

This comment has been minimized.

Copy link
Author

@shivajithanneeru shivajithanneeru commented Nov 9, 2019

No luck even I used the jsonpath-maven-plugin in prepare-package and maven-antrun-plugin version in package phase.
maven-antrun-plugin version 1.8 is unable to receive the properties from jsonpath-maven-plugin

@ASzc

This comment has been minimized.

Copy link
Owner

@ASzc ASzc commented Nov 9, 2019

I determined that it is just the ant plugin doing this, as help:evaluate is ok with the property set by jsonpath-maven-plugin:set-properties.

I also determined that it is due to a bug in maven-antrun-plugin. Since 1.8, it only passes along properties that are in mavenProject.getProperties(), which does not include properties set by other maven plugins, as jsonpath-maven-plugin does here in session.getUserProperties().

MANTRUN-178 introduced this bug. I will file an issue and try to make a pull request to fix this bug.

The only workaround I think is to use a version less than 1.8 for the time being. I tried forcing the property in there with a property task, but it doesn't work.

Here's my MWE:

pom.xml:

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycompany.app</groupId>
    <artifactId>my-module</artifactId>
    <version>1</version>
    <properties>
        <version.static>1.2.3</version.static>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>ca.szc.maven</groupId>
                <artifactId>jsonpath-maven-plugin</artifactId>
                <version>1.0.0</version>
                <executions>
                    <execution>
                        <id>read-properties</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>set-properties</goal>
                        </goals>
                        <configuration>
                            <file>package.json</file>
                            <properties>
                                <vsoVersion>$.version</vsoVersion>
                            </properties>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-help-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>echo</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>evaluate</goal>
                        </goals>
                        <configuration>
                            <expression>vsoVersion</expression>
                        </configuration>
                    </execution>
                    <execution>
                        <id>echo-static</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>evaluate</goal>
                        </goals>
                        <configuration>
                            <expression>version.static</expression>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <id>update-ppdm-package-json</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <echo>"${vsoVersion}"</echo>
                                <echo>"${version.static}"</echo>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

package.json:

{
    "version": "3.2.1"
}
@ASzc

This comment has been minimized.

Copy link
Owner

@ASzc ASzc commented Nov 9, 2019

@shivajithanneeru

This comment has been minimized.

Copy link
Author

@shivajithanneeru shivajithanneeru commented Nov 9, 2019

Thanks

@shivajithanneeru

This comment has been minimized.

Copy link
Author

@shivajithanneeru shivajithanneeru commented Nov 9, 2019

I approved your PR on maven-antrun-plugin

@ASzc

This comment has been minimized.

Copy link
Owner

@ASzc ASzc commented Nov 10, 2019

Another workaround might be to specify the property with any value in the pom. This would put it in the list that antrun will iterate through when it copies. Unsure which value will take precedence.

<properties>
    <vsoVersion></vsoVersion>
</properties>
@shivajithanneeru

This comment has been minimized.

Copy link
Author

@shivajithanneeru shivajithanneeru commented Nov 11, 2019

Nope. It doesn't work.
[INFO] --- maven-antrun-plugin:1.3:run (Display) @ my-module --- [INFO] Executing tasks [echo] "" [INFO] Executed tasks

@shivajithanneeru

This comment has been minimized.

Copy link
Author

@shivajithanneeru shivajithanneeru commented Nov 13, 2019

Hi @ASzc,
I appreciate all your help in figuring out the bug in maven-antrun-plugin and creating PR for it.
Can you please let me know, when will the PR got merged to master?

@ASzc

This comment has been minimized.

Copy link
Owner

@ASzc ASzc commented Nov 13, 2019

I can update you when it happens, sure. It might be more reliable to press subscribe on the PR comment thread though.

I can't predict when it will be merged unfortunately. I don't think a speedy turnaround is likely, based on the reaction I've seen so far, and the fact maven-antrun-plugin isn't very actively developed.

@shivajithanneeru

This comment has been minimized.

Copy link
Author

@shivajithanneeru shivajithanneeru commented Nov 21, 2019

Hi @ASzc , Any update on the PR you submitted?

@ASzc

This comment has been minimized.

Copy link
Owner

@ASzc ASzc commented Nov 22, 2019

I pinged the PMC chair, will see if that creates any movement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.