siom79 / japicmp

Comparison of two versions of a jar archive
https://siom79.github.io/japicmp
Apache License 2.0
694 stars 107 forks source link

>=0.16.0: Cannot compare versions because the number of old versions is different than the number of new versions #359

Open lalithaawgu opened 1 year ago

lalithaawgu commented 1 year ago

I am configuring a multimodule maven project to use the maven plugin. But I see this error when i specify 4 jars in to compare against 4 jars in If i skip entirely build succeeds but doesnt report missing classes. This seems to be an issue only with v0.16.0 onwards, doesnt happen in v0.15.7.

Is it possible to compare oldVersion artifact(does NOT pull the classpath dependencies ) against the newVersion classpath dependencies(is pulled in automatically which is good)

Caused by: japicmp.exception.JApiCmpException: Cannot compare versions because the number of old versions is different than the number of new versions.

com.github.siom79.japicmp japicmp-maven-plugin 0.16.0

siom79 commented 1 year ago

Can you post the configuration of the maven plugin? Looks like you are using the option breakBuildBasedOnSemanticVersioningForMajorVersionZero?

lalithaawgu commented 1 year ago

Successful with 0.15.7.

<configuration>
  <newVersions>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>${project.artifactId}</artifactId>
      <version>${project.version}</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>group1</groupId>
      <artifactId>artifact1</artifactId>
      <version>2.3.7</version>
    </dependency>
    <dependency>
      <groupId>group2</groupId>
      <artifactId>artifact2</artifactId>
      <version>0.2.7</version>
    </dependency>
    <dependency>
      <groupId>group3</groupId>
      <artifactId>artifact3</artifactId>
      <version>0.2.7</version>
    </dependency>
  </newVersions>
  <oldVersions>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>${project.artifactId}</artifactId>
      <version>2.4.8.RELEASE</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>group1</groupId>
      <artifactId>artifact1</artifactId>
      <version>2.3.3</version>
    </dependency>
    <dependency>
      <groupId>group2</groupId>
      <artifactId>artifact2</artifactId>
      <version>0.2.6</version>
    </dependency>
    <dependency>
      <groupId>group3</groupId>
      <artifactId>artifact3</artifactId>
      <version>0.2.6
      </version>
    </dependency>
  </oldVersions>
  <parameter>
    <onlyBinaryIncompatible>true</onlyBinaryIncompatible>
    <breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
    <breakBuildBasedOnSemanticVersioning>true</breakBuildBasedOnSemanticVersioning>
    <skipXmlReport>true</skipXmlReport>
    <skipPomModules>true</skipPomModules>
    <ignoreMissingOptionalDependency>false</ignoreMissingOptionalDependency>
    <ignoreNonResolvableArtifacts>false</ignoreNonResolvableArtifacts>
    <ignoreMissingClassesByRegularExpressions>
      <ignoreMissingClassesByRegularExpression>^((?!host1\.host2).)*$</ignoreMissingClassesByRegularExpression>
    </ignoreMissingClassesByRegularExpressions>
    <overrideCompatibilityChangeParameters>
      <overrideCompatibilityChangeParameter>
        <compatibilityChange>CONSTRUCTOR_REMOVED</compatibilityChange>
        <binaryCompatible>true</binaryCompatible>
        <sourceCompatible>false</sourceCompatible>
        <semanticVersionLevel>MINOR</semanticVersionLevel>
      </overrideCompatibilityChangeParameter>
    </overrideCompatibilityChangeParameters>
  </parameter>
</configuration>

Thanks!

martinaldrin commented 7 months ago

We have same issue, we can not uplift to 0.16.0 or any newer version. we are stuck on 0.15.7. We have a multi module project with 40 modules and we only include the modules that have been modified during the test with the -pl option.

mvn com.github.siom79.japicmp:japicmp-maven-plugin:cmp -Pnbc -pl <moduleName> -Doldversion=<old version> This is our profile

 <profile>
            <id>nbc</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.siom79.japicmp</groupId>
                        <artifactId>japicmp-maven-plugin</artifactId>
                        <version>${japicmp.maven.plugin.version}</version>
                        <configuration>
                            <oldVersion>
                                <dependency>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>${project.artifactId}</artifactId>
                                    <version>${oldversion}</version>
                                    <type>jar</type>
                                </dependency>
                            </oldVersion>
                            <parameter>
                                <onlyModified>true</onlyModified>
                                <includes>
                                    <include>com......</include>
                                    <include>com.....</include>
                                    <include>com......</include>
                                </includes>
                                <excludes>
                                    <exclude>com......</exclude>
                                    <exclude>com.....</exclude>
                                </excludes>
                                <accessModifier>public</accessModifier>
                                <breakBuildOnModifications>false</breakBuildOnModifications>
                                <breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
                                <breakBuildOnSourceIncompatibleModifications>true</breakBuildOnSourceIncompatibleModifications>
                                <onlyBinaryIncompatible>false</onlyBinaryIncompatible>
                                <includeSynthetic>false</includeSynthetic>
                                <ignoreMissingClasses>false</ignoreMissingClasses>
                                <skipPomModules>true</skipPomModules>
                                <overrideCompatibilityChangeParameters>
                                    <overrideCompatibilityChangeParameter>
                                        <compatibilityChange>METHOD_ADDED_TO_INTERFACE</compatibilityChange>
                                        <binaryCompatible>true</binaryCompatible>
                                        <sourceCompatible>true</sourceCompatible>
                                    </overrideCompatibilityChangeParameter>
                                    <overrideCompatibilityChangeParameter>
                                        <compatibilityChange>METHOD_ADDED_TO_PUBLIC_CLASS</compatibilityChange>
                                        <binaryCompatible>true</binaryCompatible>
                                        <sourceCompatible>true</sourceCompatible>
                                    </overrideCompatibilityChangeParameter>
                                    <overrideCompatibilityChangeParameter>
                                        <compatibilityChange>METHOD_ABSTRACT_ADDED_TO_CLASS</compatibilityChange>
                                        <binaryCompatible>true</binaryCompatible>
                                        <sourceCompatible>true</sourceCompatible>
                                    </overrideCompatibilityChangeParameter>
                                </overrideCompatibilityChangeParameters>
                            </parameter>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>cmp</goal>
                                </goals>
                                <phase>verify</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
siom79 commented 5 months ago

Have you tried a new version like 0.18.5? In these versions the code throwing the Cannot compare versions because the number of old versions is different than the number of new versions. does no longer exist.