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

Duplicated tag: 'exclusions' #637

Open
gounthar opened this issue Jan 14, 2025 · 3 comments
Open

Duplicated tag: 'exclusions' #637

gounthar opened this issue Jan 14, 2025 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@gounthar
Copy link
Collaborator

gounthar commented Jan 14, 2025

Plugin Modernizer version

plugin modernizer 999999-SNAPSHOT (2025-01-14T12:55:12Z)

What Operating System are you using

Debian Bookworm under WSL2.

Reproduction steps

java -jar plugin-modernizer-cli/target/jenkins-plugin-modernizer-999999-SNAPSHOT.jar run --plugins antexec --recipe ReplaceLibrariesWithApiPlugin

I have not found the logs yet, but I went to ~/.cache/jenkins-plugin-modernizer-cli/antexec/sources and issued mvn install.

mvn install
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-parseable POM /home/poddingue/.cache/jenkins-plugin-modernizer-cli/antexec/sources/pom.xml: Duplicated tag: 'exclusions' (position: START_TAG seen ...</exclusions>\n      <exclusions>... @83:19)  @ line 83, column 19
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project  (/home/poddingue/.cache/jenkins-plugin-modernizer-cli/antexec/sources/pom.xml) has 1 error
[ERROR]     Non-parseable POM /home/poddingue/.cache/jenkins-plugin-modernizer-cli/antexec/sources/pom.xml: Duplicated tag: 'exclusions' (position: START_TAG seen ...</exclusions>\n      <exclusions>... @83:19)  @ line 83, column 19 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException

Expected Results

Build successful.

@gounthar
Copy link
Collaborator Author

I was not able to attach the pom.xml as a file, so here it is:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.jenkins-ci.plugins</groupId>
        <artifactId>plugin</artifactId>
        <version>5.5</version>
        <relativePath />
    </parent>
    <artifactId>antexec</artifactId>
    <version>${changelist}</version>
    <packaging>hpi</packaging>
    <properties>
        <changelist>999999-SNAPSHOT</changelist>
        <gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
        <jenkins.baseline>2.479</jenkins.baseline>
        <jenkins.version>${jenkins.baseline}.1</jenkins.version>
    </properties>
    <name>AntExec</name>
    <description>Adds new build step for running directly written Apache Ant code</description>
    <url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>

    <developers>
        <developer>
            <id>svasek</id>
            <name>Milos Svasek</name>
            <email>[email protected]</email>
            <timezone>+1</timezone>
        </developer>
    </developers>

    <licenses>
        <license>
            <name>The MIT license</name>
            <comments>All source code is under the MIT license.</comments>
            <url>https://opensource.org/licenses/MIT</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:https://github.com/${gitHubRepo}.git</connection>
        <developerConnection>scm:git:https://github.com/${gitHubRepo}.git</developerConnection>
        <url>https://github.com/${gitHubRepo}</url>
        <tag>${scmTag}</tag>
    </scm>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.jenkins.tools.bom</groupId>
                <artifactId>bom-${jenkins.baseline}.x</artifactId>
                <version>3893.v213a_42768d35</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <groupId>org.jenkins-ci.tools</groupId>
                <artifactId>maven-hpi-plugin</artifactId>
                <version>3.16</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
    <dependency>
      <groupId>io.jenkins.plugins</groupId>
      <artifactId>asm-api</artifactId>
    </dependency>
    <dependency>
      <groupId>io.jenkins.plugins</groupId>
      <artifactId>json-path-api</artifactId>
      <exclusions>
        <exclusion>
          <!-- brought in by io.jenkins.plugins:asm-api -->
          <groupId>org.ow2.asm</groupId>
          <artifactId>asm</artifactId>
        </exclusion>
      </exclusions>
      <exclusions>
        <exclusion>
          <!-- brought in by io.jenkins.plugins:asm-api -->
          <groupId>org.ow2.asm</groupId>
          <artifactId>asm-commons</artifactId>
        </exclusion>
      </exclusions>
      <exclusions>
        <exclusion>
          <!-- brought in by io.jenkins.plugins:asm-api -->
          <groupId>org.ow2.asm</groupId>
          <artifactId>asm-analysis</artifactId>
        </exclusion>
      </exclusions>
      <exclusions>
        <exclusion>
          <!-- brought in by io.jenkins.plugins:asm-api -->
          <groupId>org.ow2.asm</groupId>
          <artifactId>asm-util</artifactId>
        </exclusion>
      </exclusions>
      <exclusions>
        <exclusion>
          <!-- brought in by io.jenkins.plugins:asm-api -->
          <groupId>org.ow2.asm</groupId>
          <artifactId>asm-tree</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
        <dependency>
            <groupId>org.jenkins-ci.plugins</groupId>
            <artifactId>ant</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jenkins-ci.plugins</groupId>
            <artifactId>token-macro</artifactId>
      <exclusions>
        <exclusion>
          <!-- brought in by io.jenkins.plugins:json-path-api -->
          <groupId>com.jayway.jsonpath</groupId>
          <artifactId>json-path</artifactId>
        </exclusion>
      </exclusions>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/webapp</directory>
                <targetPath>${project.build.directory}/${project.artifactId}</targetPath>
                <filtering>true</filtering>
                <includes>
                    <include>version.txt</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>ant-contrib</groupId>
                                    <artifactId>ant-contrib</artifactId>
                                    <version>1.0b3</version>
                                    <type>jar</type>
                                    <outputDirectory>${project.build.directory}/${project.artifactId}/META-INF/lib
                                    </outputDirectory>
                                    <destFileName>ant-contrib.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jenkins-ci.tools</groupId>
                <artifactId>maven-hpi-plugin</artifactId>
                <configuration>
                    <minimumJavaVersion>17</minimumJavaVersion>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <configuration>
                    <goals>deploy</goals>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>repo.jenkins-ci.org</id>
            <url>https://repo.jenkins-ci.org/public/</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>repo.jenkins-ci.org</id>
            <url>https://repo.jenkins-ci.org/public/</url>
        </pluginRepository>
    </pluginRepositories>
</project>

@nagu165
Copy link
Contributor

nagu165 commented Jan 15, 2025

Hello sir, I've verified the issue locally and the issue seems to be that exclusion tags were not grouped together under one exclusions tag.
Build was successful after modifying the pom:
Screenshot 2025-01-15 092854

@jonesbusy
Copy link
Collaborator

Probably upstream issue from rewrite-jenkins

https://github.com/openrewrite/rewrite-jenkins/blob/main/src/main/java/org/openrewrite/jenkins/ReplaceLibrariesWithApiPlugin.java#L131-L158

My though it to implement this recipe on plugin-modernizer-tool and fix it there

  1. Move it on plugin-modernizer-tool
  2. Update recipes.yml to use new package
  3. Write a RewriteTest that reproduce the issue
  4. Fix it

My though is that we also do not need to add exclusion for api plugin and only standard dependencies. Since it's the goal of API plugin to bring a dependency to the consumer.

In case of json-api plugin that also depends on asm-api it doesn't make any sense to add this exclusion.

@jonesbusy jonesbusy added the help wanted Extra attention is needed label Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants