/** * Adds the RUN Commands within the build image section * @param runCmds * @return */ public DockerFileBuilder run(List<String> runCmds) { if (runCmds != null) { for (String cmd : runCmds) { if (!StringUtils.isEmpty(cmd)) { this.runCmds.add(cmd); } } } return this; }
private boolean isSpecificVersion( String version ) { return !( StringUtils.isEmpty( version ) || version.startsWith( "[" ) || version.startsWith( "(" ) ); }
/** * <p> * Checks if String contains a search character, handling <code>null</code>. This method uses * {@link String#indexOf(int)}. * </p> * <p> * A <code>null</code> or empty ("") String will return <code>false</code>. * </p> * * <pre> * StringUtils.contains(null, *) = false * StringUtils.contains("", *) = false * StringUtils.contains("abc", 'a') = true * StringUtils.contains("abc", 'z') = false * </pre> * * @param str the String to check, may be null * @param searchChar the character to find * @return true if the String contains the search character, false if not or <code>null</code> string input * @since 1.5.7 */ public static boolean contains( String str, char searchChar ) { if ( isEmpty( str ) ) { return false; } return str.indexOf( searchChar ) >= 0; }
/** * This method can calculate the relative path between two paths on a web site. * * <pre> * PathTool.getRelativeWebPath( null, null ) = "" * PathTool.getRelativeWebPath( null, "http://plexus.codehaus.org/" ) = "" * PathTool.getRelativeWebPath( "http://plexus.codehaus.org/", null ) = "" * PathTool.getRelativeWebPath( "http://plexus.codehaus.org/", * "http://plexus.codehaus.org/plexus-utils/index.html" ) = "plexus-utils/index.html" * PathTool.getRelativeWebPath( "http://plexus.codehaus.org/plexus-utils/index.html", * "http://plexus.codehaus.org/" = "../../" * </pre> * * @param oldPath * @param newPath * @return a relative web path from <code>oldPath</code>. */ public static final String getRelativeWebPath( final String oldPath, final String newPath ) { if ( StringUtils.isEmpty( oldPath ) || StringUtils.isEmpty( newPath ) ) { return ""; } String resultPath = buildRelativePath( newPath, oldPath, '/' ); if ( newPath.endsWith( "/" ) && !resultPath.endsWith( "/" ) ) { return resultPath + "/"; } return resultPath; }
private void injectDependencyDefaults( List<Dependency> dependencies ) { for ( Dependency dependency : dependencies ) { if ( StringUtils.isEmpty( dependency.getScope() ) ) { // we cannot set this directly in the MDO due to the interactions with dependency management dependency.setScope( "compile" ); } } }
public void initialize() throws InitializationException { String mavenVersion = rtInfo.getMavenVersion(); if ( StringUtils.isEmpty( mavenVersion ) ) { throw new InitializationException( "Unable to read Maven version from maven-core" ); } applicationVersion = new DefaultArtifactVersion( mavenVersion ); }
private ArtifactRepository createLocalRepository( MavenExecutionRequest request ) throws MavenExecutionRequestPopulationException { String localRepositoryPath = null; if ( request.getLocalRepositoryPath() != null ) { localRepositoryPath = request.getLocalRepositoryPath().getAbsolutePath(); } if ( StringUtils.isEmpty( localRepositoryPath ) ) { localRepositoryPath = RepositorySystem.defaultUserLocalRepository.getAbsolutePath(); } try { return repositorySystem.createLocalRepository( request, new File( localRepositoryPath ) ); } catch ( Exception e ) { throw new MavenExecutionRequestPopulationException( "Cannot create local repository.", e ); } }
static Server decryptServer(String serverId, MavenSession mavenSession, SettingsDecrypter decrypter) { if (StringUtils.isEmpty(serverId)) { return null; } Server server = mavenSession.getSettings().getServer(serverId); if (server != null) { final DefaultSettingsDecryptionRequest decryptionRequest = new DefaultSettingsDecryptionRequest(server); SettingsDecryptionResult decryptedResult = decrypter.decrypt(decryptionRequest); return decryptedResult.getServer(); } else { LOGGER.warn("Could not find server '" + serverId + "' in settings.xml"); return null; } }
public List<TaskSegment> calculateTaskSegments( MavenSession session ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { MavenProject rootProject = session.getTopLevelProject(); List<String> tasks = session.getGoals(); if ( ( tasks == null || tasks.isEmpty() ) && !StringUtils.isEmpty( rootProject.getDefaultGoal() ) ) { tasks = Arrays.asList( StringUtils.split( rootProject.getDefaultGoal() ) ); } return calculateTaskSegments( session, tasks ); }
String getExposedPropertyKeyPart() { String propKey = imageConfig.getRunConfiguration() != null ? imageConfig.getRunConfiguration().getExposedPropertyKey() : ""; if (StringUtils.isEmpty(propKey)) { propKey = imageConfig.getAlias(); } return propKey; }
private void assembleScmInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths ) { if ( parent.getScm() != null ) { Scm parentScm = parent.getScm(); Scm childScm = child.getScm(); if ( childScm == null ) { childScm = new Scm(); child.setScm( childScm ); } if ( StringUtils.isEmpty( childScm.getConnection() ) && !StringUtils.isEmpty( parentScm.getConnection() ) ) { childScm.setConnection( appendPath( parentScm.getConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } if ( StringUtils.isEmpty( childScm.getDeveloperConnection() ) && !StringUtils.isEmpty( parentScm.getDeveloperConnection() ) ) { childScm .setDeveloperConnection( appendPath( parentScm.getDeveloperConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } if ( StringUtils.isEmpty( childScm.getUrl() ) && !StringUtils.isEmpty( parentScm.getUrl() ) ) { childScm.setUrl( appendPath( parentScm.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } } }
public Artifact createPluginArtifact( Plugin plugin ) { String version = plugin.getVersion(); if ( StringUtils.isEmpty( version ) ) { version = "RELEASE"; } VersionRange versionRange; try { versionRange = VersionRange.createFromVersionSpec( version ); } catch ( InvalidVersionSpecificationException e ) { // MNG-5368: Log a message instead of returning 'null' silently. this.logger.error( String.format( "Invalid version specification '%s' creating plugin artifact '%s'.", version, plugin ), e ); return null; } return artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange ); }
if ( StringUtils.isEmpty( p.getVersion() ) )
public Artifact createPluginArtifact( Plugin plugin ) { VersionRange versionRange; try { String version = plugin.getVersion(); if ( StringUtils.isEmpty( version ) ) { version = "RELEASE"; } versionRange = VersionRange.createFromVersionSpec( version ); } catch ( InvalidVersionSpecificationException e ) { return null; } return createPluginArtifactX( plugin.getGroupId(), plugin.getArtifactId(), versionRange ); }
public static ArtifactRepository buildArtifactRepository( org.apache.maven.model.Repository repo ) throws InvalidRepositoryException { if ( repo != null ) { String id = repo.getId(); if ( StringUtils.isEmpty( id ) ) { throw new InvalidRepositoryException( "Repository identifier missing", "" ); } String url = repo.getUrl(); if ( StringUtils.isEmpty( url ) ) { throw new InvalidRepositoryException( "URL missing for repository " + id, id ); } ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() ); ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repo.getReleases() ); ArtifactRepositoryLayout layout = new DefaultRepositoryLayout(); return createArtifactRepository( id, url, layout, snapshots, releases ); } else { return null; } }
public ArtifactRepository buildArtifactRepository( Repository repo ) throws InvalidRepositoryException { if ( repo != null ) { String id = repo.getId(); if ( StringUtils.isEmpty( id ) ) { throw new InvalidRepositoryException( "Repository identifier missing", "" ); } String url = repo.getUrl(); if ( StringUtils.isEmpty( url ) ) { throw new InvalidRepositoryException( "URL missing for repository " + id, id ); } ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() ); ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repo.getReleases() ); return createArtifactRepository( id, url, getLayout( repo.getLayout() ), snapshots, releases ); } else { return null; } }
private void assembleReportingInheritance( Model child, Model parent ) { // Reports :: aggregate Reporting childReporting = child.getReporting(); Reporting parentReporting = parent.getReporting(); if ( parentReporting != null ) { if ( childReporting == null ) { childReporting = new Reporting(); child.setReporting( childReporting ); } childReporting.setExcludeDefaults( parentReporting.isExcludeDefaults() ); if ( StringUtils.isEmpty( childReporting.getOutputDirectory() ) ) { childReporting.setOutputDirectory( parentReporting.getOutputDirectory() ); } mergeReportPluginLists( childReporting, parentReporting, true ); } }
private void assembleReportingInheritance( Model child, Model parent ) { // Reports :: aggregate Reporting childReporting = child.getReporting(); Reporting parentReporting = parent.getReporting(); if ( parentReporting != null ) { if ( childReporting == null ) { childReporting = new Reporting(); child.setReporting( childReporting ); } if ( childReporting.isExcludeDefaultsValue() == null ) { childReporting.setExcludeDefaultsValue( parentReporting.isExcludeDefaultsValue() ); } if ( StringUtils.isEmpty( childReporting.getOutputDirectory() ) ) { childReporting.setOutputDirectory( parentReporting.getOutputDirectory() ); } ModelUtils.mergeReportPluginLists( childReporting, parentReporting, true ); } }