Java Code Examples for org.apache.maven.shared.utils.StringUtils

The following examples show how to use org.apache.maven.shared.utils.StringUtils. These examples are extracted from open source projects. 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 Project: syndesis   Source File: GenerateConnectorInspectionsMojo.java    License: Apache License 2.0 6 votes vote down vote up
private DataShape generateInspections(Connector connector, DataShape shape) throws IOException, DependencyResolutionRequiredException, ClassNotFoundException {
    if (DataShapeKinds.JAVA != shape.getKind() || StringUtils.isEmpty(shape.getType())) {
        return shape;
    }

    getLog().info("Generating inspections for connector: " + connector.getId().get() + ", and type: " + shape.getType());

    final List<String> elements = project.getRuntimeClasspathElements();
    final URL[] classpath = new URL[elements.size()];

    for (int i = 0; i < elements.size(); i++) {
        classpath[i] = new File(elements.get(i)).toURI().toURL();
    }

    return generateInspections(classpath, shape);
}
 
Example 2
Source Project: docker-maven-plugin   Source File: ConfigHelper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Resolve image with an external image resolver
 *
 * @param images the original image config list (can be null)
 * @param imageResolver the resolver used to extend on an image configuration
 * @param imageNameFilter filter to select only certain image configurations with the given name
 * @param imageCustomizer final customization hook for mangling the configuration
 * @return a list of resolved and customized image configuration.
 */
public static List<ImageConfiguration> resolveImages(Logger logger,
                                                     List<ImageConfiguration> images,
                                                     Resolver imageResolver,
                                                     String imageNameFilter,
                                                     Customizer imageCustomizer) {
    List<ImageConfiguration> ret = resolveConfiguration(imageResolver, images);
    ret = imageCustomizer.customizeConfig(ret);
    List<ImageConfiguration> filtered =  filterImages(imageNameFilter,ret);
    if (ret.size() > 0 && filtered.size() == 0 && imageNameFilter != null) {
        List<String> imageNames = new ArrayList<>();
        for (ImageConfiguration image : ret) {
            imageNames.add(image.getName());
        }
        logger.warn("None of the resolved images [%s] match the configured filter '%s'",
                    StringUtils.join(imageNames.iterator(), ","), imageNameFilter);
    }
    return filtered;
}
 
Example 3
Source Project: vertx-maven-plugin   Source File: VertxMojoTestBase.java    License: Apache License 2.0 5 votes vote down vote up
void filter(File input, Map<String, String> variables) throws IOException {
    assertThat(input).isFile();
    String data = FileUtils.readFileToString(input, "UTF-8");

    for (String token : variables.keySet()) {
        String value = String.valueOf(variables.get(token));
        data = StringUtils.replace(data, token, value);
    }
    FileUtils.write(input, data, "UTF-8");
}
 
Example 4
Source Project: syndesis   Source File: RepackageExtensionMojo.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Collection<ArtifactsFilter> getAdditionalFilters() {
    final Collection<Dependency> dependencies = new HashSet<>();

    if (StringUtils.isNotBlank(blackListedBoms)) {
        addCustomBoms(dependencies);
    } else {
        addDefaultBOMs(dependencies);
    }

    if (StringUtils.isNotBlank(blackListedGAVs)) {
        addCustomDependencies(dependencies);
    } else {
        addDefaultDependencies(dependencies);
    }

    if (getLog().isDebugEnabled()) {
        getLog().debug("Filtering out dependencies from the following BOMs: " + bomsUsed);
        getLog().debug("Dependencies to be filtered out:");
        dependencies.stream().map(d -> d.getArtifact()).sorted(Comparator.comparing(Artifact::toString))
            .forEach(a -> getLog().debug(a.toString()));
    }
    final List<ArtifactsFilter> filters = new ArrayList<>(dependencies.size());

    dependencies.forEach(d -> filters.add(newExcludeFilter(d)));

    return filters;
}
 
Example 5
Source Project: vertx-maven-plugin   Source File: VertxMojoTestBase.java    License: Apache License 2.0 5 votes vote down vote up
void filter(File input, Map<String, String> variables) throws IOException {
    assertThat(input).isFile();
    String data = FileUtils.readFileToString(input, "UTF-8");

    for (String token : variables.keySet()) {
        String value = String.valueOf(variables.get(token));
        data = StringUtils.replace(data, token, value);
    }
    FileUtils.write(input, data, "UTF-8");
}
 
Example 6
Source Project: webstart   Source File: AbstractGenerator.java    License: MIT License 5 votes vote down vote up
/**
 * Add {@code level} space caracteres at the begin of each lines of the
 * given {@code text}.
 *
 * @param level the number of space caracteres to add
 * @param text  the text to prefix
 * @return the indented text
 */
protected String indentText( int level, String text )
{
    StringBuilder buffer = new StringBuilder();
    String[] lines = text.split( "\n" );
    String prefix = StringUtils.leftPad( "", level );
    for ( String line : lines )
    {
        buffer.append( prefix ).append( line ).append( EOL );
    }
    return buffer.toString();
}
 
Example 7
Source Project: webstart   Source File: SignConfig.java    License: MIT License 5 votes vote down vote up
private void generateArguments()
{
    // TODO: add support for proxy parameters to JarSigner / JarSignerSignRequest
    // instead of using implementation-specific additional arguments
    if ( httpProxyHost != null )
    {
        arguments.add( "-J-Dhttp.proxyHost=" + httpProxyHost );
    }

    if ( httpProxyPort != null )
    {
        arguments.add( "-J-Dhttp.proxyPort=" + httpProxyPort );
    }

    if ( httpsProxyHost != null )
    {
        arguments.add( "-J-Dhttps.proxyHost=" + httpsProxyHost );
    }

    if ( httpsProxyPort != null )
    {
        arguments.add( "-J-Dhttps.proxyPort=" + httpsProxyPort );
    }

    if ( !StringUtils.isEmpty( this.digestalg ) )
    {
        arguments.add( "-digestalg" );
        arguments.add( this.digestalg );
    }
}
 
Example 8
Source Project: docker-maven-plugin   Source File: WaitService.java    License: Apache License 2.0 5 votes vote down vote up
private String extractCheckerLog(List<WaitChecker> checkers) {
    List<String> logOut = new ArrayList<>();
    for (WaitChecker checker : checkers) {
        logOut.add(checker.getLogLabel());
    }
    return StringUtils.join(logOut.toArray(), " and ");
}
 
Example 9
private boolean isCompileOrRuntime(Artifact artifact) {
    return StringUtils.equals(artifact.getScope(), DefaultArtifact.SCOPE_COMPILE)
        || StringUtils.equals(artifact.getScope(), DefaultArtifact.SCOPE_RUNTIME);
}
 
Example 10
private static String emptyToNull(final String s) {
    return StringUtils.isBlank(s) ? null : s;
}
 
Example 11
Source Project: aem-eclipse-developer-tools   Source File: PropUtilsTest.java    License: Apache License 2.0 4 votes vote down vote up
private String pad(Object obj) {
	return StringUtils.rightPad(StringUtils.defaultString(String.valueOf(obj), ""), 30);
}
 
Example 12
Source Project: docker-maven-plugin   Source File: ExternalCommand.java    License: Apache License 2.0 4 votes vote down vote up
protected String getCommandAsString() {
    return StringUtils.join(getArgs(), " ");
}