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

WINDUPRULE-604 fix xml-moved-components-00014 #455

Merged
merged 1 commit into from Jun 11, 2020

Conversation

johnpoth
Copy link
Contributor

https://issues.redhat.com/browse/WINDUPRULE-604

to run tests: mvn -DrunTestsMatching=xml-moved-components clean test

Thanks!

@jonathanvila
Copy link
Member

@johnpoth please could you rebase master into this PR ? thank you

@johnpoth
Copy link
Contributor Author

@jonathanvila done, thanks!

<xmlfile as="dependencies" in="pom.xml"
matches="/m:project/m:dependencies/m:dependency/m:artifactId[text()='camel-main']">
<namespace prefix="m" uri="http://maven.apache.org/POM/4.0.0"/>
</xmlfile>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implicit AND with a NOT will produce false negatives.
Please check this issue and comment in order to refactor the rule : https://issues.redhat.com/browse/WINDUPRULE-608?focusedCommentId=14149760&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14149760

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jonathanvila , thanks for reviewing!

I've changed it to the way you indicated but the rule now fails to trigger. Any Ideas?

<rule id="xml-moved-components-00014">
            <when>
                <javaclass references="org.apache.camel.main.Main" as="javaClass">
                    <location>IMPORT</location>
                </javaclass>
            </when>
            <perform>
                <iteration over="javaClass">
                    <when>
                        <not>
                            <xmlfile as="dependencies" in="pom.xml"
                                     matches="/m:project/m:dependencies/m:dependency/m:artifactId[text()='camel-main']">
                                <namespace prefix="m" uri="http://maven.apache.org/POM/4.0.0"/>
                            </xmlfile>
                        </not>
                    </when>
                    <perform>
                        <hint title="`org.apache.camel.main.Main` class has been moved" effort="1" category-id="mandatory">
                            <message>The class `org.apache.camel.main.Main` has been moved out of `org.apache.camel:camel-core` and into its own JAR named `org.apache.camel:camel-main`.
                                `org.apache.camel:camel-main` has to be added as a dependency to your project pom.xml file
                            </message>
                            <link href="https://camel.apache.org/manual/latest/camel-3-migration-guide.html#_main_class"
                                  title="Camel 3 - Main class"/>
                        </hint>
                    </perform>
                </iteration>
            </perform>
        </rule>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathanvila using the project tags instead of xmlfile seems to work. Push and rebased. Thanks!

@jonathanvila
Copy link
Member

LGTM 👍

@jonathanvila jonathanvila merged commit bd00431 into windup:master Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants