protected void addProxyArg(List<String> args, String key, String protocol) {
    Logger logger = getLogger();

    if (args.contains(key)) {
      if (logger.isInfoEnabled()) {
        logger.info("{} proxy on {} is already set", protocol.toUpperCase(), this);
      }

      return;
    }

    String host = System.getProperty(protocol + ".proxyHost");
    String port = System.getProperty(protocol + ".proxyPort");

    if (Validator.isNotNull(host) && Validator.isNotNull(port)) {
      String url = protocol + "://" + host + ":" + port;

      args.add(key);
      args.add(url);

      if (logger.isInfoEnabled()) {
        logger.info("{} proxy on {} set to {}", protocol.toUpperCase(), this, url);
      }
    }
  }
  private void _configureProject(Project project, String description, String version) {

    if (Validator.isNotNull(description)) {
      project.setDescription(description);
    }

    if (Validator.isNotNull(version)) {
      project.setVersion(version);
    }
  }
  private String _getAppJavadocGroupName(Project project) {
    String groupName = project.getDescription();

    if (Validator.isNull(groupName)) {
      groupName = project.getName();
    }

    TaskContainer taskContainer = project.getTasks();

    WritePropertiesTask recordArtifactTask =
        (WritePropertiesTask)
            taskContainer.findByName(LiferayRelengPlugin.RECORD_ARTIFACT_TASK_NAME);

    if (recordArtifactTask != null) {
      String artifactURL = null;

      File artifactPropertiesFile = recordArtifactTask.getOutputFile();

      if (artifactPropertiesFile.exists()) {
        Properties properties = GUtil.loadProperties(artifactPropertiesFile);

        artifactURL = properties.getProperty("artifact.url");
      }

      if (Validator.isNotNull(artifactURL)) {
        int start = artifactURL.lastIndexOf('/') + 1;
        int end = artifactURL.lastIndexOf('.');

        int pos = artifactURL.indexOf('-', start);

        String moduleName = artifactURL.substring(start, pos);
        String moduleVersion = artifactURL.substring(pos + 1, end);

        StringBuilder sb = new StringBuilder();

        sb.append("Module ");
        sb.append(moduleName);
        sb.append(' ');
        sb.append(moduleVersion);
        sb.append(" - ");
        sb.append(groupName);

        groupName = sb.toString();
      }
    }

    return groupName;
  }
  @Override
  public void apply(Settings settings) {
    File rootDir = settings.getRootDir();

    Path rootDirPath = rootDir.toPath();

    String projectPathPrefix =
        GradleUtil.getProperty(settings, PROJECT_PATH_PREFIX_PROPERTY_NAME, "");

    if (Validator.isNotNull(projectPathPrefix)) {
      if (projectPathPrefix.charAt(0) != ':') {
        projectPathPrefix = ":" + projectPathPrefix;
      }

      if (projectPathPrefix.charAt(projectPathPrefix.length() - 1) == ':') {

        projectPathPrefix = projectPathPrefix.substring(0, projectPathPrefix.length() - 1);
      }
    }

    try {
      _includeProjects(settings, rootDirPath, rootDirPath, projectPathPrefix);
    } catch (IOException ioe) {
      throw new UncheckedIOException(ioe);
    }
  }
  public Map<String, String> getBundleDefaultInstructions() {
    Map<String, String> map = new HashMap<>();

    map.put(Constants.BUNDLE_SYMBOLICNAME, project.getName());
    map.put(Constants.BUNDLE_VENDOR, "Liferay, Inc.");
    map.put(Constants.DONOTCOPY, "(.touch)");
    map.put(Constants.DSANNOTATIONS, "*");
    map.put(Constants.METATYPE, "*");
    map.put(Constants.PLUGIN, StringUtil.merge(_BND_PLUGIN_CLASS_NAMES, ","));
    map.put(Constants.SOURCES, "false");

    map.put("Git-Descriptor", "${system-allow-fail;git describe --dirty --always}");
    map.put("Git-SHA", "${system-allow-fail;git rev-list -1 HEAD}");

    JavaCompile javaCompile =
        (JavaCompile) GradleUtil.getTask(project, JavaPlugin.COMPILE_JAVA_TASK_NAME);

    CompileOptions compileOptions = javaCompile.getOptions();

    map.put("Javac-Debug", _getOnOffValue(compileOptions.isDebug()));
    map.put("Javac-Deprecation", _getOnOffValue(compileOptions.isDeprecation()));

    String encoding = compileOptions.getEncoding();

    if (Validator.isNull(encoding)) {
      encoding = System.getProperty("file.encoding");
    }

    map.put("Javac-Encoding", encoding);

    map.put("-jsp", "*.jsp,*.jspf");
    map.put("-sass", "*");

    return map;
  }
Ejemplo n.º 6
0
  private String _removeTrailingSlash(String path) {
    if (Validator.isNull(path)) {
      return path;
    }

    path = path.replace('\\', '/');

    if (path.charAt(path.length() - 1) == '/') {
      path = path.substring(0, path.length() - 1);
    }

    return path;
  }
Ejemplo n.º 7
0
  private String _removeLeadingSlash(String path) {
    if (Validator.isNull(path)) {
      return path;
    }

    path = path.replace('\\', '/');

    if (path.charAt(0) == '/') {
      path = path.substring(1);
    }

    return path;
  }
