Skip to content

Commit

Permalink
#366 <skip> and -Djapicmp.skip work
Browse files Browse the repository at this point in the history
  • Loading branch information
siom79 committed Nov 3, 2023
1 parent a644096 commit e08688f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ public class JApiCmpMojo extends AbstractMojo {
private List<Dependency> oldClassPathDependencies;
@org.apache.maven.plugins.annotations.Parameter(required = false)
private List<Dependency> newClassPathDependencies;
@org.apache.maven.plugins.annotations.Parameter(property = "japicmp.skip", required = false)
@org.apache.maven.plugins.annotations.Parameter(defaultValue = "false")
private boolean skip;
@org.apache.maven.plugins.annotations.Parameter(property = "japicmp.skip", defaultValue = "false")
private boolean skipExec;
@org.apache.maven.plugins.annotations.Parameter(property = "japicmp.skipXmlReport", required = false)
private boolean skipXmlReport;
@org.apache.maven.plugins.annotations.Parameter(property = "japicmp.skipHtmlReport", required = false)
Expand Down Expand Up @@ -104,7 +106,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
MavenParameters mavenParameters = new MavenParameters(this.artifactRepositories,
this.mavenProject, this.mojoExecution, this.versionRangeWithProjectVersion, this.repoSystem, this.repoSession,
this.remoteRepos);
PluginParameters pluginParameters = new PluginParameters(this.skip, this.newVersion, this.oldVersion, this.parameter, this.dependencies, Optional.of(
PluginParameters pluginParameters = new PluginParameters(this.skipExec || this.skip, this.newVersion, this.oldVersion, this.parameter, this.dependencies, Optional.of(
this.projectBuildDir), Optional.<String>absent(), true, this.oldVersions, this.newVersions, this.oldClassPathDependencies,
this.newClassPathDependencies);
executeWithParameters(pluginParameters, mavenParameters);
Expand Down Expand Up @@ -185,8 +187,6 @@ private void setUpOverrideCompatibilityChanges(JarArchiveComparatorOptions compa
}
}



private boolean skipModule(PluginParameters pluginParameters, MavenParameters mavenParameters) {
SkipModuleStrategy skipModuleStrategy = new SkipModuleStrategy(pluginParameters, mavenParameters, getLog());
return skipModuleStrategy.skip();
Expand All @@ -197,7 +197,6 @@ private enum ConfigurationVersion {
}

private static DefaultArtifact createDefaultArtifact(MavenProject mavenProject, String version) {

org.apache.maven.artifact.Artifact artifact = mavenProject.getArtifact();
return createDefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getType(), version);
}
Expand Down
31 changes: 31 additions & 0 deletions japicmp-testbase/japicmp-test-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,37 @@
</dependencies>
</configuration>
</execution>
<execution>
<id>skip</id>
<phase>pre-integration-test</phase>
<goals>
<goal>cmp</goal>
</goals>
<configuration>
<skip>true</skip>
<oldVersion>
<dependency>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-test-v1</artifactId>
<version>${project.version}</version>
</dependency>
</oldVersion>
<newVersion>
<dependency>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-test-v2</artifactId>
<version>${project.version}</version>
</dependency>
</newVersion>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.4</version>
</dependency>
</dependencies>
</configuration>
</execution>
</executions>
</plugin>
<!-- run site plugin to build reports during 'pre-integration-test' phase
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package japicmp.test;

import org.junit.Test;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

public class ITSkip {

@Test
public void testXmlReportNotGenerated() throws IOException {
assertThat(Files.exists(Paths.get(System.getProperty("user.dir"), "target", "japicmp", "skip.html")), is(false));
}

@Test
public void testHtmlReportNotGenerated() throws IOException {
assertThat(Files.exists(Paths.get(System.getProperty("user.dir"), "target", "japicmp", "skip.xml")), is(false));
}

@Test
public void testDiffReportGenerated() throws IOException {
assertThat(Files.exists(Paths.get(System.getProperty("user.dir"), "target", "japicmp", "skip.diff")), is(false));
}
}

0 comments on commit e08688f

Please sign in to comment.