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); } }
@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); } }
@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); } }
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; }
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; }
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); }