Beispiel #1
0
 @Override
 public void execute() throws MojoExecutionException {
   try {
     SCM scm = determineSCM();
     project.getProperties().setProperty(buildTimeProperty, getBuildTime());
     project.getProperties().setProperty(scmUriProperty, getSCMUri(scm));
     project.getProperties().setProperty(scmBranchProperty, getSCMBranch(scm));
     project.getProperties().setProperty(scmCommitProperty, getSCMCommit(scm));
     project.getProperties().setProperty(md5Property, computeMD5());
   } catch (Throwable ex) {
     throw new MojoExecutionException(ex.toString(), ex);
   }
 }
  @Override
  public void execute() throws MojoExecutionException, MojoFailureException {

    FileOutputStream fos = null;
    try {
      if (!project.getPackaging().equalsIgnoreCase("pom")) {

        String status = project.getProperties().getProperty("deegree.module.status");
        if (status == null) {
          status = "unknown";
        }

        File f = new File("/tmp/" + status + ".txt");
        fos = new FileOutputStream(f, true);
        PrintWriter writer = new PrintWriter(new OutputStreamWriter(fos, "UTF-8"));

        writer.print("||");
        writer.print(project.getArtifactId());
        writer.print("||");
        writer.print(project.getDescription());
        writer.print("||");
        writer.print("\n");
        writer.close();
      }
    } catch (FileNotFoundException e) {
      throw new MojoExecutionException(e.getMessage(), e);
    } catch (UnsupportedEncodingException e) {
      throw new MojoExecutionException(e.getMessage(), e);
    } finally {
      IOUtils.closeQuietly(fos);
    }
  }
  private void updateArtifactEntry(final BufferedReader reader, final BufferedWriter writer)
      throws IOException {

    // this line remains the same
    writer.write(project.getArtifactId());
    writer.newLine();
    // next line is version, author (or "deployer"), date & time,
    reader.readLine();
    writer.write(
        project.getVersion()
            + " was last deployed by "
            + System.getProperty("user.name")
            + " at "
            + SimpleDateFormat.getDateTimeInstance().format(now));
    writer.newLine();
    // next line is the quote
    for (String line = reader.readLine();
        null != line && 0 < line.length();
        line = reader.readLine()) {}
    ;
    final String quote = project.getProperties().getProperty("version.quote");
    if (null != quote) {
      writer.write(quote);
      writer.newLine();
      writer.newLine();
    }
  }
 private void checkBomVersion() throws CoreException {
   IMavenProjectFacade mavenProjectFacade =
       MavenPlugin.getMavenProjectRegistry().getProject(project);
   MavenProject mavenProject = mavenProjectFacade.getMavenProject(new NullProgressMonitor());
   assertThat(mavenProject.getProperties().getProperty("jboss.fuse.bom.version"))
       .isEqualTo(CamelModelFactory.getFuseVersionForCamelVersion(camelVersion));
 }
 public void execute() throws MojoExecutionException {
   Map map = getPluginContext();
   String jsonHudsonUrl = hudsonUrl + "/" + hudsonProject + "/" + "api/json";
   System.out.println(jsonHudsonUrl);
   HudsonRestful spyRest = new HudsonRestful();
   Integer buildNumber = spyRest.retrieveBuildNumber(jsonHudsonUrl);
   System.out.println("Build Number : " + buildNumber);
   project.getProperties().put("hudsonBuildNumber", "-r" + buildNumber); // no build number
 }
 private Properties initProperties() throws MojoExecutionException {
   if (generateGitPropertiesFile) {
     return properties = new Properties();
   } else if (!runningTests) {
     return properties = project.getProperties();
   } else {
     return properties = new Properties(); // that's ok for unit tests
   }
 }
  private void appendPropertiesToReactorProjects(@NotNull Properties properties) {
    for (MavenProject mavenProject : reactorProjects) {
      Properties mavenProperties = mavenProject.getProperties();

      log(mavenProject.getName(), "] project", mavenProject.getName());

      for (Object key : properties.keySet()) {
        mavenProperties.put(key, properties.get(key));
      }
    }
  }
  @Override
  public void execute() throws MojoExecutionException, MojoFailureException {

    String version = project.getVersion();
    String trimmedVersion = "";

    Pattern pattern = Pattern.compile("[0-9]+\\.[0-9]+\\.[0-9]+");
    Matcher matcher = pattern.matcher(version);
    if (matcher.find()) {
      trimmedVersion = matcher.group();
    }

    project.getProperties().setProperty("version.replacer", trimmedVersion);
  }
  /**
   * @throws MojoExecutionException
   * @throws MojoFailureException if methodEntryCount exceeds {@link #MAX_PORT_ALLOCATION_RETRY}
   * @param entryNum a value less than {@link #MAX_PORT_ALLOCATION_RETRY}
   */
  private void allocatePorts(int methodEntryCount)
      throws MojoExecutionException, MojoFailureException {
    if (methodEntryCount >= MAX_PORT_ALLOCATION_RETRY) {
      throw new MojoFailureException(
          "Exceeded the maximum number of port allocation retries ("
              + MAX_PORT_ALLOCATION_RETRY
              + ")");
    }
    methodEntryCount++;

    // calc dynamic and static ports
    List<Port> portsList = new ArrayList<Port>();
    for (String portName : DEFAULT_PORT_NAMES) {
      Port port = new Port(portName);
      if (this.staticPorts != null && this.staticPorts.containsKey(portName)) {
        // this prevents assigning random port and instead
        // tests the static port for availability
        String portNum = String.valueOf(this.staticPorts.get(portName));
        getLog().debug("Statically defining port '" + portName + "' with value '" + portNum + "'.");
        port.setPortNumber(Integer.valueOf(portNum));
        port.setFailIfOccupied(true);
      }
      portsList.add(port);
    }

    // allocate dynamic ports and verify requested ports
    PortAllocatorMojo portAllocator = new PortAllocatorMojo();
    portAllocator.setProject(project);
    portAllocator.setLog(getLog());
    portAllocator.setPorts(portsList.toArray(new Port[0]));
    portAllocator.execute();

    // detect port collisions from dynamic port assignment
    List<String> portNums = new ArrayList<String>();
    for (String portName : DEFAULT_PORT_NAMES) {
      String portNum = String.valueOf(project.getProperties().get(portName));
      assert !"null".equals(portNum);
      if (portNums.contains(portNum)) {
        // duplicate ports generated by port allocator, try again
        getLog()
            .debug(
                "Duplicate port value of "
                    + portNum
                    + " is defined. Trying to re-allocate non-duplicate port values.");
        allocatePorts(methodEntryCount);
      }
      portNums.add(portNum);
    }
  }
  private void copyExtraResources() throws MojoExecutionException, MojoFailureException {
    for (MavenArtifact extraResource : getExtraResourcesArtifacts()) {
      Artifact artifact = getMavenArtifact(extraResource);

      File dest;
      if (extraResource.getOutputDirectory() != null) {
        dest = extraResource.getOutputDirectory();
      } else if (extraResource.getOutputProperty() != null) {
        dest = new File(project.getProperties().getProperty(extraResource.getOutputProperty()));
      } else {
        dest = resourcesDestinationLocation;
      }
      unpack(artifact.getFile(), dest, artifact.getType());
    }
  }
  private void extractPluginJs() throws MojoExecutionException {
    Collection<Artifact> plugins = getNexusPlugins();

    File outputDir = new File(project.getProperties().getProperty("nexus.webapp"), "static");
    outputDir.mkdirs();

    for (Artifact plugin : plugins) {
      ZipFile file;
      try {
        file = new ZipFile(plugin.getFile());
      } catch (IOException e) {
        throw new MojoExecutionException(e.getMessage(), e);
      }

      getLog().debug("Processing " + plugin);

      Enumeration<? extends ZipEntry> entries = file.entries();
      while (entries.hasMoreElements()) {
        ZipEntry entry = entries.nextElement();

        String name = entry.getName();
        if (!(name.startsWith("static/js/") && name.endsWith(".js"))) {
          continue;
        }

        File outFile = new File(outputDir, name.substring(10));
        getLog().debug("Extracting " + name + " to " + outFile);

        InputStream in = null;
        FileOutputStream out = null;

        try {
          in = file.getInputStream(entry);
          out = new FileOutputStream(outFile);

          IOUtil.copy(in, out);
        } catch (IOException e) {
          throw new MojoExecutionException(e.getMessage(), e);
        } finally {
          IOUtil.close(out);
          IOUtil.close(in);
        }
      }
    }
  }
  /**
   * Get the context root from a maven web project
   *
   * @param mavenProject
   * @return the final name of the project if it exists, or the project's artifactId.
   */
  protected String getContextRoot(MavenProject mavenProject) {
    String contextRoot;

    // MECLIPSEWTP-43 : Override with maven property
    String property = mavenProject.getProperties().getProperty(M2ECLIPSE_WTP_CONTEXT_ROOT);
    if (StringUtils.isEmpty(property)) {
      String finalName = mavenProject.getBuild().getFinalName();
      if (StringUtils.isBlank(finalName)
          || finalName.equals(mavenProject.getArtifactId() + "-" + mavenProject.getVersion())) {
        contextRoot = mavenProject.getArtifactId();
      } else {
        contextRoot = finalName;
      }
    } else {
      contextRoot = property;
    }
    return contextRoot.trim().replace(" ", "_");
  }
  /**
   * @return the wagon (already connected) to use against the profile's serverDeployLocation or null
   *     if in development profile
   * @throws org.apache.maven.plugin.MojoExecutionException
   */
  private Wagon getWagon() throws MojoExecutionException {

    loadProfile();

    try {

      Wagon wagon = null;

      if (null != profile) {

        final String serverDeployLocation =
            System.getProperty(
                SERVER_DEPLOY_LOCATION,
                project.getProperties().getProperty("serverDeployLocation"));

        final String protocol =
            serverDeployLocation.substring(0, serverDeployLocation.indexOf(':'));

        final Repository wagonRepository = new Repository();

        wagonRepository.setUrl(serverDeployLocation);

        final RepositoryPermissions permissions = new RepositoryPermissions();
        permissions.setFileMode("g+w");
        wagonRepository.setPermissions(permissions);

        wagon = (Wagon) container.lookup(Wagon.ROLE, protocol);
        wagon.connect(wagonRepository);
      }
      return wagon;

    } catch (ConnectionException ex) {
      getLog().error(ex);
      throw new MojoExecutionException("repository wagon not connected", ex);
    } catch (AuthenticationException ex) {
      getLog().error(ex);
      throw new MojoExecutionException("repository wagon not authenticated", ex);
    } catch (ComponentLookupException ex) {
      getLog().error(ex);
      throw new MojoExecutionException("repository wagon not found", ex);
    }
  }
  /** initialize properties shared with template */
  protected void initTemplateProperties() {

    processProperties();

    getProperties().put("pageTitle", getTitle());
    getProperties().put("parentPageTitle", getParentPageTitle());
    getProperties().put("artifactId", project.getArtifactId());
    getProperties().put("version", project.getVersion());
    getProperties().put("groupId", project.getGroupId());
    getProperties().put("name", project.getName());
    getProperties().put("description", project.getDescription());

    java.util.Properties projectProps = project.getProperties();

    if (projectProps != null) {

      for (Map.Entry<Object, Object> e : projectProps.entrySet()) {
        getProperties().put(String.valueOf(e.getKey()), String.valueOf(e.getValue()));
      }
    }
  }
  /**
   * Create a LegacyProperties object for dealing with Legacy Properties.
   *
   * @param log the log to write to
   * @param project the maven project to get maven properties from
   * @param legacyPropertiesFile the (potential) legacy properties file to load from. if this file
   *     does not exist, no properties are loaded, and no exception is thrown.
   * @throws MojoFailureException if the legacyPropertiesFile exists, but there is a problem reading
   *     / parsing / loading the properties from the file.
   */
  public LegacyProperties(Log log, MavenProject project, File legacyPropertiesFile)
      throws MojoFailureException {
    this.log = log;
    this.legacyPropertiesFile = legacyPropertiesFile;

    projectProps = project.getProperties();
    if (projectProps == null) {
      projectProps = new Properties();
    }

    if (legacyPropertiesFile.exists()) {
      FileReader reader = null;
      try {
        reader = new FileReader(legacyPropertiesFile);
        legacyFileProps = new Properties();
        legacyFileProps.load(reader);
      } catch (IOException e) {
        throw new MojoFailureException(
            "Unable to load properties file: " + legacyPropertiesFile, e);
      } finally {
        IOUtils.closeQuietly(reader);
      }
    }
  }
 /**
  * Extracts buildnumber fields from git repository and publishes them as maven properties.
  * Executes only once per build. Return default (unknown) buildnumber fields on error.
  *
  * @throws MojoExecutionException
  * @throws MojoFailureException
  */
 @Override
 public void execute() throws MojoExecutionException, MojoFailureException {
   Properties props = project.getProperties();
   try {
     // executes only once per build
     // http://www.sonatype.com/people/2009/05/how-to-make-a-plugin-run-once-during-a-build/
     if (executionRootDirectory.equals(baseDirectory) || !runOnlyAtExecutionRoot) {
       // build started from this projects root
       BuildNumber bn = BuildNumberExtractor.extract(repositoryDirectory);
       props.setProperty(revisionProperty, bn.getRevision());
       props.setProperty(shortRevisionProperty, bn.getShortRevision());
       props.setProperty(branchProperty, bn.getBranch());
       props.setProperty(tagProperty, bn.getTag());
       props.setProperty(parentProperty, bn.getParent());
       props.setProperty(commitsCountProperty, bn.getCommitsCountAsString());
       props.setProperty(commitDateProperty, bn.getCommitDate());
       // create composite buildnumber
       String composite = createBuildnumber(bn);
       props.setProperty(buildnumberProperty, composite);
       getLog()
           .info(
               String.format(
                   "Git info extracted, revision: '%s', branch: '%s', tag: '%s', commitsCount: '%d', commitDate: '%s', buildNumber: '%s', describe: '%s",
                   bn.getShortRevision(),
                   bn.getBranch(),
                   bn.getTag(),
                   bn.getCommitsCount(),
                   bn.getCommitDate(),
                   composite,
                   bn.getDescribe()));
     } else if ("pom".equals(parentProject.getPackaging())) {
       // build started from parent, we are in subproject, lets provide parent properties to our
       // project
       Properties parentProps = parentProject.getProperties();
       String revision = parentProps.getProperty(revisionProperty);
       if (null == revision) {
         // we are in subproject, but parent project wasn't build this time,
         // maybe build is running from parent with custom module list - 'pl' argument
         getLog()
             .info("Cannot extract Git info, maybe custom build with 'pl' argument is running");
         fillPropsUnknown(props);
         return;
       }
       props.setProperty(revisionProperty, revision);
       props.setProperty(shortRevisionProperty, parentProps.getProperty(shortRevisionProperty));
       props.setProperty(branchProperty, parentProps.getProperty(branchProperty));
       props.setProperty(tagProperty, parentProps.getProperty(tagProperty));
       props.setProperty(parentProperty, parentProps.getProperty(parentProperty));
       props.setProperty(commitsCountProperty, parentProps.getProperty(commitsCountProperty));
       props.setProperty(buildnumberProperty, parentProps.getProperty(buildnumberProperty));
       props.setProperty(commitDateProperty, parentProps.getProperty(commitDateProperty));
       props.setProperty(describeProperty, parentProps.getProperty(describeProperty));
     } else {
       // should not happen
       getLog()
           .warn(
               "Cannot extract JGit version: something wrong with build process, we're not in parent, not in subproject!");
       fillPropsUnknown(props);
     }
   } catch (Exception e) {
     getLog().error(e);
     fillPropsUnknown(props);
   }
 }
  public void execute() throws MojoExecutionException, MojoFailureException {
    if (testSkip || pluginSkip) {
      return;
    }

    init();

    validateStaticPorts();
    allocatePorts();

    project.getProperties().put("jetty-application-host", "0.0.0.0");
    project
        .getProperties()
        .put(
            "nexus-base-url",
            "http://*****:*****@SuppressWarnings("unchecked")
        List<File> webapps = FileUtils.getFiles(pluginFolder, "*-webapp.zip", null);
        for (File webapp : webapps) {
          unpack(
              webapp, new File((String) project.getProperties().get(PROP_NEXUS_BASE_DIR)), "zip");
          webapp.delete();
        }
      } catch (IOException e) {
        throw new MojoExecutionException("Failed to unpack webapp plugins:", e);
      }
    }

    // setup Maven if requested for this test
    if (setupMaven) {
      mavenLocation.mkdirs();
      String mavenVersion = setupMaven().getBaseVersion();
      project.getProperties().put("maven-version", mavenVersion);
      if (this.mavenBaseDir == null) {
        this.mavenBaseDir = "apache-maven-" + mavenVersion;
      }
      project.getProperties().put("maven-basedir", getPath(new File(mavenLocation, mavenBaseDir)));

      File fakeRepoDest = new File(mavenLocation, "fake-repo");
      project.getProperties().put("maven-repository", getPath(fakeRepoDest));
    }

    if (!resourcesDestinationLocation.isDirectory()) {
      resourcesDestinationLocation.mkdirs();
    }
    project.getProperties().put("test-resources-folder", getPath(resourcesDestinationLocation));
    // ./resources dir at root of project by default, suitable for tests I guess?
    if (resourcesSourceLocation.isDirectory()) {
      project.getProperties().put("test-resources-source-folder", getPath(resourcesSourceLocation));
    }

    // start default configs
    File defaultConfig = new File(resourcesDestinationLocation, "default-configs");
    project.getProperties().put("default-configs", getPath(defaultConfig));

    copyUrl("/default-config/nexus.xml", new File(defaultConfig, "nexus.xml"));
    copyUrl("/default-config/security.xml", new File(defaultConfig, "security.xml"));
    copyUrl(
        "/default-config/security-configuration.xml",
        new File(defaultConfig, "security-configuration.xml"));
    copyUrl("/default-config/settings.xml", new File(defaultConfig, "settings.xml"));
    copyUrl("/default-config/logback-nexus.xml", new File(defaultConfig, "logback-nexus.xml"));

    File sourceDefaultConfig = new File(resourcesSourceLocation, "default-config");
    if (sourceDefaultConfig.isDirectory()) {
      copyAndInterpolate(sourceDefaultConfig, defaultConfig);
    }
    // end default configs

    // start baseTest.properties
    File baseTestProperties = new File(testOutputDirectory, "baseTest.properties");
    copyUrl("/default-config/baseTest.properties", baseTestProperties);

    File testSuiteProperties = new File(resourcesSourceLocation, "baseTest.properties");
    if (testSuiteProperties.isFile()) {
      merge(baseTestProperties, testSuiteProperties, "properties");
    }

    addProjectProperties(baseTestProperties);
    // end baseTest.properties

    File logbackConfig = new File(testOutputDirectory, "logback.xml");
    if (!logbackConfig.exists()) {
      copyUrl("/test-config/logback.xml", logbackConfig);
    }

    copyExtraResources();

    File destinationComponents = new File(testOutputDirectory, "META-INF/plexus/components.xml");
    copyUrl("/default-config/components.xml", destinationComponents);

    File componentsXml = new File(testResourcesDirectory, "components.xml");
    if (componentsXml.exists()) {
      copyAndInterpolate(componentsXml.getParentFile(), destinationComponents.getParentFile());
    }

    if (extractNexusPluginsJavascript) {
      extractPluginJs();
    }
  }
  private void setupPlugins(
      Collection<MavenArtifact> nexusPluginsArtifacts, File libsFolder, File pluginsFolder)
      throws MojoFailureException, MojoExecutionException {

    Set<Artifact> plugins = new LinkedHashSet<Artifact>();
    for (MavenArtifact plugin : nexusPluginsArtifacts) {
      Artifact pluginArtifact = getMavenArtifact(plugin);
      plugins.add(pluginArtifact);
    }

    nexusPluginsArtifacts = new LinkedHashSet<MavenArtifact>(nexusPluginsArtifacts);
    Collection<Artifact> nonTransitivePlugins = getNonTransitivePlugins(plugins);
    for (Artifact artifact : nonTransitivePlugins) {
      final MavenArtifact ma =
          new MavenArtifact(
              artifact.getGroupId(),
              artifact.getArtifactId(),
              artifact.getClassifier(),
              artifact.getType());
      ma.setVersion(artifact.getVersion());
      nexusPluginsArtifacts.add(ma);
    }

    nexusPluginsArtifacts = filterOutExcludedPlugins(nexusPluginsArtifacts);

    final Map<String, File> bundlePlugins =
        useBundlePluginsIfPresent ? listPlugins(pluginsFolder) : null;

    for (MavenArtifact plugin : nexusPluginsArtifacts) {
      getLog().info("Setting up plugin: " + plugin);

      Artifact pluginArtifact = getMavenArtifact(plugin);

      File dest;
      if (plugin.getOutputDirectory() != null) {
        dest = plugin.getOutputDirectory();
      } else if (plugin.getOutputProperty() != null) {
        dest = new File(project.getProperties().getProperty(plugin.getOutputProperty()));
      } else if ("bundle".equals(pluginArtifact.getClassifier())
          && "zip".equals(pluginArtifact.getType())) {
        dest = pluginsFolder;
      } else {
        dest = libsFolder;
      }

      String type = pluginArtifact.getType();

      if ("jar".equals(type)) {
        // System.out.println( "copying jar: "+ pluginArtifact.getFile().getAbsolutePath() + " to:
        // "+
        // dest.getAbsolutePath() );
        copy(pluginArtifact.getFile(), dest);
      } else if ("zip".equals(type) || "tar.gz".equals(type)) {
        File file = pluginArtifact.getFile();
        if (file == null || !file.isFile()) {
          throw new MojoFailureException(
              "Could not properly resolve artifact " + pluginArtifact + ", got " + file);
        }
        final String pluginKey = pluginArtifact.getGroupId() + ":" + pluginArtifact.getArtifactId();
        if (!useBundlePluginsIfPresent || !bundlePlugins.containsKey(pluginKey)) {
          unpack(file, dest, type);
        }
      } else {
        throw new MojoFailureException("Invalid plugin type: " + type);
      }
    }
  }
  private void executeServerDeploy(final Wagon wagon) throws MojoExecutionException {

    // alpha|nuclei|beta|electron|gamma|production deployment goes through scpexe
    try {
      if (ensureNoLocalModifications()) {

        @SuppressWarnings("unchecked")
        final List<ArtifactItem> theArtifactItems = getProcessedArtifactItems(stripVersion);

        for (ArtifactItem item : theArtifactItems) {

          final Artifact artifact =
              factory.createArtifactWithClassifier(
                  item.getGroupId(),
                  item.getArtifactId(),
                  item.getVersion(),
                  item.getType(),
                  profile);

          resolver.resolve(artifact, getRemoteRepos(), getLocal());

          final String sesamSite = project.getProperties().getProperty("sesam.site");
          final String destName = null != sesamSite ? sesamSite : project.getBuild().getFinalName();

          // tag the code
          final boolean tagOnDeploy =
              Boolean.parseBoolean(
                  System.getProperty(
                      TAG_ON_DEPLOY, project.getProperties().getProperty("tag.on.deploy")));

          if (tagOnDeploy && !Boolean.getBoolean(DRY_RUN)) {
            tagDeploy();
          }

          // do the upload
          getLog()
              .info(
                  "Uploading "
                      + artifact.getFile().getAbsolutePath()
                      + " to "
                      + wagon.getRepository().getUrl()
                      + '/'
                      + destName
                      + ".war");

          if (!Boolean.getBoolean(DRY_RUN)) {
            wagon.put(artifact.getFile(), destName + ".war");
          }

          // update the version.txt
          getLog().info("Updating " + wagon.getRepository().getUrl() + "/version.txt");

          if (Boolean.getBoolean(DRY_RUN)) {

            final StringWriter sb = new StringWriter();
            final BufferedWriter w = new BufferedWriter(sb);
            updateArtifactEntry(new BufferedReader(new StringReader("")), w);
            w.flush();
            getLog().info("version.txt entry will be \n" + sb.toString());

          } else {

            updateVersionFile(wagon);
          }
        }
      }

    } catch (TransferFailedException ex) {
      getLog().error(ex);
      throw new MojoExecutionException("transfer failed", ex);
    } catch (ResourceDoesNotExistException ex) {
      getLog().error(ex);
      throw new MojoExecutionException("resource does not exist", ex);
    } catch (AuthorizationException ex) {
      getLog().error(ex);
      throw new MojoExecutionException("authorisation exception", ex);
    } catch (ArtifactNotFoundException ex) {
      getLog().error(ex);
      throw new MojoExecutionException("artifact not found", ex);
    } catch (ArtifactResolutionException ex) {
      getLog().error(ex);
      throw new MojoExecutionException("artifact resolution exception", ex);
    } catch (ScmException ex) {
      getLog().error(ex);
      throw new MojoExecutionException("scm exception", ex);
    } catch (ComponentLookupException ex) {
      getLog().error(ex);
      throw new MojoExecutionException("failed to lookup ScmManager", ex);
    } catch (IOException ex) {
      getLog().error(ex);
      throw new MojoExecutionException("IOException", ex);
    }
  }
