Skip to content

Commit 686157c

Browse files
committed
Fixed endpoint property issue
1 parent 797f1da commit 686157c

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

S3StorageWagon/src/main/java/com/gkatzioura/maven/cloud/s3/EndpointProperty.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ public EndpointProperty(String endpoint){
3131
this.endpoint = endpoint;
3232
}
3333

34+
public static final EndpointProperty empty() {
35+
return new EndpointProperty(null);
36+
}
37+
38+
public boolean isPresent() {
39+
return endpoint != null || System.getProperty(S3_ENDPOINT)!=null;
40+
}
41+
3442
/**
3543
* @return the endpoint set in the constructor or set using the S3_ENDPOINT system property or null
3644
* */

S3StorageWagon/src/main/java/com/gkatzioura/maven/cloud/s3/plugin/download/S3DownloadMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
8080
try {
8181
//Sending the authenticationInfo as null will make this use the default S3 authentication, which will only
8282
//look at the environment Java properties or environment variables
83-
amazonS3 = S3Connect.connect(null, region, new EndpointProperty(bucket), new PathStyleEnabledProperty(String.valueOf(S3ClientOptions.DEFAULT_PATH_STYLE_ACCESS)));
83+
amazonS3 = S3Connect.connect(null, region, EndpointProperty.empty(), new PathStyleEnabledProperty(String.valueOf(S3ClientOptions.DEFAULT_PATH_STYLE_ACCESS)));
8484
} catch (AuthenticationException e) {
8585
throw new MojoExecutionException(
8686
String.format("Unable to authenticate to S3 with the available credentials. Make sure to either define the environment variables or System properties defined in https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.html.%n" +

S3StorageWagon/src/main/java/com/gkatzioura/maven/cloud/s3/plugin/upload/S3UploadMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
8787
try {
8888
//Sending the authenticationInfo as null will make this use the default S3 authentication, which will only
8989
//look at the environment Java properties or environment variables
90-
amazonS3 = S3Connect.connect(null, region, new EndpointProperty(bucket), new PathStyleEnabledProperty(String.valueOf(S3ClientOptions.DEFAULT_PATH_STYLE_ACCESS)));
90+
amazonS3 = S3Connect.connect(null, region, EndpointProperty.empty(), new PathStyleEnabledProperty(String.valueOf(S3ClientOptions.DEFAULT_PATH_STYLE_ACCESS)));
9191
} catch (AuthenticationException e) {
9292
throw new MojoExecutionException(
9393
String.format("Unable to authenticate to S3 with the available credentials. Make sure to either define the environment variables or System properties defined in https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.html.%n" +

S3StorageWagon/src/main/java/com/gkatzioura/maven/cloud/s3/utils/S3Connect.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,11 @@ private static AmazonS3ClientBuilder createAmazonS3ClientBuilder(AuthenticationI
8282

8383
AmazonS3ClientBuilder builder;
8484
builder = AmazonS3ClientBuilder.standard().withCredentials(new CredentialsFactory().create(authenticationInfo));
85-
builder.setRegion(regionProvider.getRegion());
8685

87-
if (endpoint.get() != null){
86+
if (endpoint.isPresent()){
8887
builder.setEndpointConfiguration( new AwsClientBuilder.EndpointConfiguration(endpoint.get(), builder.getRegion()));
88+
} else {
89+
builder.setRegion(regionProvider.getRegion());
8990
}
9091

9192
builder.setPathStyleAccessEnabled(pathStyle.get());

0 commit comments

Comments
 (0)