Skip to content

Commit

Permalink
add create parameter to deployS3 goal to create a bucket if does not …
Browse files Browse the repository at this point in the history
…exist
  • Loading branch information
davidmoten committed May 18, 2021
1 parent ace382d commit 088564e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ final class S3Deployer {
this.s3Client = s3Client;
}

void deploy(String inputDirectory, String bucketName, String outputBasePath, boolean publicRead) {
void deploy(String inputDirectory, String bucketName, String outputBasePath, boolean publicRead, boolean create) {
if (inputDirectory == null) {
throw new RuntimeException("must specify inputDirectory parameter in configuration");
}

final Path root = new File(inputDirectory).toPath().toAbsolutePath();

if (!s3Client.doesBucketExistV2(bucketName)) {
s3Client.createBucket(bucketName);
}

try {
Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public final class S3DeployerMojo extends AbstractDeployAwsMojo<AmazonS3ClientBu

@Parameter(property = "publicRead", defaultValue = "true")
private boolean publicRead;

@Parameter(property="create", defaultValue="true")
private boolean create;

public S3DeployerMojo() {
super(AmazonS3ClientBuilder.standard());
Expand All @@ -28,7 +31,7 @@ public S3DeployerMojo() {
@Override
protected void execute(AmazonS3 s3Client) {
S3Deployer deployer = new S3Deployer(getLog(), s3Client);
deployer.deploy(inputDirectory, bucketName, outputBasePath, publicRead);
deployer.deploy(inputDirectory, bucketName, outputBasePath, publicRead, create);
}

}

0 comments on commit 088564e

Please sign in to comment.