Beispiel #20
0
 private boolean isAppFuse() {
   return (project.getProperties().getProperty("copyright.year") != null);
 }
Beispiel #21
0
  private List<Dependency> addModuleDependencies(
      List<Dependency> dependencies, String moduleName, String moduleLocation) {
    log("Adding dependencies from " + moduleName + " module...");

    // Read dependencies from module's pom.xml
    URL pomLocation = null;
    File newDir = new File("target", "appfuse-" + moduleName);

    if (!newDir.exists()) {
      newDir.mkdirs();
    }

    File pom = new File("target/appfuse-" + moduleName + "/pom.xml");

    try {
      // replace github.com with raw.github.com and trunk with master
      trunk = trunk.replace("https://github.com", "https://raw.github.com");
      tag = tag.replace("trunk", "master");
      pomLocation = new URL(trunk + tag + moduleLocation + "/pom.xml");
    } catch (MalformedURLException e) {
      e.printStackTrace();
    }

    Get get = (Get) AntUtils.createProject().createTask("get");
    get.setSrc(pomLocation);
    get.setDest(pom);
    get.execute();

    MavenProject p = createProjectFromPom(pom);

    List moduleDependencies = p.getOriginalModel().getDependencies();

    // set the properties for appfuse if root module
    if (moduleName.equalsIgnoreCase("root")) {
      appfuseProperties = p.getOriginalModel().getProperties();
    }

    // create a list of artifactIds to check for duplicates (there's no equals() on Dependency)
    Set<String> artifactIds = new LinkedHashSet<String>();

    for (Dependency dep : dependencies) {
      artifactIds.add(dep.getArtifactId());
    }

    // add all non-appfuse dependencies
    for (Object moduleDependency : moduleDependencies) {
      Dependency dep = (Dependency) moduleDependency;

      if (dep.getGroupId().equals("javax.servlet")
          && dep.getArtifactId().equals("jsp-api")
          && "jsf".equals(project.getProperties().getProperty("web.framework"))) {
        // skip adding dependency for old group id of jsp-api
        continue;
      }

      if (!artifactIds.contains(dep.getArtifactId()) && !dep.getArtifactId().contains("appfuse")) {
        dependencies.add(dep);
      }
    }

    return dependencies;
  }