Ejemplo n.º 8
0
  private String _addTrailingSlash(String path) {
    if (Validator.isNull(path)) {
      return path;
    }

    path = path.replace('\\', '/');

    if (path.charAt(path.length() - 1) != '/') {
      path += '/';
    }

    return path;
  }
  @Override
  protected List<String> getCompleteArgs() {
    List<String> completeArgs = super.getCompleteArgs();

    File cacheDir = getCacheDir();

    if (cacheDir != null) {
      completeArgs.add("--cache");
      completeArgs.add(FileUtil.getAbsolutePath(cacheDir));
    }

    String logLevel = null;

    Logger logger = getLogger();

    if (logger.isTraceEnabled()) {
      logLevel = "silly";
    } else if (logger.isDebugEnabled()) {
      logLevel = "verbose";
    } else if (logger.isInfoEnabled()) {
      logLevel = "info";
    } else if (logger.isWarnEnabled()) {
      logLevel = "warn";
    } else if (logger.isErrorEnabled()) {
      logLevel = "error";
    }

    if (logLevel != null) {
      completeArgs.add("--loglevel");
      completeArgs.add(logLevel);
    }

    completeArgs.add("--progress");
    completeArgs.add(Boolean.toString(isProgress()));

    if (isInheritProxy()) {
      addProxyArg(completeArgs, "--proxy", "http");
      addProxyArg(completeArgs, "--https-proxy", "https");
    }

    String registry = getRegistry();

    if (Validator.isNotNull(registry)) {
      completeArgs.add("--registry");
      completeArgs.add(registry);
    }

    return completeArgs;
  }
  private void _configureTaskAppJavadoc(Project project, String appTitle, String appVersion) {

    Javadoc javadoc =
        (Javadoc) GradleUtil.getTask(project, AppJavadocBuilderPlugin.APP_JAVADOC_TASK_NAME);

    File portalRootDir = GradleUtil.getRootDir(project.getRootProject(), "portal-impl");

    if (portalRootDir != null) {
      File stylesheetFile = new File(portalRootDir, "tools/styles/javadoc.css");

      if (stylesheetFile.exists()) {
        StandardJavadocDocletOptions standardJavadocDocletOptions =
            (StandardJavadocDocletOptions) javadoc.getOptions();

        standardJavadocDocletOptions.setStylesheetFile(stylesheetFile);
      }
    }

    if (Validator.isNotNull(appTitle) && Validator.isNotNull(appVersion)) {
      String title = String.format("%s %s API", appTitle, appVersion);

      javadoc.setTitle(title);
    }
  }
  protected Set<Path> getDirPaths(String key, Path rootDirPath) {
    String dirNamesString = System.getProperty(key);

    if (Validator.isNull(dirNamesString)) {
      return Collections.emptySet();
    }

    Set<Path> dirPaths = new HashSet<>();

    for (String dirName : dirNamesString.split(",")) {
      dirPaths.add(rootDirPath.resolve(dirName));
    }

    return dirPaths;
  }
Ejemplo n.º 12
0
  protected List<String> getCompleteArgs() {
    List<String> args = new ArrayList<>(getArgs());

    List<String> dirNames = getDirNames();

    if (dirNames.size() == 1) {
      args.add("sass.dir=/" + _removeLeadingSlash(dirNames.get(0)));
    } else {
      for (int i = 0; i < dirNames.size(); i++) {
        String dirName = dirNames.get(i);

        args.add("sass.dir." + i + "=/" + _removeLeadingSlash(dirName));
      }
    }

    String docrootDirName = FileUtil.getAbsolutePath(getDocrootDir());

    args.add("sass.docroot.dir=" + _removeTrailingSlash(docrootDirName));

    args.add("sass.generate.source.map=" + isGenerateSourceMap());

    args.add("sass.output.dir=" + _addTrailingSlash(getOutputDirName()));

    String portalCommonPath = FileUtil.getAbsolutePath(getPortalCommonPath());

    args.add("sass.portal.common.path=" + portalCommonPath);

    args.add("sass.precision=" + getPrecision());

    String rtlExcludedPathRegexps = CollectionUtils.join(",", getRtlExcludedPathRegexps());

    args.add("sass.rtl.excluded.path.regexps=" + rtlExcludedPathRegexps);

    String sassCompilerClassName = getSassCompilerClassName();

    if (Validator.isNotNull(sassCompilerClassName)) {
      args.add("sass.compiler.class.name=" + sassCompilerClassName);
    }

    return args;
  }
Ejemplo n.º 13
0
  public static boolean removeIgnoredFiles(Project project, SortedSet<File> files) {

    if (files.isEmpty()) {
      return false;
    }

    File rootDir = null;

    File firstFile = files.first();

    if (files.size() == 1) {
      rootDir = firstFile.getParentFile();
    } else {
      String dirName =
          StringUtil.getCommonPrefix(
              '/', _getCanonicalPath(firstFile), _getCanonicalPath(files.last()));

      if (Validator.isNotNull(dirName)) {
        rootDir = new File(dirName);
      }
    }

    if (rootDir == null) {
      if (_logger.isWarnEnabled()) {
        _logger.warn(
            "Unable to remove ignored files, common parent directory " + "cannot be found");
      }

      return false;
    }

    String result =
        _getGitResult(
            project,
            rootDir,
            "ls-files",
            "--cached",
            "--deleted",
            "--exclude-standard",
            "--modified",
            "--others",
            "-z");

    if (Validator.isNull(result)) {
      if (_logger.isWarnEnabled()) {
        _logger.warn("Unable to remove ignored files, Git returned an empty " + "result");
      }

      return false;
    }

    String[] committedFileNames = result.split("\\000");

    Set<File> committedFiles = new HashSet<>();

    for (String fileName : committedFileNames) {
      committedFiles.add(new File(rootDir, fileName));
    }

    return files.retainAll(committedFiles);
  }