Skip to content

Commit

Permalink
feature(parallized deploy): allow configuration of the deployer to ru…
Browse files Browse the repository at this point in the history
…n tasks in parallel

- Configuration: Adds a deployThreads configuration.
- MavenRepositoryDeployer: establishes this class as a Singleton
- MavenRepositoryDeploymentCallable: for a given leaf node, this does the deployment, returning a new DeploymentResult object to collect for the overall summary

Signed-off-by: Samuel Dacanay <[email protected]>
  • Loading branch information
dakaneye committed Oct 18, 2024
1 parent 3577832 commit 2465f28
Show file tree
Hide file tree
Showing 5 changed files with 287 additions and 140 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ release.properties
local-cache
maven-repository-provisioner.log
.checkstyle
**/*.iml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* Copyright simpligility technologies inc. http://www.simpligility.com
* Licensed under Eclipse Public License - v 1.0 http://www.eclipse.org/legal/epl-v10.html
*/
Expand All @@ -15,23 +15,23 @@ public class Configuration
@Parameter( names = { "-h", "-help" }, help = true, description = "Display the help information." )
private boolean help;

@Parameter( names = { "-s", "-sourceUrl" },
description =
@Parameter( names = { "-s", "-sourceUrl" },
description =
"URL for the source repository from which artifacts are resolved, "
+ "example for a Nexus install is http://localhost:8081/content/groups/public" )
private String sourceUrl = "https://repo.maven.apache.org/maven2";

@Parameter( names = { "-t", "-targetUrl" },
@Parameter( names = { "-t", "-targetUrl" },
description = "Folder or URL for the target repository e.g. dist-repo or "
+ " http://localhost:8081/content/repositories/release",
+ " http://localhost:8081/content/repositories/release",
required = true )
private String targetUrl;

@Parameter( names = { "-a", "-artifactCoordinates" },
@Parameter( names = { "-a", "-artifactCoordinates" },
description = "GroupId/ArtifactId/Version (GAV) coordinates of the desired artifacts using the "
+ "syntax (values in [] are optional): "
+ "g:a[:extension][:classifier]:v|g:a[:extension][:classifier]:v "
+ " e.g. org.apache.commons:commons-lang3:3.3.2|com.google.inject:guice:jar:no_aop:3.0",
+ " e.g. org.apache.commons:commons-lang3:3.3.2|com.google.inject:guice:jar:no_aop:3.0",
required = false )
private String artifactCoordinate;

Expand All @@ -43,7 +43,7 @@ public class Configuration

@Parameter( names = { "-su", "-sourceUsername" }, description = "Username for the source repository, if required." )
private String sourceUsername;

@Parameter( names = { "-sp", "-sourcePassword" }, description = "Password for the source repository, if required." )
private String sourcePassword;

Expand All @@ -54,7 +54,7 @@ public class Configuration
@Parameter( names = { "-ij", "-includeJavadoc" },
description = "Flag to enable/disable download of javadoc artifacts.", arity = 1 )
private Boolean includeJavadoc = true;

@Parameter( names = { "-ip", "-includeProvidedScope" },
description = "Flag to include/exclude provisioning of dependencies with provided scope.", arity = 1 )
private Boolean includeProvidedScope = false;
Expand All @@ -67,12 +67,12 @@ public class Configuration
description = "Flag to include/exclude provisioning of dependencies with runtime scope.", arity = 1 )
private Boolean includeRuntimeScope = false;

@Parameter( names = { "-cd", "-cacheDirectory" },
@Parameter( names = { "-cd", "-cacheDirectory" },
description = "Local directory used as a cache between resolving and deploying or as the "
+ "source repository that should be transferred." )
private String cacheDirectory = "local-cache";

@Parameter( names = { "-ct", "-checkTarget" },
@Parameter( names = { "-ct", "-checkTarget" },
description = "Check target repository before deploying, if target GAV pom exists no deployment will be"
+ " attempted", arity = 1 )
private Boolean checkTarget = true;
Expand All @@ -82,6 +82,10 @@ public class Configuration
+ "deployments of a second execution are logged.", arity = 1 )
private Boolean verifyOnly = false;

@Parameter( names = { "-dt", "-deployThreads" },
description = "Number of threads to use for deploying artifacts, default is 5." )
private int deployThreads = 5;

public void setSourceUrl( String sourceUrl )
{
this.sourceUrl = sourceUrl;
Expand Down Expand Up @@ -111,12 +115,12 @@ public void setSourceUsername( String sourceUsername )
{
this.sourceUsername = sourceUsername;
}

public void seSourcetPassword( String sourcePassword )
{
this.sourcePassword = sourcePassword;
}

public void setIncludeSources( Boolean includeSources )
{
this.includeSources = includeSources;
Expand Down Expand Up @@ -204,12 +208,12 @@ public String getSourceUsername()
{
return sourceUsername;
}

public String getSourcePassword()
{
return sourcePassword;
}

public Boolean getIncludeSources()
{
return includeSources;
Expand All @@ -224,7 +228,7 @@ public Boolean getIncludeProvidedScope()
{
return includeProvidedScope;
}

public Boolean getIncludeTestScope()
{
return includeTestScope;
Expand All @@ -250,6 +254,15 @@ public Boolean getVerifyOnly()
return verifyOnly;
}

public void setDeployThreads(int deployThreads)
{
this.deployThreads = deployThreads;
}

public int getDeployThreads() {
return deployThreads;
}

public List<String> getArtifactCoordinates()
{
List<String> coords = Arrays.asList( artifactCoordinate.split( "\\|" ) );
Expand All @@ -261,14 +274,14 @@ public boolean hasArtifactsCoordinates()
return artifactCoordinate != null && !artifactCoordinate.isEmpty();
}

public String getConfigSummary()
public String getConfigSummary()
{
StringBuilder builder = new StringBuilder();
builder.append( "\nProvisioning artifacts: " + this.getArtifactCoordinate() + "\n" )
.append( "Source: " + getSourceUrl() + "\n" )
.append( "Target: " + getTargetUrl() + "\n" )
.append( "Username: " + getUsername() + "\n" );
if ( this.getPassword() != null )
if ( this.getPassword() != null )
{
builder.append( "Password: " + getPassword().replaceAll( ".", "***" ) + "\n" );
}
Expand Down
Loading

0 comments on commit 2465f28

Please sign in to comment.