Beispiel #22
0
 public void execute() {
   project.getProperties().put("timestamp", "123456789");
 }
Beispiel #23
0
  private void createFullSourcePom(List<Dependency> newDependencies) throws MojoFailureException {
    // Change spring-test and jmock dependencies to use <optional>true</option> instead of
    // <scope>test</scope>.
    // This is necessary because Base*TestCase classes are in src/main/java. If we move these
    // classes to their
    // own test module, this will no longer be necessary. For the first version of this mojo, it
    // seems easier
    // to follow the convention used in AppFuse rather than creating a test module and changing all
    // modules to
    // depend on it.

    // create properties based on dependencies while we're at it
    Set<String> projectProperties = new TreeSet<String>();

    for (Dependency dep : newDependencies) {
      if (dep.getArtifactId().equals("spring-test")
          || dep.getArtifactId().contains("jmock")
          || dep.getArtifactId().equals("junit")
          || dep.getArtifactId().equals("shale-test")) {
        dep.setOptional(true);
        dep.setScope(null);
      }
      String version = dep.getVersion();
      // trim off ${}
      if (version.startsWith("${")) {
        version = version.substring(2);
      }

      if (version.endsWith("}")) {
        version = version.substring(0, version.length() - 1);
      }
      projectProperties.add(version);
    }

    // add core as a dependency for modular wars
    if (project.getPackaging().equals("war") && project.hasParent()) {
      Dependency core = new Dependency();
      core.setGroupId("${project.parent.groupId}");
      core.setArtifactId("core");
      core.setVersion("${project.parent.version}");
      newDependencies.add(core);

      // workaround for JSF requiring JSP 2.1 - this is a true hack
      if (project.getProperties().getProperty("web.framework").equals("jsf")) {
        Dependency jsp21 = new Dependency();
        jsp21.setGroupId("javax.servlet.jsp");
        jsp21.setArtifactId("jsp-api");
        jsp21.setVersion("${jsp.version}");
        jsp21.setScope("provided");
        newDependencies.add(jsp21);

        // replace jsp.version property as well
        project.getOriginalModel().getProperties().setProperty("jsp.version", "2.1");
      }
    }

    Collections.sort(newDependencies, new BeanComparator("groupId"));

    project.getOriginalModel().setDependencies(newDependencies);

    Properties currentProperties = project.getOriginalModel().getProperties();

    Set<String> currentKeys = new LinkedHashSet<String>();
    for (Object key : currentProperties.keySet()) {
      currentKeys.add((String) key);
    }

    StringBuffer sortedProperties = new StringBuffer();

    Properties appfuseProperties = getAppFuseProperties();

    // holder for properties - stored in ThreadLocale
    Map<String, String> propertiesForPom = new LinkedHashMap<String, String>();

    for (String key : projectProperties) {
      // don't add property if it already exists in project
      if (!currentKeys.contains(key)) {
        String value = appfuseProperties.getProperty(key);

        // this happens when the version number is hard-coded
        if (value == null) {
          continue;
        }

        // hack for Tapestry depending on commons-pool (a.k.a. commons-dbcp 1.2.2)
        if ("tapestry".equals(project.getProperties().getProperty("web.framework"))
            && key.equals("commons.dbcp.version")) {
          value = "1.2.2";
        }

        if (value.contains("&amp;")) {
          value = "<![CDATA[" + value + "]]>";
        }

        sortedProperties
            .append("        <")
            .append(key)
            .append(">")
            .append(value)
            .append("</")
            .append(key)
            .append(">" + "\n");
        propertiesForPom.put(key, value);
      }
    }

    if (project.getPackaging().equals("pom") || project.hasParent()) {
      // store sorted properties in a thread local for later retrieval
      Map<String, String> properties = new LinkedHashMap<String, String>();
      if (propertiesContextHolder.get() != null) {
        properties = (LinkedHashMap) propertiesContextHolder.get();
      }

      for (String key : propertiesForPom.keySet()) {
        if (!properties.containsKey(key)) {
          properties.put(key, propertiesForPom.get(key));
        }
      }

      propertiesContextHolder.set(properties);
    }

    StringWriter writer = new StringWriter();

    try {
      project.writeOriginalModel(writer);

      File pom = new File("pom-fullsource.xml");

      if (pom.exists()) {
        pom.delete();
      }

      FileWriter fw = new FileWriter(pom);
      fw.write(writer.toString());
      fw.flush();
      fw.close();
    } catch (IOException ex) {
      getLog().error("Unable to create pom-fullsource.xml: " + ex.getMessage(), ex);
      throw new MojoFailureException(ex.getMessage());
    }

    log("Updated dependencies in pom.xml...");

    // I tried to use regex here, but couldn't get it to work - going with the old fashioned way
    // instead
    String pomXml = writer.toString();
    int startTag = pomXml.indexOf("\n  <dependencies>");

    String dependencyXml = pomXml.substring(startTag, pomXml.indexOf("</dependencies>", startTag));
    // change 2 spaces to 4
    dependencyXml = dependencyXml.replaceAll("  ", "    ");
    dependencyXml =
        "\n    <!-- Dependencies calculated by AppFuse when running full-source plugin -->"
            + dependencyXml;

    try {
      String packaging = project.getPackaging();
      String pathToPom = "pom.xml";
      if (project.hasParent()) {
        if (packaging.equals("jar")) {
          pathToPom = "core/" + pathToPom;
        } else if (packaging.equals("war")) {
          pathToPom = "web/" + pathToPom;
        }
      }

      String originalPom = FileUtils.readFileToString(new File(pathToPom), "UTF-8");
      // replace tabs with spaces (in case user has changed their pom.xml
      originalPom = originalPom.replace("\t", "    ");
      startTag = originalPom.indexOf("\n    <dependencies>");

      StringBuffer sb = new StringBuffer();
      sb.append(originalPom.substring(0, startTag));
      sb.append(dependencyXml);
      sb.append(originalPom.substring(originalPom.indexOf("</dependencies>", startTag)));

      String adjustedPom = sb.toString();

      // Calculate properties and add them to pom if not a modular project - otherwise properties
      // are added
      // near the end of this method from a threadlocal
      if (!project.getPackaging().equals("pom") && !project.hasParent()) {
        adjustedPom = addPropertiesToPom(adjustedPom, sortedProperties);
      }

      adjustedPom = adjustLineEndingsForOS(adjustedPom);

      FileUtils.writeStringToFile(
          new File(pathToPom), adjustedPom, "UTF-8"); // was pomWithProperties
    } catch (IOException ex) {
      getLog().error("Unable to write to pom.xml: " + ex.getMessage(), ex);
      throw new MojoFailureException(ex.getMessage());
    }

    boolean renamePackages = true;
    if (System.getProperty("renamePackages") != null) {
      renamePackages = Boolean.valueOf(System.getProperty("renamePackages"));
    }

    if (renamePackages && !project.getPackaging().equals("pom")) {
      log("Renaming packages to '" + project.getGroupId() + "'...");
      RenamePackages renamePackagesTool = new RenamePackages(project.getGroupId());
      if (project.hasParent()) {
        if (project.getPackaging().equals("jar")) {
          renamePackagesTool.setBaseDir("core/src");
        } else {
          renamePackagesTool.setBaseDir("web/src");
        }
      }

      renamePackagesTool.execute();
    }

    // when performing full-source on a modular project, add the properties to the root pom.xml at
    // the end
    if (project.getPackaging().equals("war") && project.hasParent()) {
      // store sorted properties in a thread local for later retrieval
      Map properties = propertiesContextHolder.get();
      // alphabetize the properties by key
      Set<String> propertiesToAdd = new TreeSet<String>(properties.keySet());

      StringBuffer calculatedProperties = new StringBuffer();

      for (String key : propertiesToAdd) {
        // don't add property if it already exists in project
        Set<Object> keysInProject = project.getParent().getOriginalModel().getProperties().keySet();
        if (!keysInProject.contains(key)) {
          String value = getAppFuseProperties().getProperty(key);

          if (value.contains("&amp;")) {
            value = "<![CDATA[" + value + "]]>";
          }

          calculatedProperties.append("        <");
          calculatedProperties.append(key);
          calculatedProperties.append(">");
          calculatedProperties.append(value);
          calculatedProperties.append("</");
          calculatedProperties.append(key);
          calculatedProperties.append(">");
          calculatedProperties.append("\n");
        }
      }

      try {
        String originalPom = FileUtils.readFileToString(new File("pom.xml"), "UTF-8");

        // Move modules to build section.
        originalPom = originalPom.replaceAll("  <modules>", "");
        // Because I hate f*****g regex.
        originalPom = originalPom.replaceAll("    <module>.*?</module>", "");
        originalPom = originalPom.replaceAll("  </modules>", "");

        originalPom =
            originalPom.replace(
                "<repositories>",
                "<modules>\n"
                    + "        <module>core</module>\n"
                    + "        <module>web</module>\n"
                    + "    </modules>\n\n    <repositories>");

        String pomWithProperties = addPropertiesToPom(originalPom, calculatedProperties);

        FileUtils.writeStringToFile(new File("pom.xml"), pomWithProperties, "UTF-8");
      } catch (IOException ex) {
        getLog().error("Unable to read root pom.xml: " + ex.getMessage(), ex);
        throw new MojoFailureException(ex.getMessage());
      }
    }

    // cleanup so user isn't aware that files were created
    File pom = new File("pom-fullsource.xml");

    if (pom.exists()) {
      pom.delete();
    }
  }
  public Object evaluate(String expr, Class<?> type) throws ExpressionEvaluationException {
    Object value = null;

    if (expr == null) {
      return null;
    }

    String expression = stripTokens(expr);
    if (expression.equals(expr)) {
      int index = expr.indexOf("${");
      if (index >= 0) {
        int lastIndex = expr.indexOf("}", index);
        if (lastIndex >= 0) {
          String retVal = expr.substring(0, index);

          if ((index > 0) && (expr.charAt(index - 1) == '$')) {
            retVal += expr.substring(index + 1, lastIndex + 1);
          } else {
            Object subResult = evaluate(expr.substring(index, lastIndex + 1));

            if (subResult != null) {
              retVal += subResult;
            } else {
              retVal += "$" + expr.substring(index + 1, lastIndex + 1);
            }
          }

          retVal += evaluate(expr.substring(lastIndex + 1));
          return retVal;
        }
      }

      // Was not an expression
      if (expression.contains("$$")) {
        return expression.replaceAll("\\$\\$", "\\$");
      } else {
        return expression;
      }
    }

    MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();

    if ("localRepository".equals(expression)) {
      value = session.getLocalRepository();
    } else if ("session".equals(expression)) {
      value = session;
    } else if (expression.startsWith("session")) {
      try {
        int pathSeparator = expression.indexOf("/");

        if (pathSeparator > 0) {
          String pathExpression = expression.substring(1, pathSeparator);
          value = ReflectionValueExtractor.evaluate(pathExpression, session);
          value = value + expression.substring(pathSeparator);
        } else {
          value = ReflectionValueExtractor.evaluate(expression.substring(1), session);
        }
      } catch (Exception e) {
        // TODO: don't catch exception
        throw new ExpressionEvaluationException(
            "Error evaluating plugin parameter expression: " + expression, e);
      }
    } else if ("reactorProjects".equals(expression)) {
      value = session.getProjects();
    } else if ("mojoExecution".equals(expression)) {
      value = mojoExecution;
    } else if ("project".equals(expression)) {
      value = project;
    } else if ("executedProject".equals(expression)) {
      value = project.getExecutionProject();
    } else if (expression.startsWith("project") || expression.startsWith("pom")) {
      try {
        int pathSeparator = expression.indexOf("/");

        if (pathSeparator > 0) {
          String pathExpression = expression.substring(0, pathSeparator);
          value = ReflectionValueExtractor.evaluate(pathExpression, project);
          value = value + expression.substring(pathSeparator);
        } else {
          value = ReflectionValueExtractor.evaluate(expression.substring(1), project);
        }
      } catch (Exception e) {
        // TODO: don't catch exception
        throw new ExpressionEvaluationException(
            "Error evaluating plugin parameter expression: " + expression, e);
      }
    } else if (expression.equals("repositorySystemSession")) {
      value = session.getRepositorySession();
    } else if (expression.equals("mojo")) {
      value = mojoExecution;
    } else if (expression.startsWith("mojo")) {
      try {
        int pathSeparator = expression.indexOf("/");

        if (pathSeparator > 0) {
          String pathExpression = expression.substring(1, pathSeparator);
          value = ReflectionValueExtractor.evaluate(pathExpression, mojoExecution);
          value = value + expression.substring(pathSeparator);
        } else {
          value = ReflectionValueExtractor.evaluate(expression.substring(1), mojoExecution);
        }
      } catch (Exception e) {
        // TODO: don't catch exception
        throw new ExpressionEvaluationException(
            "Error evaluating plugin parameter expression: " + expression, e);
      }
    } else if (expression.equals("plugin")) {
      value = mojoDescriptor.getPluginDescriptor();
    } else if (expression.startsWith("plugin")) {
      try {
        int pathSeparator = expression.indexOf("/");

        PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();

        if (pathSeparator > 0) {
          String pathExpression = expression.substring(1, pathSeparator);
          value = ReflectionValueExtractor.evaluate(pathExpression, pluginDescriptor);
          value = value + expression.substring(pathSeparator);
        } else {
          value = ReflectionValueExtractor.evaluate(expression.substring(1), pluginDescriptor);
        }
      } catch (Exception e) {
        throw new ExpressionEvaluationException(
            "Error evaluating plugin parameter expression: " + expression, e);
      }
    } else if ("settings".equals(expression)) {
      value = session.getSettings();
    } else if (expression.startsWith("settings")) {
      try {
        int pathSeparator = expression.indexOf("/");

        if (pathSeparator > 0) {
          String pathExpression = expression.substring(1, pathSeparator);
          value = ReflectionValueExtractor.evaluate(pathExpression, session.getSettings());
          value = value + expression.substring(pathSeparator);
        } else {
          value = ReflectionValueExtractor.evaluate(expression.substring(1), session.getSettings());
        }
      } catch (Exception e) {
        // TODO: don't catch exception
        throw new ExpressionEvaluationException(
            "Error evaluating plugin parameter expression: " + expression, e);
      }
    } else if ("basedir".equals(expression)) {
      value = basedir;
    } else if (expression.startsWith("basedir")) {
      int pathSeparator = expression.indexOf("/");

      if (pathSeparator > 0) {
        value = basedir + expression.substring(pathSeparator);
      }
    }

    /*
     * MNG-4312: We neither have reserved all of the above magic expressions nor is their set fixed/well-known (it
     * gets occasionally extended by newer Maven versions). This imposes the risk for existing plugins to
     * unintentionally use such a magic expression for an ordinary system property. So here we check whether we
     * ended up with a magic value that is not compatible with the type of the configured mojo parameter (a string
     * could still be converted by the configurator so we leave those alone). If so, back off to evaluating the
     * expression from properties only.
     */
    if (value != null
        && type != null
        && !(value instanceof String)
        && !isTypeCompatible(type, value)) {
      value = null;
    }

    if (value == null) {
      // The CLI should win for defining properties

      if ((value == null) && (properties != null)) {
        // We will attempt to get nab a system property as a way to specify a
        // parameter to a plugins. My particular case here is allowing the surefire
        // plugin to run a single test so I want to specify that class on the cli
        // as a parameter.

        value = properties.getProperty(expression);
      }

      if ((value == null) && ((project != null) && (project.getProperties() != null))) {
        value = project.getProperties().getProperty(expression);
      }
    }

    if (value instanceof String) {
      // TODO: without #, this could just be an evaluate call...

      String val = (String) value;

      int exprStartDelimiter = val.indexOf("${");

      if (exprStartDelimiter >= 0) {
        if (exprStartDelimiter > 0) {
          value =
              val.substring(0, exprStartDelimiter) + evaluate(val.substring(exprStartDelimiter));
        } else {
          value = evaluate(val.substring(exprStartDelimiter));
        }
      }
    }

    return value;
  }
