Beispiel #1
0
 @Override
 public boolean install() {
   if (!isInstalled()) {
     MavenModelResource pom = getModelResource();
     if (!pom.createNewFile()) throw new IllegalStateException("Could not create POM file.");
     pom.setContents(createDefaultPOM());
   }
   return isInstalled();
 }
Beispiel #2
0
 @Override
 public void setModel(final Model pom) {
   MavenXpp3Writer writer = new MavenXpp3Writer();
   ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
   MavenModelResource modelResource = getModelResource();
   try (Writer fw = new OutputStreamWriter(outputStream)) {
     writer.write(fw, pom);
     modelResource.setContents(outputStream.toString());
   } catch (IOException e) {
     throw new RuntimeException(
         "Could not write POM file: " + modelResource.getFullyQualifiedName(), e);
   } finally {
     buildManager.evictFromCache(modelResource);
   }
 }
Beispiel #3
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);
  }
Beispiel #4
0
 @Override
 public boolean isInstalled() {
   MavenModelResource pom = getModelResource();
   return pom != null && pom.exists();
 }