コード例 #1
0
  public void updateMetadata(
      @SuppressWarnings("hiding") Metadata metadata, @SuppressWarnings("rawtypes") Map entries) {
    for (Object key : entries.keySet()) {
      final Object value = entries.get(key);
      if (value != null) {
        metadata.put(key, value.toString());
      }
    }

    metadata.persist();
  }
コード例 #2
0
  protected void syncAppVersion() {
    final Metadata metadata =
        Metadata.getInstance(new File(getBasedir(), "application.properties"));
    if (syncVersion(metadata)) metadata.persist();

    String artifactId = project.getArtifactId();

    if (artifactId.startsWith("grails-")) artifactId = artifactId.substring("grails-".length());

    final String fName = getFullGrailsPluginName();
    if (fName != null) {
      File gpFile = new File(fName);

      String text = null;
      String mod = null;
      try {
        text = readFileAsString(gpFile);
        mod = text.replaceFirst(GRAILS_PLUGIN_VERSION_PATTERN, "$1" + project.getVersion() + "$5");
      } catch (IOException e) {
        // ignore
      }
      if (text != null && !mod.equalsIgnoreCase(text)) {
        BufferedOutputStream out = null;
        try {
          out = new BufferedOutputStream(new FileOutputStream(gpFile));
          out.write(mod.getBytes());
        } catch (IOException e) {
          // do nuffink
        } finally {
          if (out != null) {
            try {
              out.close();
            } catch (Exception ignored) {
              // ignored
            }
          }
        }
      }
    }
  }