Beispiel #25
0
  public void execute() throws MojoExecutionException, MojoFailureException {
    // http://issues.appfuse.org/browse/APF-1025
    System.setProperty("file.encoding", "UTF-8");

    // If appfuse.version is specified as a property, and not a SNAPSHOT, use it for the tag
    String appfuseVersion = project.getProperties().getProperty("appfuse.version");

    if ((appfuseVersion != null) && !appfuseVersion.endsWith("SNAPSHOT") && tag.equals("trunk/")) {
      tag = "tags/APPFUSE_" + appfuseVersion.toUpperCase().replaceAll("-", "_") + "/";
      // APF-1168: Allow milestone and release candidates
      if (tag.contains("_M")) {
        tag = tag.replace("_M", "-M");
      } else if (tag.contains("_R")) {
        tag = tag.replace("_R", "-R");
      }
    }

    String daoFramework = project.getProperties().getProperty("dao.framework");

    if (daoFramework == null) {
      log("No dao.framework property specified, defaulting to 'hibernate'");
    }

    String webFramework = project.getProperties().getProperty("web.framework");

    boolean modular = (project.getPackaging().equals("pom") && !project.hasParent());
    if (project.getPackaging().equals("jar")
        || (project.getPackaging().equals("war") && !project.hasParent())) {
      // export data-common
      log("Installing source from data-common module...");
      export("data/common/src", (modular) ? "core/src" : destinationDirectory);

      // export persistence framework
      log("Installing source from " + daoFramework + " module...");
      export("data/" + daoFramework + "/src", (modular) ? "core/src" : destinationDirectory);

      // export service module
      log("Installing source from service module...");
      export("service/src", (modular) ? "core/src" : destinationDirectory);

      // move Base*TestCase to test directory
      moveFiles(
          (modular) ? "core/src/main" : destinationDirectory + "/main",
          (modular) ? "core/src/test" : destinationDirectory + "/test",
          "**/Base*TestCase.java");

      // delete dao.framework related files from test directory
      deleteFile("test/resources/hibernate.cfg.xml");
      deleteFile("test/resources/META-INF");
      deleteFile("test/resources/sql-map-config.xml");

      // If JPA, delete hibernate.cfg.xml b/c it will cause issues when
      // using jpaconfiguration with the hibernate3-maven-plugin
      if ("jpa".equalsIgnoreCase(daoFramework)) {
        deleteFile("main/resources/hibernate.cfg.xml");
      }
    }

    // it's OK if a project created with appfuse-ws doesn't have a web framework defined
    // currently, a project with appfuse-ws can be identified by enunciate
    boolean isWebServicesProject = false;
    for (Object pluginArtifact : project.getPluginArtifacts()) {
      if (((Artifact) pluginArtifact).getArtifactId().contains("enunciate")) {
        isWebServicesProject = true;
        break;
      }
    }

    if (project.getPackaging().equalsIgnoreCase("war")) {

      if (webFramework == null && !isWebServicesProject) {
        getLog()
            .error(
                "The web.framework property is not specified - please modify your pom.xml to add "
                    + " this property. For example: <web.framework>struts</web.framework>.");
        throw new MojoExecutionException(
            "No web.framework property specified, please modify pom.xml to add it.");
      }

      if (project.hasParent()) {
        // copy jdbc.properties to core/src/test/resources
        // FileUtils.copyFileToDirectory(new File("src/main/resources/jdbc.properties"), new
        // File("../core/src/test/resources"));

        // delete hibernate, ibatis and jpa files from web project
        deleteFile("main/resources/hibernate.cfg.xml");
        deleteFile("main/resources/META-INF");
        deleteFile("main/resources/sql-map-config.xml");

        // there's a jdbc.properties in test/resources that shouldn't be there
        deleteFile("test/resources/jdbc.properties");
      } else if (!isAppFuse()) {
        // there's a jdbc.properties in test/resources that shouldn't be there
        deleteFile("test/resources/jdbc.properties");
      }
    }

    log("Source successfully exported, modifying pom.xml...");

    List dependencies = project.getOriginalModel().getDependencies();
    List<Dependency> newDependencies = new ArrayList<Dependency>();

    // remove all appfuse dependencies
    for (Object dependency : dependencies) {
      Dependency dep = (Dependency) dependency;

      if (!dep.getGroupId().equals(APPFUSE_GROUP_ID)) {
        newDependencies.add(dep);
      }
    }

    if (!project.getPackaging().equals("pom") && !project.hasParent()) {

      // add dependencies from root appfuse pom
      newDependencies = addModuleDependencies(newDependencies, "root", "");

      // Add dependencies from appfuse-data
      newDependencies = addModuleDependencies(newDependencies, "data", "data");

      // Add dependencies from appfuse-data-common
      newDependencies = addModuleDependencies(newDependencies, "data-common", "data/common");

      // Add dependencies from appfuse-${dao.framework}
      newDependencies =
          addModuleDependencies(newDependencies, daoFramework, "data/" + daoFramework);

      // Add dependencies from appfuse-service
      newDependencies = addModuleDependencies(newDependencies, "service", "service");

      if (!isWebServicesProject && project.getPackaging().equals("war")) {
        newDependencies = addWebDependencies(appfuseVersion, newDependencies, webFramework);
      }

      createFullSourcePom(newDependencies);
    } else {
      if (project.getPackaging().equals("pom")) {
        // add dependencies from root appfuse pom
        newDependencies = addModuleDependencies(newDependencies, "root", "");

        createFullSourcePom(newDependencies);
      }

      if (project.getPackaging().equals("jar")) {
        newDependencies.clear();

        // Add dependencies from appfuse-data
        newDependencies = addModuleDependencies(newDependencies, "data", "data");

        // Add dependencies from appfuse-data-common
        newDependencies = addModuleDependencies(newDependencies, "data-common", "data/common");

        // Add dependencies from appfuse-${dao.framework}
        newDependencies =
            addModuleDependencies(newDependencies, daoFramework, "data/" + daoFramework);

        // Add dependencies from appfuse-service
        newDependencies = addModuleDependencies(newDependencies, "service", "service");

        createFullSourcePom(newDependencies);
      }

      if (project.getPackaging().equals("war")) {
        newDependencies.clear();

        newDependencies = addWebDependencies(appfuseVersion, newDependencies, webFramework);

        createFullSourcePom(newDependencies);
      }
    }
  }
 /**
  * Gets the property value that is defined in the pom. This is an extension point to allow
  * updating a file external to the reactor.
  *
  * @param pom The pom.
  * @param property The property.
  * @return The value as defined in the pom or <code>null</code> if not defined.
  * @since 1.0-alpha-1
  */
 protected String getPropertyValue(StringBuilder pom, String property) {
   return project.getProperties().getProperty(property);
 }