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

Run report with different configurations #320

Open
davidnewcomb opened this issue Feb 11, 2022 · 4 comments
Open

Run report with different configurations #320

davidnewcomb opened this issue Feb 11, 2022 · 4 comments

Comments

@davidnewcomb
Copy link

I have written a groovy script that reduces all the changes down to only report changes across our 'special' annotations given our rules. This is all working.
A new requirement has come in to split the report into three: one for the public interfaces, one for the internal interfaces and the original one with everything. These 3 reports will go to different teams.

In the groovy script I have this at the top:

REPORT_PUBLIC = true
REPORT_SEMI = true

I am wondering what options are available to help? The simplest solution would be to make 3 copies of the groovy script one with true/true, one with true/false and one with false/true. Then have 3 separate maven plugin declarations each with a different html-path so they don't overwrite each other.

The docs mentions you can have extra executions so the output base name is based on the execution id, so can I pass parameters into the main script from the execution block to get my 3 different reports.

Or maybe trying to pass -Dblar=semi then read it with System.getenv() inside the script.

I'm just looking for a bit of advice on a cleaner way of doing this?

@davidnewcomb
Copy link
Author

I have tried it with 3 different plugin blocks, referencing the 3 copies of the script (with different params hardcoded). I have added to the executions block and that prevents the report output names from clashing within the same target folder. I still have a lot of duplication here that I'd like to clean up if possible.

@siom79
Copy link
Owner

siom79 commented Feb 11, 2022

You can define different executions with different ids:

<plugin>
        <groupId>com.github.siom79.japicmp</groupId>
        <artifactId>japicmp-maven-plugin</artifactId>
        <version>0.15.6</version>
        <configuration>
          <oldVersion>
            <file>
              <path>${project.build.directory}/${project.artifactId}-${project.version}.${project.packaging}</path>
            </file>
          </oldVersion>
          <newVersion>
            <file>
              <path>${project.build.directory}/${project.artifactId}-${project.version}.${project.packaging}</path>
            </file>
          </newVersion>
          <parameter>
            <!-- see documentation -->
          </parameter>
        </configuration>
        <executions>
          <execution>
            <id>conf1</id>
            <phase>verify</phase>
            <goals>
              <goal>cmp</goal>
            </goals>
            <configuration>
              <postAnalysisScript>${project.basedir}/src/main/groovy/postAnalysisScript.groovy</postAnalysisScript>
            </configuration>
          </execution>
          <execution>
            <id>conf2</id>
            <phase>verify</phase>
            <goals>
              <goal>cmp</goal>
            </goals>
            <configuration>
              <postAnalysisScript>${project.basedir}/src/main/groovy/postAnalysisScript.groovy</postAnalysisScript>
            </configuration>
          </execution>
        </executions>
      </plugin>

In this example I get two different files:

[INFO] --- japicmp-maven-plugin:0.15.6:cmp (conf1) @ test ---
[INFO] Written file '/home/boxuser/dev/kvletl/test/target/japicmp/conf1.diff'.
[INFO] Written file '/home/boxuser/dev/kvletl/test/target/japicmp/conf1.xml'.
[INFO] Written file '/home/boxuser/dev/kvletl/test/target/japicmp/conf1.html'.
[INFO] 
[INFO] --- japicmp-maven-plugin:0.15.6:cmp (conf2) @ test ---
[INFO] Written file '/home/boxuser/dev/kvletl/test/target/japicmp/conf2.diff'.
[INFO] Written file '/home/boxuser/dev/kvletl/test/target/japicmp/conf2.xml'.
[INFO] Written file '/home/boxuser/dev/kvletl/test/target/japicmp/conf2.html'.

@davidnewcomb
Copy link
Author

Yes, that kind of thing! That solves half the problem.

If there was something like the following which added "myparam" to the environment or something that would be perfect. I'm just thinking allowed here. Are there any facilities like this?

<configuration>
     <postAnalysisScript>${project.basedir}/src/main/groovy/postAnalysisScript.groovy</postAnalysisScript>
     <postAnalysisScriptParameters>
          <postAnalysisScriptParameter>myparam=semi<postAnalysisScriptParameter>
     </postAnalysisScriptParameters>
</configuration>

@davidnewcomb
Copy link
Author

Just for anyone following, those parameters are contained within configuration->parameter block. Like so:

<configuration>
   <parameter>
      <postAnalysisScript>${project.basedir}/src/main/groovy/postAnalysisScript.groovy</postAnalysisScript>
   </parameter>
</configuration>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants