You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/12/25 03:33:00 UTC
[commons-vfs] 10/20: maven-plugin: added parameter from CLI tool,
add local file path as old or new archive location;
java source and target level is now 1.7;
removed dependency to eclipse-aether API
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to annotated tag japicmp-base-0.1.0
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
commit 7af9e4952831788d8c8438c666ebc61a1042d0bd
Author: siom79 <ma...@googlemail.com>
AuthorDate: Sat Jun 21 19:18:15 2014 +0200
maven-plugin: added parameter from CLI tool, add local file path as old or new archive location; java source and target level is now 1.7; removed dependency to eclipse-aether API
---
japicmp-maven-plugin/pom.xml | 19 +-
.../main/java/japicmp/maven/ConfigurationFile.java | 13 +
.../src/main/java/japicmp/maven/JApiCmpMojo.java | 264 +++++++++++++++------
.../src/main/java/japicmp/maven/Parameter.java | 49 ++++
.../src/main/java/japicmp/maven/Version.java | 9 +
japicmp-testbase/japicmp-test-maven-plugin/pom.xml | 7 +
japicmp-testbase/japicmp-test-v2/pom.xml | 32 +++
japicmp/pom.xml | 4 -
japicmp/src/main/java/japicmp/cli/CliParser.java | 36 +--
japicmp/src/main/java/japicmp/config/Options.java | 24 ++
.../main/java/japicmp/model/AccessModifier.java | 13 +
pom.xml | 9 +-
12 files changed, 360 insertions(+), 119 deletions(-)
diff --git a/japicmp-maven-plugin/pom.xml b/japicmp-maven-plugin/pom.xml
index 8c9c796..f83a912 100644
--- a/japicmp-maven-plugin/pom.xml
+++ b/japicmp-maven-plugin/pom.xml
@@ -14,7 +14,6 @@
<properties>
<maven.version>3.1.0</maven.version>
- <aether.version>0.9.0.M2</aether.version>
</properties>
<prerequisites>
@@ -48,19 +47,19 @@
<version>${maven.version}</version>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-api</artifactId>
- <version>${aether.version}</version>
+ <groupId>japicmp</groupId>
+ <artifactId>japicmp</artifactId>
+ <version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.eclipse.aether</groupId>
- <artifactId>aether-util</artifactId>
- <version>${aether.version}</version>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>${maven.version}</version>
</dependency>
<dependency>
- <groupId>japicmp</groupId>
- <artifactId>japicmp</artifactId>
- <version>${project.version}</version>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-compat</artifactId>
+ <version>${maven.version}</version>
</dependency>
</dependencies>
diff --git a/japicmp-maven-plugin/src/main/java/japicmp/maven/ConfigurationFile.java b/japicmp-maven-plugin/src/main/java/japicmp/maven/ConfigurationFile.java
new file mode 100644
index 0000000..c5685cd
--- /dev/null
+++ b/japicmp-maven-plugin/src/main/java/japicmp/maven/ConfigurationFile.java
@@ -0,0 +1,13 @@
+package japicmp.maven;
+
+public class ConfigurationFile {
+ private String path;
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+}
diff --git a/japicmp-maven-plugin/src/main/java/japicmp/maven/JApiCmpMojo.java b/japicmp-maven-plugin/src/main/java/japicmp/maven/JApiCmpMojo.java
index 11b0582..e8b8c46 100644
--- a/japicmp-maven-plugin/src/main/java/japicmp/maven/JApiCmpMojo.java
+++ b/japicmp-maven-plugin/src/main/java/japicmp/maven/JApiCmpMojo.java
@@ -1,28 +1,31 @@
package japicmp.maven;
-import com.google.common.io.Files;
+import com.google.common.base.Optional;
import japicmp.cmp.JarArchiveComparator;
import japicmp.cmp.JarArchiveComparatorOptions;
import japicmp.config.Options;
+import japicmp.model.AccessModifier;
+import japicmp.model.JApiChangeStatus;
import japicmp.model.JApiClass;
import japicmp.output.stdout.StdoutOutputGenerator;
+import japicmp.output.xml.XmlOutputGenerator;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.factory.DefaultArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.DefaultMavenProjectBuilder;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
-import org.eclipse.aether.DefaultRepositorySystemSession;
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.aether.repository.LocalRepository;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.resolution.ArtifactRequest;
-import org.eclipse.aether.resolution.ArtifactResult;
+import org.apache.maven.settings.Settings;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.nio.charset.Charset;
import java.util.List;
/**
@@ -31,15 +34,22 @@ import java.util.List;
public class JApiCmpMojo extends AbstractMojo {
/**
* @parameter
+ * @required
*/
private Version oldVersion;
/**
* @parameter
+ * @required
*/
private Version newVersion;
/**
+ * @parameter
+ */
+ private Parameter parameter;
+
+ /**
* @parameter expression="${project.build.directory}"
* @required
*/
@@ -48,82 +58,202 @@ public class JApiCmpMojo extends AbstractMojo {
/**
* @component
*/
- private RepositorySystem repoSystem;
+ private ArtifactFactory artifactFactory;
+
+ /**
+ * @component
+ */
+ private ArtifactResolver artifactResolver;
+
+ /**
+ * @parameter default-value="${localRepository}"
+ */
+ private ArtifactRepository localRepository;
/**
- * @component default-value="${project.remoteProjectRepositories}"
+ * @parameter default-value="${project.remoteArtifactRepositories}"
*/
- private List<RemoteRepository> remoteRepos;
+ private List<ArtifactRepository> artifactRepositories;
+
+ /**
+ * The system settings for Maven. This is the instance resulting from
+ * merging global and user-level settings files.
+ *
+ * @parameter expression="${settings}"
+ * @readonly
+ * @required
+ */
+ private Settings settings;
public void execute() throws MojoExecutionException, MojoFailureException {
- File oldVersionFile = null;
- File newVersionFile = null;
- if (oldVersion != null) {
- Dependency dependency = oldVersion.getDependency();
- if (dependency != null) {
- String descriptor = dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion();
- getLog().debug("oldVersion: " + descriptor);
- oldVersionFile = resolveArtifact(descriptor);
+ File newVersionFile = retrieveFileFromConfiguration(newVersion, "newVersion");
+ File oldVersionFile = retrieveFileFromConfiguration(oldVersion, "oldVersion");
+ List<JApiClass> jApiClasses = compareArchives(newVersionFile, oldVersionFile);
+ if (projectBuildDir != null && projectBuildDir.exists()) {
+ try {
+ File jApiCmpBuildDir = createJapiCmpBaseDir();
+ Options options = createOptions();
+ String diffOutput = generateDiffOutput(newVersionFile, oldVersionFile, jApiClasses, options);
+ createFileAndWriteTo(diffOutput, jApiCmpBuildDir);
+ generateXmlOutput(newVersionFile, oldVersionFile, jApiClasses, jApiCmpBuildDir, options);
+ breakBuildIfNecessary(jApiClasses);
+ } catch (IOException e) {
+ throw new MojoFailureException(String.format("Failed to construct output directory: %s", e.getMessage()), e);
}
+ } else {
+ throw new MojoFailureException("Could not determine the location of the build directory.");
}
- if (newVersion != null) {
- Dependency dependency = newVersion.getDependency();
- if (dependency != null) {
- String descriptor = dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion();
- getLog().debug("newVersion: " + descriptor);
- newVersionFile = resolveArtifact(descriptor);
+ }
+
+ private void breakBuildIfNecessary(List<JApiClass> jApiClasses) throws MojoFailureException {
+ if(breakBuildOnModificationsParameter()) {
+ for(JApiClass jApiClass : jApiClasses) {
+ if(jApiClass.getChangeStatus() != JApiChangeStatus.UNCHANGED) {
+ throw new MojoFailureException(String.format("Breaking the build because there is at least one modified class: %s", jApiClass.getFullyQualifiedName()));
+ }
}
}
- if(oldVersionFile != null && newVersionFile != null) {
- JarArchiveComparatorOptions comparatorOptions = new JarArchiveComparatorOptions();
- JarArchiveComparator jarArchiveComparator = new JarArchiveComparator(comparatorOptions);
- List<JApiClass> jApiClasses = jarArchiveComparator.compare(oldVersionFile, newVersionFile);
- StdoutOutputGenerator stdoutOutputGenerator = new StdoutOutputGenerator();
- String output = stdoutOutputGenerator.generate(oldVersionFile, newVersionFile, jApiClasses, new Options());
- getLog().info(output);
- if(projectBuildDir != null && projectBuildDir.exists()) {
+ }
+
+ private Options createOptions() throws MojoFailureException {
+ Options options = new Options();
+ if (parameter != null) {
+ String accessModifierArg = parameter.getAccessModifier();
+ if (accessModifierArg != null) {
try {
- File japiBuildDir = new File(projectBuildDir.getCanonicalPath() + File.separator + "japicmp");
- japiBuildDir.mkdirs();
- File diffOutputfile = new File(japiBuildDir.getCanonicalPath() + File.separator + "japicmp.diff");
- FileWriter fileWriter = null;
- try {
- fileWriter = new FileWriter(diffOutputfile);
- fileWriter.write(output);
- } catch(Exception e) {
- throw new MojoFailureException(String.format("Failed to write diff file: %s", e.getMessage()), e);
- } finally {
- if(fileWriter != null) {
- fileWriter.close();
- }
- }
- } catch (IOException e) {
- throw new MojoFailureException(String.format("Failed to construct output directory: %s", e.getMessage()), e);
+ AccessModifier accessModifier = AccessModifier.valueOf(accessModifierArg.toUpperCase());
+ options.setAccessModifier(accessModifier);
+ } catch (IllegalArgumentException e) {
+ throw new MojoFailureException(String.format("Invalid value for option accessModifier: %s. Possible values are: %s.", accessModifierArg, AccessModifier.listOfAccessModifier()));
+ }
+ }
+ String onlyModified = parameter.getOnlyModified();
+ if (onlyModified != null) {
+ Boolean booleanOnlyModified = Boolean.valueOf(onlyModified);
+ options.setOutputOnlyModifications(booleanOnlyModified);
+ }
+ String packagesToExclude = parameter.getPackagesToExclude();
+ if (packagesToExclude != null) {
+ try {
+ options.addPackagesExcludeFromArgument(packagesToExclude);
+ } catch (Exception e) {
+ throw new MojoFailureException(e.getMessage());
+ }
+ }
+ String packagesToInclude = parameter.getPackagesToInclude();
+ if (packagesToInclude != null) {
+ try {
+ options.addPackageIncludeFromArgument(packagesToInclude);
+ } catch (Exception e) {
+ throw new MojoFailureException(e.getMessage());
}
}
- } else {
- throw new MojoFailureException(String.format("At least one required parameter is missing."));
}
+ return options;
+ }
+
+ private boolean breakBuildOnModificationsParameter() {
+ boolean retVal = false;
+ if (parameter != null) {
+ retVal = Boolean.valueOf(parameter.getBreakBuildOnModifications());
+ }
+ return retVal;
+ }
+
+ private void createFileAndWriteTo(String diffOutput, File jApiCmpBuildDir) throws IOException, MojoFailureException {
+ File outputfile = new File(jApiCmpBuildDir.getCanonicalPath() + File.separator + "japicmp.diff");
+ writeToFile(diffOutput, outputfile);
+ }
+
+ private File createJapiCmpBaseDir() throws IOException {
+ File jApiCmpBuildDir = new File(projectBuildDir.getCanonicalPath() + File.separator + "japicmp");
+ jApiCmpBuildDir.mkdirs();
+ return jApiCmpBuildDir;
+ }
+
+ private String generateDiffOutput(File newVersionFile, File oldVersionFile, List<JApiClass> jApiClasses, Options options) {
+ StdoutOutputGenerator stdoutOutputGenerator = new StdoutOutputGenerator();
+ String diffOutput = stdoutOutputGenerator.generate(oldVersionFile, newVersionFile, jApiClasses, options);
+ getLog().info(diffOutput);
+ return diffOutput;
+ }
+
+ private void generateXmlOutput(File newVersionFile, File oldVersionFile, List<JApiClass> jApiClasses, File jApiCmpBuildDir, Options options) throws IOException {
+ XmlOutputGenerator xmlGenerator = new XmlOutputGenerator();
+ options.setXmlOutputFile(Optional.of(jApiCmpBuildDir.getCanonicalPath() + File.separator + "japicmp.xml"));
+ xmlGenerator.generate(oldVersionFile, newVersionFile, jApiClasses, options);
}
- private File resolveArtifact(String descriptor) throws MojoFailureException {
+ private List<JApiClass> compareArchives(File newVersionFile, File oldVersionFile) {
+ JarArchiveComparatorOptions comparatorOptions = new JarArchiveComparatorOptions();
+ JarArchiveComparator jarArchiveComparator = new JarArchiveComparator(comparatorOptions);
+ return jarArchiveComparator.compare(oldVersionFile, newVersionFile);
+ }
+
+ private File retrieveFileFromConfiguration(Version version, String parameterName) throws MojoFailureException {
+ if (version != null) {
+ Dependency dependency = version.getDependency();
+ if (dependency != null) {
+ String descriptor = dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion();
+ getLog().debug(parameterName + ": " + descriptor);
+ File file = resolveArtifact(dependency);
+ if (file == null) {
+ throw new MojoFailureException(String.format("Could not resolve dependency with descriptor '%s'.", descriptor));
+ }
+ return file;
+ } else if (version.getFile() != null) {
+ ConfigurationFile configurationFile = version.getFile();
+ String path = configurationFile.getPath();
+ if (path == null) {
+ throw new MojoFailureException(String.format("The path element in the configuration of the plugin is missing for %s.", parameterName));
+ }
+ File file = new File(path);
+ if (!file.exists()) {
+ throw new MojoFailureException(String.format("The path '%s' does not point to an existing file.", path));
+ }
+ if (!file.isFile() || !file.canRead()) {
+ throw new MojoFailureException(String.format("The file given by path '%s' is either not a file or is not readable.", path));
+ }
+ return file;
+ } else {
+ throw new MojoFailureException(String.format("Missing configuration parameter 'dependency'."));
+ }
+ }
+ throw new MojoFailureException(String.format("Missing configuration parameter: %s", parameterName));
+ }
+
+ private void writeToFile(String output, File outputfile) throws MojoFailureException, IOException {
+ FileWriter fileWriter = null;
try {
- ArtifactRequest request = new ArtifactRequest();
- request.setArtifact(new DefaultArtifact(descriptor));
- request.setRepositories(remoteRepos);
- ArtifactResult result = repoSystem.resolveArtifact(newSession(repoSystem), request);
- File file = result.getArtifact().getFile();
- getLog().info("Resolved artifact " + result + " to " + file + " from " + result.getRepository());
- return file;
+ fileWriter = new FileWriter(outputfile);
+ fileWriter.write(output);
} catch (Exception e) {
- throw new MojoFailureException(String.format("Failed to load artifact from repository: %s", e.getMessage()), e);
+ throw new MojoFailureException(String.format("Failed to write diff file: %s", e.getMessage()), e);
+ } finally {
+ if (fileWriter != null) {
+ fileWriter.close();
+ }
}
}
- private static RepositorySystemSession newSession(RepositorySystem system) {
- DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
- LocalRepository localRepo = new LocalRepository(new File(System.getProperty("user.home") + "/.m2/repository"));
- session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
- return session;
+ private File resolveArtifact(Dependency dependency) throws MojoFailureException {
+ notNull(artifactRepositories, "Maven parameter artifactRepositories should be provided by maven container.");
+ notNull(artifactResolver, "Maven parameter artifactResolver should be provided by maven container.");
+ notNull(localRepository, "Maven parameter localRepository should be provided by maven container.");
+ notNull(artifactRepositories, "Maven parameter artifactRepositories should be provided by maven container.");
+ Artifact artifact = artifactFactory.createBuildArtifact(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), "jar");
+ ArtifactResolutionRequest request = new ArtifactResolutionRequest();
+ request.setArtifact(artifact);
+ request.setLocalRepository(localRepository);
+ request.setRemoteRepositories(artifactRepositories);
+ artifactResolver.resolve(request);
+ return artifact.getFile();
+ }
+
+ private static <T> T notNull(T value, String msg) throws MojoFailureException {
+ if (value == null) {
+ throw new MojoFailureException(msg);
+ }
+ return value;
}
}
diff --git a/japicmp-maven-plugin/src/main/java/japicmp/maven/Parameter.java b/japicmp-maven-plugin/src/main/java/japicmp/maven/Parameter.java
new file mode 100644
index 0000000..a4393fe
--- /dev/null
+++ b/japicmp-maven-plugin/src/main/java/japicmp/maven/Parameter.java
@@ -0,0 +1,49 @@
+package japicmp.maven;
+
+public class Parameter {
+ private String accessModifier;
+ private String packagesToInclude;
+ private String packagesToExclude;
+ private String onlyModified;
+ private String breakBuildOnModifications;
+
+ public String getAccessModifier() {
+ return accessModifier;
+ }
+
+ public void setAccessModifier(String accessModifier) {
+ this.accessModifier = accessModifier;
+ }
+
+ public String getPackagesToInclude() {
+ return packagesToInclude;
+ }
+
+ public void setPackagesToInclude(String packagesToInclude) {
+ this.packagesToInclude = packagesToInclude;
+ }
+
+ public String getPackagesToExclude() {
+ return packagesToExclude;
+ }
+
+ public void setPackagesToExclude(String packagesToExclude) {
+ this.packagesToExclude = packagesToExclude;
+ }
+
+ public String getOnlyModified() {
+ return onlyModified;
+ }
+
+ public void setOnlyModified(String onlyModified) {
+ this.onlyModified = onlyModified;
+ }
+
+ public String getBreakBuildOnModifications() {
+ return breakBuildOnModifications;
+ }
+
+ public void setBreakBuildOnModifications(String breakBuildOnModifications) {
+ this.breakBuildOnModifications = breakBuildOnModifications;
+ }
+}
diff --git a/japicmp-maven-plugin/src/main/java/japicmp/maven/Version.java b/japicmp-maven-plugin/src/main/java/japicmp/maven/Version.java
index 3be2982..14d5342 100644
--- a/japicmp-maven-plugin/src/main/java/japicmp/maven/Version.java
+++ b/japicmp-maven-plugin/src/main/java/japicmp/maven/Version.java
@@ -2,6 +2,7 @@ package japicmp.maven;
public class Version {
private Dependency dependency;
+ private ConfigurationFile file;
public Dependency getDependency() {
return dependency;
@@ -10,4 +11,12 @@ public class Version {
public void setDependency(Dependency dependency) {
this.dependency = dependency;
}
+
+ public ConfigurationFile getFile() {
+ return file;
+ }
+
+ public void setFile(ConfigurationFile file) {
+ this.file = file;
+ }
}
diff --git a/japicmp-testbase/japicmp-test-maven-plugin/pom.xml b/japicmp-testbase/japicmp-test-maven-plugin/pom.xml
index 1cdc6e7..553ed80 100644
--- a/japicmp-testbase/japicmp-test-maven-plugin/pom.xml
+++ b/japicmp-testbase/japicmp-test-maven-plugin/pom.xml
@@ -40,6 +40,13 @@
<version>${project.version}</version>
</dependency>
</newVersion>
+ <parameter>
+ <onlyModified>true</onlyModified>
+ <packagesToInclude>*</packagesToInclude>
+ <packagesToExclude>*</packagesToExclude>
+ <accessModifier>public</accessModifier>
+ <breakBuildOnModifications>false</breakBuildOnModifications>
+ </parameter>
</configuration>
<executions>
<execution>
diff --git a/japicmp-testbase/japicmp-test-v2/pom.xml b/japicmp-testbase/japicmp-test-v2/pom.xml
index c1c68f4..db78d5b 100644
--- a/japicmp-testbase/japicmp-test-v2/pom.xml
+++ b/japicmp-testbase/japicmp-test-v2/pom.xml
@@ -8,4 +8,36 @@
</parent>
<artifactId>japicmp-test-v2</artifactId>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>japicmp</groupId>
+ <artifactId>japicmp-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <configuration>
+ <oldVersion>
+ <dependency>
+ <groupId>japicmp</groupId>
+ <artifactId>japicmp-test-v1</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </oldVersion>
+ <newVersion>
+ <file>
+ <path>${project.build.directory}/${project.artifactId}-${project.version}.jar</path>
+ </file>
+ </newVersion>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>verify</phase>
+ <goals>
+ <goal>cmp</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
diff --git a/japicmp/pom.xml b/japicmp/pom.xml
index 0d78636..bd8c70e 100644
--- a/japicmp/pom.xml
+++ b/japicmp/pom.xml
@@ -30,10 +30,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- </plugin>
- <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
diff --git a/japicmp/src/main/java/japicmp/cli/CliParser.java b/japicmp/src/main/java/japicmp/cli/CliParser.java
index e5f87e3..ba8c4c2 100644
--- a/japicmp/src/main/java/japicmp/cli/CliParser.java
+++ b/japicmp/src/main/java/japicmp/cli/CliParser.java
@@ -2,7 +2,6 @@ package japicmp.cli;
import com.google.common.base.Optional;
import japicmp.model.AccessModifier;
-import japicmp.config.PackageFilter;
import japicmp.config.Options;
import japicmp.exception.JApiCmpException;
import japicmp.util.StringArrayEnumeration;
@@ -35,32 +34,16 @@ public class CliParser {
AccessModifier accessModifier = AccessModifier.valueOf(accessModifierArg.toUpperCase());
options.setAccessModifier(accessModifier);
} catch (IllegalArgumentException e) {
- throw new IllegalArgumentException(String.format("Invalid value for option -a: %s. Possible values are: %s.", accessModifierArg, listOfAccessModifiers()));
+ throw new IllegalArgumentException(String.format("Invalid value for option -a: %s. Possible values are: %s.", accessModifierArg, AccessModifier.listOfAccessModifier()));
}
}
if ("-i".equals(arg)) {
String packagesIncludeArg = getOptionWithArgument("-i", sae);
- String[] parts = packagesIncludeArg.split(",");
- for (String part : parts) {
- part = part.trim();
- try {
- options.getPackagesInclude().add(new PackageFilter(part));
- } catch (Exception e) {
- throw new IllegalArgumentException(String.format("Wrong syntax for include option '%s': %s", part, e.getMessage()));
- }
- }
+ options.addPackageIncludeFromArgument(packagesIncludeArg);
}
if ("-e".equals(arg)) {
String packagesExcludeArg = getOptionWithArgument("-e", sae);
- String[] parts = packagesExcludeArg.split(",");
- for (String part : parts) {
- part = part.trim();
- try {
- options.getPackagesInclude().add(new PackageFilter(part));
- } catch (Exception e) {
- throw new IllegalArgumentException(String.format("Wrong syntax for exclude option '%s': %s", part, e.getMessage()));
- }
- }
+ options.addPackagesExcludeFromArgument(packagesExcludeArg);
}
if ("-h".equals(arg)) {
printHelp();
@@ -103,17 +86,4 @@ public class CliParser {
throw new IllegalArgumentException(String.format("Missing argument for option %s.", option));
}
}
-
- private String listOfAccessModifiers() {
- StringBuilder sb = new StringBuilder();
- int i = 0;
- for (AccessModifier am : AccessModifier.values()) {
- if (i > 0) {
- sb.append(",");
- }
- sb.append(am.toString());
- i++;
- }
- return sb.toString();
- }
}
diff --git a/japicmp/src/main/java/japicmp/config/Options.java b/japicmp/src/main/java/japicmp/config/Options.java
index 8cfc975..3efdf52 100644
--- a/japicmp/src/main/java/japicmp/config/Options.java
+++ b/japicmp/src/main/java/japicmp/config/Options.java
@@ -62,4 +62,28 @@ public class Options {
public List<PackageFilter> getPackagesExclude() {
return packagesExclude;
}
+
+ public void addPackagesExcludeFromArgument(String packagesExcludeArg) {
+ String[] parts = packagesExcludeArg.split(",");
+ for (String part : parts) {
+ part = part.trim();
+ try {
+ getPackagesExclude().add(new PackageFilter(part));
+ } catch (Exception e) {
+ throw new IllegalArgumentException(String.format("Wrong syntax for package include option '%s': %s", part, e.getMessage()));
+ }
+ }
+ }
+
+ public void addPackageIncludeFromArgument(String packagesIncludeArg) {
+ String[] parts = packagesIncludeArg.split(",");
+ for (String part : parts) {
+ part = part.trim();
+ try {
+ getPackagesInclude().add(new PackageFilter(part));
+ } catch (Exception e) {
+ throw new IllegalArgumentException(String.format("Wrong syntax for package exclude option '%s': %s", part, e.getMessage()));
+ }
+ }
+ }
}
diff --git a/japicmp/src/main/java/japicmp/model/AccessModifier.java b/japicmp/src/main/java/japicmp/model/AccessModifier.java
index d9422f2..8454fa2 100644
--- a/japicmp/src/main/java/japicmp/model/AccessModifier.java
+++ b/japicmp/src/main/java/japicmp/model/AccessModifier.java
@@ -12,4 +12,17 @@ public enum AccessModifier {
public int getLevel() {
return level;
}
+
+ public static String listOfAccessModifier() {
+ StringBuilder sb = new StringBuilder();
+ int i = 0;
+ for (AccessModifier am : AccessModifier.values()) {
+ if (i > 0) {
+ sb.append(",");
+ }
+ sb.append(am.toString());
+ i++;
+ }
+ return sb.toString();
+ }
}
diff --git a/pom.xml b/pom.xml
index 5c6f160..d4f6967 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,6 +12,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<github.account>siom79</github.account>
<cloudbees.account>siom79</cloudbees.account>
+ <java.source>1.7</java.source>
+ <java.target>1.7</java.target>
</properties>
<modules>
@@ -36,8 +38,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
- <source>1.5</source>
- <target>1.5</target>
+ <source>${java.source}</source>
+ <target>${java.target}</target>
</configuration>
</plugin>
<plugin>
@@ -55,9 +57,6 @@
<goals>
<goal>jar</goal>
</goals>
- <configuration>
- <additionalparam>-Xdoclint:none</additionalparam>
- </configuration>
</execution>
</executions>
</plugin>