Search in sources :

Example 1 with PublicDiffCriteria

use of org.osjava.jardiff.PublicDiffCriteria in project semantic-versioning by jeluard.

the class Main method main.

public static void main(final String[] args) throws IOException {
    Config config = new Config();
    CmdlineParser cmdlineParser = new CmdlineParser(config);
    // Load translations of command line descriptions
    cmdlineParser.setResourceBundle(Main.class.getPackage().getName() + ".Messages", Main.class.getClassLoader());
    cmdlineParser.setProgramName("semver");
    cmdlineParser.setAboutLine("Semantic Version validator.");
    try {
        cmdlineParser.parse(args);
    } catch (CmdlineParserException e) {
        System.err.println("Error: " + e.getLocalizedMessage() + "\nRun semver --help for help.");
        System.exit(1);
    }
    if (config.help) {
        cmdlineParser.usage();
        System.exit(0);
    }
    final DiffCriteria diffCriteria = config.publicOnly ? new PublicDiffCriteria() : new SimpleDiffCriteria();
    final Comparer comparer = new Comparer(diffCriteria, new File(config.baseJar), new File(config.newJar), config.includes, config.excludes);
    final Delta delta = comparer.diff();
    if (config.diff) {
        Dumper.dump(delta);
    }
    if (config.check) {
        System.out.println(delta.computeCompatibilityType());
    }
    if (config.infer) {
        System.out.println(delta.infer(Version.parse(config.baseVersion)));
    }
    if (config.validate) {
        System.out.println(delta.validate(Version.parse(config.baseVersion), Version.parse(config.newVersion)));
    }
}
Also used : PublicDiffCriteria(org.osjava.jardiff.PublicDiffCriteria) CmdlineParser(de.tototec.cmdoption.CmdlineParser) CmdlineParserException(de.tototec.cmdoption.CmdlineParserException) SimpleDiffCriteria(org.osjava.jardiff.SimpleDiffCriteria) SimpleDiffCriteria(org.osjava.jardiff.SimpleDiffCriteria) PublicDiffCriteria(org.osjava.jardiff.PublicDiffCriteria) DiffCriteria(org.osjava.jardiff.DiffCriteria) File(java.io.File)

Example 2 with PublicDiffCriteria

use of org.osjava.jardiff.PublicDiffCriteria in project semantic-versioning by jeluard.

the class AbstractEnforcerRule method compareJars.

private void compareJars(final EnforcerRuleHelper helper, final Version previous, final File previousJar, final Version current, final File currentJar) throws EnforcerRuleException {
    helper.getLog().info("Using <" + previousJar + "> as previous JAR");
    helper.getLog().info("Using <" + currentJar + "> as current JAR");
    try {
        final DiffCriteria diffCriteria = publicOnly ? new PublicDiffCriteria() : new SimpleDiffCriteria();
        final Comparer comparer = new Comparer(diffCriteria, previousJar, currentJar, extractFilters(this.includes), extractFilters(this.excludes));
        final Delta delta = comparer.diff();
        enforce(helper, delta, previous, current);
    } catch (IOException e) {
        throw new EnforcerRuleException("Exception while checking compatibility: " + e.toString(), e);
    }
}
Also used : PublicDiffCriteria(org.osjava.jardiff.PublicDiffCriteria) Delta(org.semver.Delta) Comparer(org.semver.Comparer) EnforcerRuleException(org.apache.maven.enforcer.rule.api.EnforcerRuleException) SimpleDiffCriteria(org.osjava.jardiff.SimpleDiffCriteria) IOException(java.io.IOException) SimpleDiffCriteria(org.osjava.jardiff.SimpleDiffCriteria) PublicDiffCriteria(org.osjava.jardiff.PublicDiffCriteria) DiffCriteria(org.osjava.jardiff.DiffCriteria)

Aggregations

DiffCriteria (org.osjava.jardiff.DiffCriteria)2 PublicDiffCriteria (org.osjava.jardiff.PublicDiffCriteria)2 SimpleDiffCriteria (org.osjava.jardiff.SimpleDiffCriteria)2 CmdlineParser (de.tototec.cmdoption.CmdlineParser)1 CmdlineParserException (de.tototec.cmdoption.CmdlineParserException)1 File (java.io.File)1 IOException (java.io.IOException)1 EnforcerRuleException (org.apache.maven.enforcer.rule.api.EnforcerRuleException)1 Comparer (org.semver.Comparer)1 Delta (org.semver.Delta)1