org.codehaus.plexus.util.StringUtils Java Examples
The following examples show how to use
org.codehaus.plexus.util.StringUtils.
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: EnvStreamConsumer.java From maven-native with MIT License | 6 votes |
@Override public void consumeLine( String line ) { if ( line.startsWith( START_PARSING_INDICATOR ) ) { this.startParsing = true; return; } if ( this.startParsing ) { String[] tokens = StringUtils.split( line, "=" ); if ( tokens.length == 2 ) { envs.put( tokens[0], tokens[1] ); } } else { System.out.println( line ); } }
Example #2
Source File: StartContainerExecutor.java From docker-maven-plugin with Apache License 2.0 | 6 votes |
private void exposeContainerProps(String containerId) throws DockerAccessException { String propKey = getExposedPropertyKeyPart(); if (StringUtils.isNotEmpty(exposeContainerProps) && StringUtils.isNotEmpty(propKey)) { Container container = hub.getQueryService().getMandatoryContainer(containerId); String prefix = addDot(exposeContainerProps) + addDot(propKey); projectProperties.put(prefix + "id", containerId); String ip = container.getIPAddress(); if (StringUtils.isNotEmpty(ip)) { projectProperties.put(prefix + "ip", ip); } Map<String, String> nets = container.getCustomNetworkIpAddresses(); if (nets != null) { for (Map.Entry<String, String> entry : nets.entrySet()) { projectProperties.put(prefix + addDot("net") + addDot(entry.getKey()) + "ip", entry.getValue()); } } } }
Example #3
Source File: FormattedPropertiesTest.java From appassembler with MIT License | 6 votes |
private void saveAndCompare( String expectedResource ) throws IOException { StringOutputStream string = new StringOutputStream(); formattedProperties.save( string ); StringOutputStream expected = new StringOutputStream(); InputStream asStream = getClass().getResourceAsStream( expectedResource ); try { IOUtil.copy( asStream, expected ); } finally { IOUtil.close( asStream ); } String unified = StringUtils.unifyLineSeparators( expected.toString() ); assertEquals( unified, string.toString() ); }
Example #4
Source File: StagerMojo.java From helidon-build-tools with Apache License 2.0 | 6 votes |
@Override public void unpack(Path archive, Path target, String excludes, String includes) { File archiveFile = archive.toFile(); UnArchiver unArchiver = null; try { unArchiver = archiverManager.getUnArchiver(archiveFile); } catch (NoSuchArchiverException ex) { throw new IllegalStateException(ex); } unArchiver.setSourceFile(archiveFile); unArchiver.setDestDirectory(target.toFile()); if (StringUtils.isNotEmpty(excludes) || StringUtils.isNotEmpty(includes)) { IncludeExcludeFileSelector[] selectors = new IncludeExcludeFileSelector[]{ new IncludeExcludeFileSelector() }; if (StringUtils.isNotEmpty(excludes)) { selectors[0].setExcludes(excludes.split(",")); } if (StringUtils.isNotEmpty(includes)) { selectors[0].setIncludes(includes.split(",")); } unArchiver.setFileSelectors(selectors); } unArchiver.extract(); }
Example #5
Source File: AssembleMojo.java From appassembler with MIT License | 6 votes |
private JvmSettings convertToJvmSettingsWithDefaultHandling( Program program ) { JvmSettings jvmSettings = new JvmSettings(); if ( program.getJvmSettings() != null ) { // Some kind of settings done on per program base so they take // precendence. jvmSettings = program.getJvmSettings(); } else { // No settings in the program done so we use the default behaviour if ( StringUtils.isNotBlank( this.extraJvmArguments ) ) { jvmSettings.setExtraArguments( parseTokens( this.extraJvmArguments ) ); } } return jvmSettings; }
Example #6
Source File: CreateMetadataMojo.java From buildnumber-maven-plugin with MIT License | 6 votes |
public String getRevision() throws MojoExecutionException { try { return this.getScmRevision(); } catch ( ScmException e ) { if ( !StringUtils.isEmpty( revisionOnScmFailure ) ) { getLog().warn( "Cannot get the revision information from the scm repository, proceeding with " + "revision of " + revisionOnScmFailure + " : \n" + e.getLocalizedMessage() ); return revisionOnScmFailure; } throw new MojoExecutionException( "Cannot get the revision information from the scm repository : \n" + e.getLocalizedMessage(), e ); } }
Example #7
Source File: License.java From sonarqube-licensecheck with Apache License 2.0 | 6 votes |
/** * @deprecated remove with later release * @param serializedLicensesString setting string * @return a list with licences */ @Deprecated private static List<License> readLegacySeparated(String serializedLicensesString) { List<License> licenses = new ArrayList<>(); if (StringUtils.isNotEmpty(serializedLicensesString)) { String[] parts = serializedLicensesString.split(";"); for (String licenseString : parts) { String[] subParts = licenseString.split("~"); String name = subParts.length > 0 ? subParts[0] : null; String identifier = subParts.length > 1 ? subParts[1] : null; String status = subParts.length > 2 ? subParts[2] : null; licenses.add(new License(name, identifier, status)); } } return licenses; }
Example #8
Source File: DefaultArtifactDownloader.java From opoopress with Apache License 2.0 | 6 votes |
private ArtifactRepository parseRepository(String repo, ArtifactRepositoryPolicy policy) throws MojoFailureException { // if it's a simple url String id = null; ArtifactRepositoryLayout layout = getLayout("default"); String url = repo; // if it's an extended repo URL of the form id::layout::url if (repo.contains("::")) { Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher(repo); if (!matcher.matches()) { throw new MojoFailureException(repo, "Invalid syntax for repository: " + repo, "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\"."); } id = matcher.group(1).trim(); if (!StringUtils.isEmpty(matcher.group(2))) { layout = getLayout(matcher.group(2).trim()); } url = matcher.group(3).trim(); } return artifactRepositoryFactory.createArtifactRepository(id, url, layout, policy, policy); }
Example #9
Source File: AbstractInvisibleProjectBasedTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
protected IProject importRootFolder(IPath rootPath, String triggerFile) throws Exception { if (StringUtils.isNotBlank(triggerFile)) { IPath triggerFilePath = rootPath.append(triggerFile); Preferences preferences = preferenceManager.getPreferences(); preferences.setTriggerFiles(Arrays.asList(triggerFilePath)); } final List<IPath> roots = Arrays.asList(rootPath); IWorkspaceRunnable runnable = new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { projectsManager.initializeProjects(roots, monitor); } }; JavaCore.run(runnable, null, monitor); waitForBackgroundJobs(); String invisibleProjectName = ProjectUtils.getWorkspaceInvisibleProjectName(rootPath); return ResourcesPlugin.getWorkspace().getRoot().getProject(invisibleProjectName); }
Example #10
Source File: EnvStreamConsumer.java From exec-maven-plugin with Apache License 2.0 | 6 votes |
public void consumeLine( String line ) { if ( line.startsWith( START_PARSING_INDICATOR ) ) { this.startParsing = true; return; } if ( this.startParsing ) { String[] tokens = StringUtils.split( line, "=" ); if ( tokens.length == 2 ) { envs.put( tokens[0], tokens[1] ); } } else { System.out.println( line ); } }
Example #11
Source File: MySQLMessageQueueStorage.java From hermes with Apache License 2.0 | 6 votes |
private Map<String, String> getAppProperties(ByteBuf buf) { Map<String, String> map = new HashMap<>(); if (buf != null) { HermesPrimitiveCodec codec = new HermesPrimitiveCodec(buf); byte firstByte = codec.readByte(); if (HermesPrimitiveCodec.NULL != firstByte) { codec.readerIndexBack(1); int length = codec.readInt(); if (length > 0) { for (int i = 0; i < length; i++) { String key = codec.readSuffixStringWithPrefix(PropertiesHolder.APP, true); if (!StringUtils.isBlank(key)) { map.put(key, codec.readString()); } else { codec.skipString(); } } } } } return map; }
Example #12
Source File: ScmRenderer.java From maven-confluence-plugin with Apache License 2.0 | 6 votes |
/** * Create the documentation to provide an developer access with a * <code>Starteam</code> SCM. For example, generate the following command * line: * <p> * stcmd co -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl * -is * </p> * <p> * stcmd ci -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl * -f NCI -is * </p> * * @param starteamRepo */ private void developerAccessStarteam(StarteamScmProviderRepository starteamRepo) { paragraph(getI18nString("devaccess.starteam.intro")); StringBuilder command = new StringBuilder(); // Safety: remove the username/password if present String fullUrl = StringUtils.replace(starteamRepo.getFullUrl(), starteamRepo.getUser(), "username"); fullUrl = StringUtils.replace(fullUrl, starteamRepo.getPassword(), "password"); command.append("$ stcmd co -x -nologo -stop -p "); command.append(fullUrl); command.append(" -is"); command.append(SystemUtils.LINE_SEPARATOR); command.append("$ stcmd ci -x -nologo -stop -p "); command.append(fullUrl); command.append(" -f NCI -is"); verbatimText(command.toString()); }
Example #13
Source File: UusimispyyntoKasaaja.java From KantaCDA-API with Apache License 2.0 | 6 votes |
@Override protected void addRelatedDocument(POCDMT000040ClinicalDocument clinicalDocument, String oid, String setid, String propertycode, XActRelationshipDocument relationType) { POCDMT000040RelatedDocument relatedDocument = of.createPOCDMT000040RelatedDocument(); relatedDocument.setTypeCode(relationType); relatedDocument.setParentDocument(of.createPOCDMT000040ParentDocument()); relatedDocument.getParentDocument().getIds().add(of.createII()); relatedDocument.getParentDocument().getIds().get(0).setRoot(oid); relatedDocument.getParentDocument().setCode(of.createCE()); fetchAttributes(propertycode, relatedDocument.getParentDocument().getCode()); clinicalDocument.getRelatedDocuments().add(relatedDocument); if ( !StringUtils.isEmpty(setid) ) { relatedDocument.getParentDocument().setSetId(of.createII()); relatedDocument.getParentDocument().getSetId().setRoot(setid); } }
Example #14
Source File: VndrParser.java From hub-detect with Apache License 2.0 | 6 votes |
public DependencyGraph parseVendorConf(final List<String> vendorConfContents) { final MutableDependencyGraph graph = new MutableMapDependencyGraph(); // TODO test against moby vendorConfContents.forEach(line -> { if (StringUtils.isNotBlank(line) && !line.startsWith("#")) { final String[] parts = line.split(" "); final ExternalId dependencyExternalId = externalIdFactory.createNameVersionExternalId(Forge.GOLANG, parts[0], parts[1]); final Dependency dependency = new Dependency(parts[0], parts[1], dependencyExternalId); graph.addChildToRoot(dependency); } }); return graph; }
Example #15
Source File: ThemeMojo.java From opoopress with Apache License 2.0 | 6 votes |
private void updateThemeConfigurationFile(SiteConfigImpl siteConfig, File themeDir) throws MojoFailureException{ File config = new File(themeDir, "theme.yml"); if (!config.exists()) { throw new MojoFailureException("Config file '" + config + "' not exists."); } Locale loc = Locale.getDefault(); //locale from parameter String localeString = locale; //locale from site configuration if(StringUtils.isBlank(localeString)){ localeString = siteConfig.get("locale"); } if (StringUtils.isNotEmpty(localeString)) { loc = LocaleUtils.toLocale(localeString); } File localeConfig = new File(themeDir, "theme_" + loc.toString() + ".yml"); if (localeConfig.exists()) { config.renameTo(new File(themeDir, "theme-original.yml")); localeConfig.renameTo(config); } }
Example #16
Source File: ModuleConvertor.java From netbeans with Apache License 2.0 | 6 votes |
private List<Token> getApplicableTokens(Map<String, String> moduleProps, String string) { String tokens = moduleProps.get(string); if (tokens == null) { return Arrays.asList(Token.values()); } String[] split = StringUtils.split(tokens, ","); List<Token> toRet = new ArrayList<Token>(); for (String val : split) { try { toRet.add(Token.valueOf(val.trim())); } catch (IllegalArgumentException e) { e.printStackTrace(); } } return toRet; }
Example #17
Source File: SourceJavadocByHash.java From netbeans with Apache License 2.0 | 6 votes |
public static @CheckForNull File[] find(@NonNull URL root, boolean javadoc) { String k = root.toString(); Preferences n = node(javadoc); String v = n.get(k, null); if (v == null) { return null; } String[] split = StringUtils.split(v, "||"); List<File> toRet = new ArrayList<File>(); for (String vv : split) { File f = FileUtilities.convertStringToFile(vv); if (f.isFile()) { toRet.add(f); } else { //what do we do when one of the possibly more files is gone? //in most cases we are dealing with exactly one file, so keep the //previous behaviour of removing it. n.remove(k); } } return toRet.toArray(new File[0]); }
Example #18
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor ) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List<String> scopes = new ArrayList<>( 2 ); if ( StringUtils.isNotEmpty( scopeToCollect ) ) { scopes.add( scopeToCollect ); } if ( StringUtils.isNotEmpty( scopeToResolve ) ) { scopes.add( scopeToResolve ); } if ( scopes.isEmpty() ) { return null; } else { return new CumulativeScopeArtifactFilter( scopes ); } }
Example #19
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
private ArtifactFilter getArtifactFilter(MojoDescriptor mojoDescriptor) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List<String> scopes = new ArrayList<String>(2); if (StringUtils.isNotEmpty(scopeToCollect)) { scopes.add(scopeToCollect); } if (StringUtils.isNotEmpty(scopeToResolve)) { scopes.add(scopeToResolve); } if (scopes.isEmpty()) { return null; } else { return new CumulativeScopeArtifactFilter(scopes); } }
Example #20
Source File: AbstractGitFlowMojo.java From gitflow-maven-plugin with Apache License 2.0 | 6 votes |
/** * Validates plugin configuration. Throws exception if configuration is not * valid. * * @param params * Configuration parameters to validate. * @throws MojoFailureException * If configuration is not valid. */ protected void validateConfiguration(String... params) throws MojoFailureException { if (StringUtils.isNotBlank(argLine) && MAVEN_DISALLOWED_PATTERN.matcher(argLine).find()) { throw new MojoFailureException( "The argLine doesn't match allowed pattern."); } if (params != null && params.length > 0) { for (String p : params) { if (StringUtils.isNotBlank(p) && MAVEN_DISALLOWED_PATTERN.matcher(p).find()) { throw new MojoFailureException("The '" + p + "' value doesn't match allowed pattern."); } } } }
Example #21
Source File: AbstractScmMojo.java From buildnumber-maven-plugin with MIT License | 6 votes |
/** * Get info from scm. * * @param repository * @param fileSet * @return * @throws ScmException * @todo this should be rolled into org.apache.maven.scm.provider.ScmProvider and * org.apache.maven.scm.provider.svn.SvnScmProvider */ protected InfoScmResult info( ScmRepository repository, ScmFileSet fileSet ) throws ScmException { CommandParameters commandParameters = new CommandParameters(); // only for Git, we will make a test for shortRevisionLength parameter if ( GitScmProviderRepository.PROTOCOL_GIT.equals( scmManager.getProviderByRepository( repository ).getScmType() ) && this.shortRevisionLength > 0 ) { getLog().info( "ShortRevision tag detected. The value is '" + this.shortRevisionLength + "'." ); if ( shortRevisionLength >= 0 && shortRevisionLength < 4 ) { getLog().warn( "shortRevision parameter less then 4. ShortRevisionLength is relaying on 'git rev-parese --short=LENGTH' command, accordingly to Git rev-parse specification the LENGTH value is miminum 4. " ); } commandParameters.setInt( CommandParameter.SCM_SHORT_REVISION_LENGTH, this.shortRevisionLength ); } if ( !StringUtils.isBlank( scmTag ) && !"HEAD".equals( scmTag ) ) { commandParameters.setScmVersion( CommandParameter.SCM_VERSION, new ScmTag( scmTag ) ); } return scmManager.getProviderByRepository( repository ).info( repository.getProviderRepository(), fileSet, commandParameters ); }
Example #22
Source File: DryRunMojo.java From helm-maven-plugin with MIT License | 6 votes |
public void execute() throws MojoExecutionException, MojoFailureException { if (skip || skipDryRun) { getLog().info("Skip dry run"); return; } for (String inputDirectory : getChartDirectories(getChartDirectory())) { getLog().info("\n\nPerform dry-run for chart " + inputDirectory + "..."); callCli(getHelmExecuteablePath() + " " + action + " " + inputDirectory + " --dry-run --generate-name" + (StringUtils.isNotEmpty(getRegistryConfig()) ? " --registry-config=" + getRegistryConfig() : "") + (StringUtils.isNotEmpty(getRepositoryCache()) ? " --repository-cache=" + getRepositoryCache() : "") + (StringUtils.isNotEmpty(getRepositoryConfig()) ? " --repository-config=" + getRepositoryConfig() : ""), "There are test failures", true); } }
Example #23
Source File: ScmMojo.java From pitest with Apache License 2.0 | 6 votes |
private String getSCMConnection() throws MojoExecutionException { if (this.getProject().getScm() == null) { throw new MojoExecutionException("No SCM Connection configured."); } final String scmConnection = this.getProject().getScm().getConnection(); if ("connection".equalsIgnoreCase(this.connectionType) && StringUtils.isNotEmpty(scmConnection)) { return scmConnection; } final String scmDeveloper = this.getProject().getScm().getDeveloperConnection(); if ("developerconnection".equalsIgnoreCase(this.connectionType) && StringUtils.isNotEmpty(scmDeveloper)) { return scmDeveloper; } throw new MojoExecutionException("SCM Connection is not set."); }
Example #24
Source File: SCoverageReportMojo.java From scoverage-maven-plugin with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public String getName( Locale locale ) { if ( StringUtils.isEmpty( name ) ) { return getBundle( locale ).getString( "report.scoverage.name" ); } return name; }
Example #25
Source File: MavenDependencyScanner.java From sonarqube-licensecheck with Apache License 2.0 | 5 votes |
private Function<Dependency, Dependency> loadLicenseFromPom(Map<Pattern, String> licenseMap, MavenSettings settings) { return (Dependency dependency) -> { if (StringUtils.isNotBlank(dependency.getLicense()) || dependency.getPomPath() == null) { return dependency; } return loadLicense(licenseMap, settings, dependency); }; }
Example #26
Source File: MojoExecutor.java From dew with Apache License 2.0 | 5 votes |
private Collection<String> toScopes( String classpath ) { Collection<String> scopes = Collections.emptyList(); if ( StringUtils.isNotEmpty( classpath ) ) { if ( Artifact.SCOPE_COMPILE.equals( classpath ) ) { scopes = Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED ); } else if ( Artifact.SCOPE_RUNTIME.equals( classpath ) ) { scopes = Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME ); } else if ( Artifact.SCOPE_COMPILE_PLUS_RUNTIME.equals( classpath ) ) { scopes = Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_RUNTIME ); } else if ( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM.equals( classpath ) ) { scopes = Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_RUNTIME ); } else if ( Artifact.SCOPE_TEST.equals( classpath ) ) { scopes = Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_TEST ); } } return Collections.unmodifiableCollection( scopes ); }
Example #27
Source File: MojoExecutor.java From dew with Apache License 2.0 | 5 votes |
private Collection<String> toScopes( String classpath ) { Collection<String> scopes = Collections.emptyList(); if ( StringUtils.isNotEmpty( classpath ) ) { if ( Artifact.SCOPE_COMPILE.equals( classpath ) ) { scopes = Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED ); } else if ( Artifact.SCOPE_RUNTIME.equals( classpath ) ) { scopes = Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME ); } else if ( Artifact.SCOPE_COMPILE_PLUS_RUNTIME.equals( classpath ) ) { scopes = Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_RUNTIME ); } else if ( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM.equals( classpath ) ) { scopes = Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_RUNTIME ); } else if ( Artifact.SCOPE_TEST.equals( classpath ) ) { scopes = Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_TEST ); } } return Collections.unmodifiableCollection( scopes ); }
Example #28
Source File: DependencyFactory.java From appassembler with MIT License | 5 votes |
/** * Used by GenericDaemonGenerator. * @param artifact {@link Artifact} * @param layout {@link ArtifactRepositoryLayout} * @param outputFileNameMapping The name mapping. * @return the dependency. */ public static Dependency create( Artifact artifact, ArtifactRepositoryLayout layout, String outputFileNameMapping ) { Dependency dependency = new Dependency(); dependency.setGroupId( artifact.getGroupId() ); dependency.setArtifactId( artifact.getArtifactId() ); dependency.setVersion( artifact.getVersion() ); dependency.setClassifier( artifact.getClassifier() ); String path = layout.pathOf( artifact ); if ( StringUtils.isNotEmpty( outputFileNameMapping ) ) { // Replace the file name part of the path with one that has been mapped File directory = new File( path ).getParentFile(); try { String fileName = MappingUtils.evaluateFileNameMapping( outputFileNameMapping, artifact ); File file = new File( directory, fileName ); // Always use forward slash as path separator, because that's what layout.pathOf( artifact ) uses path = file.getPath().replace( '\\', '/' ); } catch ( InterpolationException e ) { // TODO Handle exceptions! // throw new MojoExecutionException("Unable to map file name.", e); } } dependency.setRelativePath( path ); return dependency; }
Example #29
Source File: ExecMojo.java From exec-maven-plugin with Apache License 2.0 | 5 votes |
private List<String> getExecutablePaths( Map<String, String> enviro ) { List<String> paths = new ArrayList<String>(); paths.add( "" ); String path = enviro.get( "PATH" ); if ( path != null ) { paths.addAll( Arrays.asList( StringUtils.split( path, File.pathSeparator ) ) ); } return paths; }
Example #30
Source File: MdPageGeneratorMojo.java From markdown-page-generator-plugin with MIT License | 5 votes |
private String getOutputEncoding() { if (StringUtils.isBlank(outputEncoding)) { return Charset.defaultCharset().name(); } else { return outputEncoding; } }