示例#1
0
  public String replaceRulesetsDirectoryWithLatestReleaseIfAny()
      throws IOException, DependencyException {
    if (!this.rulesetsNeedUpdate()) return null;

    Path windupRulesDir = getRulesetsDir();
    Path coreRulesetsDir = windupRulesDir.resolve(RULESET_CORE_DIRECTORY);

    Coordinate rulesetsCoord = getLatestReleaseOf("org.jboss.windup.rules", "windup-rulesets");
    if (rulesetsCoord == null) throw new WindupException("No Windup release found.");

    FileUtils.deleteDirectory(coreRulesetsDir.toFile());
    extractArtifact(rulesetsCoord, coreRulesetsDir.toFile());

    return rulesetsCoord.getVersion();
  }
示例#2
0
  public boolean rulesetsNeedUpdate() {
    Coordinate lastRelease = this.getLatestReleaseOf(RULES_GROUP_ID, RULESETS_ARTIFACT_ID);
    Path windupRulesDir = getRulesetsDir();
    Path coreRulesPomPath =
        windupRulesDir.resolve(
            RULESET_CORE_DIRECTORY
                + "/META-INF/maven/org.jboss.windup.rules/windup-rulesets/pom.xml");
    File pomXml = coreRulesPomPath.toFile();
    if (!pomXml.exists()) return false;

    MavenModelResource pom = (MavenModelResource) factory.create(pomXml);
    SingleVersion installed = new SingleVersion(pom.getCurrentModel().getVersion());
    SingleVersion latest = new SingleVersion(lastRelease.getVersion());
    final String msg = "Core rulesets: Installed: " + installed + " Latest release: " + latest;
    log.info(msg);
    System.out.println(msg); // Print to both to have the info in the log too.
    return 0 > installed.compareTo(latest);
  }