Java Code Examples for org.codehaus.plexus.util.StringUtils#join()
The following examples show how to use
org.codehaus.plexus.util.StringUtils#join() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileSystemUtilities.java From jaxb2-maven-plugin with Apache License 2.0 | 5 votes |
private static void validateFileOrDirectoryName(final File fileOrDir) { if (Os.isFamily(Os.FAMILY_WINDOWS) && !FileUtils.isValidWindowsFileName(fileOrDir)) { throw new IllegalArgumentException( "The file (" + fileOrDir + ") cannot contain any of the following characters: \n" + StringUtils.join(INVALID_CHARACTERS_FOR_WINDOWS_FILE_NAME, " ")); } }
Example 2
Source File: DockerFileBuilder.java From docker-maven-plugin with Apache License 2.0 | 5 votes |
private void addOptimisation() { if (runCmds != null && !runCmds.isEmpty() && shouldOptimise) { String optimisedRunCmd = StringUtils.join(runCmds.iterator(), " && "); runCmds.clear(); runCmds.add(optimisedRunCmd); } }
Example 3
Source File: JavaFXJLinkMojo.java From javafx-maven-plugin with Apache License 2.0 | 4 votes |
private List<String> createCommandArguments() throws MojoExecutionException, MojoFailureException { List<String> commandArguments = new ArrayList<>(); preparePaths(getParent(Paths.get(jlinkExecutable), 2)); if (modulepathElements != null && !modulepathElements.isEmpty()) { commandArguments.add(" --module-path"); String modulePath = StringUtils.join(modulepathElements.iterator(), File.pathSeparator); if (jmodsPath != null && ! jmodsPath.isEmpty()) { getLog().debug("Including jmods from local path: " + jmodsPath); modulePath = jmodsPath + File.pathSeparator + modulePath; } commandArguments.add(modulePath); commandArguments.add(" --add-modules"); if (moduleDescriptor != null) { commandArguments.add(" " + moduleDescriptor.name()); } else { throw new MojoExecutionException("jlink requires a module descriptor"); } } commandArguments.add(" --output"); File image = new File(builddir, jlinkImageName); getLog().debug("image output: " + image.getAbsolutePath()); if (image.exists()) { try { Files.walk(image.toPath()) .sorted(Comparator.reverseOrder()) .map(Path::toFile) .forEach(File::delete); } catch (IOException e) { throw new MojoExecutionException("Image can't be removed " + image.getAbsolutePath(), e); } } commandArguments.add(" " + image.getAbsolutePath()); if (stripDebug) { commandArguments.add(" --strip-debug"); } if (stripJavaDebugAttributes) { commandArguments.add(" --strip-java-debug-attributes"); } if (bindServices) { commandArguments.add(" --bind-services"); } if (ignoreSigningInformation) { commandArguments.add(" --ignore-signing-information"); } if (compress != null) { commandArguments.add(" --compress"); if (compress < 0 || compress > 2) { throw new MojoFailureException("The given compress parameters " + compress + " is not in the valid value range from 0..2"); } commandArguments.add(" " + compress); } if (noHeaderFiles) { commandArguments.add(" --no-header-files"); } if (noManPages) { commandArguments.add(" --no-man-pages"); } if (jlinkVerbose) { commandArguments.add(" --verbose"); } if (launcher != null && ! launcher.isEmpty()) { commandArguments.add(" --launcher"); String moduleMainClass; if (mainClass.contains("/")) { moduleMainClass = mainClass; } else { moduleMainClass = moduleDescriptor.name() + "/" + mainClass; } commandArguments.add(" " + launcher + "=" + moduleMainClass); } return commandArguments; }
Example 4
Source File: JavaFXRunMojo.java From javafx-maven-plugin with Apache License 2.0 | 4 votes |
private List<String> createCommandArguments(boolean oldJDK) throws MojoExecutionException { List<String> commandArguments = new ArrayList<>(); preparePaths(getParent(Paths.get(executable), 2)); if (options != null) { options.stream() .filter(Objects::nonNull) .filter(String.class::isInstance) .map(String.class::cast) .map(this::splitComplexArgumentString) .flatMap(Collection::stream) .forEach(commandArguments::add); } if (!oldJDK) { if (modulepathElements != null && !modulepathElements.isEmpty()) { commandArguments.add(" --module-path"); String modulePath = StringUtils.join(modulepathElements.iterator(), File.pathSeparator); commandArguments.add(modulePath); commandArguments.add(" --add-modules"); if (moduleDescriptor != null) { commandArguments.add(" " + moduleDescriptor.name()); } else { String modules = pathElements.values().stream() .filter(Objects::nonNull) .map(JavaModuleDescriptor::name) .filter(Objects::nonNull) .filter(module -> module.startsWith(JAVAFX_PREFIX) && !module.endsWith("Empty")) .collect(Collectors.joining(",")); commandArguments.add(" " + modules); } } } if (classpathElements != null && (oldJDK || !classpathElements.isEmpty())) { commandArguments.add(" -classpath"); String classpath = ""; if (oldJDK || moduleDescriptor != null) { classpath = project.getBuild().getOutputDirectory() + File.pathSeparator; } classpath += StringUtils.join(classpathElements.iterator(), File.pathSeparator); commandArguments.add(classpath); } if (mainClass != null) { if (moduleDescriptor != null) { commandArguments.add(" --module"); if (mainClass.contains("/")) { commandArguments.add(" " + mainClass); } else { getLog().warn("Main module name not found in <mainClass>. Module name will be assumed from module-info.java"); commandArguments.add(" " + moduleDescriptor.name() + "/" + mainClass); } } else { commandArguments.add(" " + mainClass); } } if (commandlineArgs != null) { commandArguments.add(commandlineArgs); } return commandArguments; }
Example 5
Source File: AbstractAjcCompiler.java From aspectj-maven-plugin with MIT License | 4 votes |
/** * Assembles a complete ajc compiler arguments list. * * @throws MojoExecutionException error in configuration */ protected void assembleArguments() throws MojoExecutionException { if (XhasMember) { ajcOptions.add("-XhasMember"); } // Add classpath ajcOptions.add("-classpath"); ajcOptions.add(AjcHelper.createClassPath(project, null, getClasspathDirectories())); // Add boot classpath if (null != bootclasspath) { ajcOptions.add("-bootclasspath"); ajcOptions.add(bootclasspath); } if (null != Xjoinpoints) { ajcOptions.add("-Xjoinpoints:" + Xjoinpoints); } // Add warn option if (null != warn) { ajcOptions.add("-warn:" + warn); } if (null != proc) { ajcOptions.add("-proc:" + proc); } if (Xset != null && !Xset.isEmpty()) { StringBuilder sb = new StringBuilder("-Xset:"); for (Map.Entry<String, String> param : Xset.entrySet()) { sb.append(param.getKey()); sb.append("="); sb.append(param.getValue()); sb.append(','); } ajcOptions.add(sb.substring(0, sb.length() - 1)); } // Add artifacts or directories to weave String joinedWeaveDirectories = null; if (weaveDirectories != null) { joinedWeaveDirectories = StringUtils.join(weaveDirectories, File.pathSeparator); } addModulesArgument("-inpath", ajcOptions, weaveDependencies, joinedWeaveDirectories, "dependencies and/or directories to weave"); // Add library artifacts addModulesArgument("-aspectpath", ajcOptions, aspectLibraries, getAdditionalAspectPaths(), "an aspect library"); // Add xmlConfigured option and argument if (null != xmlConfigured) { ajcOptions.add("-xmlConfigured"); ajcOptions.add(xmlConfigured.getAbsolutePath()); } // add target dir argument ajcOptions.add("-d"); ajcOptions.add(getOutputDirectory().getAbsolutePath()); ajcOptions.add("-s"); ajcOptions.add(getGeneratedSourcesDirectory().getAbsolutePath()); // Add all the files to be included in the build, if (null != ajdtBuildDefFile) { resolvedIncludes = AjcHelper.getBuildFilesForAjdtFile(ajdtBuildDefFile, basedir); } else { resolvedIncludes = getIncludedSources(); } ajcOptions.addAll(resolvedIncludes); }
Example 6
Source File: Java2WSMojo.java From cxf with Apache License 2.0 | 4 votes |
public void execute() throws MojoExecutionException { boolean requiresModules = JavaUtils.isJava9Compatible(); if (requiresModules) { // Since JEP 261 ("Jigsaw"), access to some packages must be granted fork = true; boolean skipXmlWsModule = JavaUtils.isJava11Compatible(); // additionalJvmArgs = "--add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED " + "--add-exports=java.xml/com.sun.org.apache.xerces.internal.impl.xs=ALL-UNNAMED " + (skipXmlWsModule ? "" : "--add-opens java.xml.ws/javax.xml.ws.wsaddressing=ALL-UNNAMED ") + "--add-opens java.base/java.security=ALL-UNNAMED " + "--add-opens java.base/java.net=ALL-UNNAMED " + "--add-opens java.base/java.lang=ALL-UNNAMED " + "--add-opens java.base/java.util=ALL-UNNAMED " + "--add-opens java.base/java.util.concurrent=ALL-UNNAMED " + (additionalJvmArgs == null ? "" : additionalJvmArgs); } if (fork && SystemUtils.IS_OS_WINDOWS) { // Windows does not allow for very long command lines, // so by default CLASSPATH environment variable is used. classpathAsEnvVar = true; } System.setProperty("org.apache.cxf.JDKBugHacks.defaultUsesCaches", "true"); if (skip) { getLog().info("Skipping Java2WS execution"); return; } ClassLoaderSwitcher classLoaderSwitcher = new ClassLoaderSwitcher(getLog()); try { String cp = classLoaderSwitcher.switchClassLoader(project, false, classpath, classpathElements); if (fork) { List<String> artifactsPath = new ArrayList<>(pluginArtifacts.size()); for (Artifact a : pluginArtifacts) { File file = a.getFile(); if (file == null) { throw new MojoExecutionException("Unable to find file for artifact " + a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion()); } artifactsPath.add(file.getPath()); } cp = StringUtils.join(artifactsPath.iterator(), File.pathSeparator) + File.pathSeparator + cp; } List<String> args = initArgs(classpathAsEnvVar ? null : cp); processJavaClass(args, classpathAsEnvVar ? cp : null); } finally { classLoaderSwitcher.restoreClassLoader(); } if (!skipGarbageCollection) { System.gc(); } }
Example 7
Source File: EclipselinkModelGenMojo.java From eclipselink-maven-plugin with Apache License 2.0 | 4 votes |
@Override public void execute() throws MojoExecutionException, MojoFailureException { if (!this.skip) { final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); if (compiler == null) { throw new MojoExecutionException("You need to run build with JDK or have tools.jar on the classpath"); } try (final StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null)) { final Set<File> sourceFiles = getSourceFiles(); if (sourceFiles.isEmpty()) { info("No files to process"); return; } info("Found " + sourceFiles.size() + " source files for potential processing"); debug("Source files: " + Arrays.toString(sourceFiles.toArray())); Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(sourceFiles); final File[] classPathFiles = getClassPathFiles(); final String compileClassPath = StringUtils.join(classPathFiles, File.pathSeparator); debug("Classpath: " + compileClassPath); List<String> compilerOptions = buildCompilerOptions(processor, compileClassPath); project.addCompileSourceRoot(this.generatedSourcesDirectory.getAbsolutePath()); final DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>(); final CompilationTask task = compiler.getTask(null, fileManager, diagnostics, compilerOptions, null, compilationUnits); final Boolean retVal = task.call(); final StringBuilder s = new StringBuilder(); for (Diagnostic<?> diagnostic : diagnostics.getDiagnostics()) { s.append("\n" + diagnostic); } if (!retVal) { throw new MojoExecutionException("Processing failed: " + s.toString()); } buildContext.refresh(this.generatedSourcesDirectory); } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); } } }
Example 8
Source File: SignCodeMojo.java From sling-whiteboard with Apache License 2.0 | 2 votes |
public String getCommaSeparatedUploadFileNames() { return StringUtils.join(fileNameMapping.keySet().iterator(), ","); }