Skip to content
Permalink
Browse files
total overhaul of SDK building
  • Loading branch information
mbenson committed Mar 31, 2022
1 parent da99c88 commit a6252af4eb247f73f229f4fbc61af71ea7538160
Showing 38 changed files with 4,256 additions and 648 deletions.
10 ivy.xml
@@ -32,7 +32,8 @@
</info>
<configurations defaultconfmapping="*->default">
<conf name="default" description="full antlib with all dependencies" />
<conf name="provided" description="Ant must be present at runtime" />
<conf name="provided" description="Ant must be present at runtime" visibility="private" />
<conf name="sso" description="Optional SSO support" />
<conf name="test" description="dependencies used for tests of the antlib" visibility="private" />
</configurations>
<publications xmlns:e="urn:ant.apache.org:ivy-extras">
@@ -55,15 +56,20 @@
</publications>
<dependencies defaultconfmapping="*->default">
<dependency org="software.amazon.awssdk" name="s3" rev="${aws.sdk.version}" conf="default">
<exclude org="software.amazon.awssdk" name="apache-client" />
</dependency>
<dependency org="software.amazon.awssdk" name="url-connection-client" rev="${aws.sdk.version}" conf="default" />
<dependency org="software.amazon.awssdk" name="sts" rev="${aws.sdk.version}" conf="default" />
<dependency org="org.apache.commons" name="commons-lang3" rev="3.12.0" conf="default" />
<dependency org="org.kohsuke.metainf-services" name="metainf-services" rev="1.8" conf="default" />
<dependency org="org.apache.ant" name="ant" rev="1.10.12" conf="provided" />
<dependency org="junit" name="junit" rev="4.13" conf="test" />
<dependency org="com.adobe.testing" name="s3mock" rev="2.4.7" conf="test" />
<dependency org="jakarta.servlet.jsp" name="jakarta.servlet.jsp-api" rev="2.3.6" conf="test" />
<dependency org="org.apache.groovy" name="groovy-ant" rev="4.0.0" transitive="false" conf="test" />
<dependency org="org.apache.groovy" name="groovy-jsr223" rev="4.0.0" conf="test" />
<dependency org="org.assertj" name="assertj-core" rev="3.22.0" conf="test" />
<dependency org="software.amazon.awssdk" name="aws-json-protocol" rev="${aws.sdk.version}" conf="sso" transitive="false" />
<dependency org="software.amazon.awssdk" name="sso" rev="${aws.sdk.version}" conf="sso" transitive="false" />
<exclude org="software.amazon.awssdk" artifact="apache-client" />
</dependencies>
</ivy-module>

This file was deleted.

@@ -16,96 +16,23 @@
*/
package org.apache.ant.s3;

import java.util.Objects;
import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Stream;

import org.apache.tools.ant.BuildException;
import org.apache.ant.s3.build.RootConfiguringSupplier;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.DataType;

import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.S3ClientBuilder;

/**
* {@link DataType} providing access to an {@link S3Client} instance.
*/
public class Client extends S3DataType implements Supplier<S3Client> {

private Builder<S3ClientBuilder> builder;
private Credentials credentials;
private HttpConfiguration httpConfiguration;
public class Client extends RootConfiguringSupplier<S3Client> {

/**
* Create a new {@link Client}.
*
* @param project
* @param project Ant {@link Project}
*/
public Client(Project project) {
super(project);
}

/**
* Create a nested {@code builder} element to allow customization.
*
* @return {@link AmazonS3ClientBuilder}
*/
public Builder<S3ClientBuilder> createBuilder() {
checkChildrenAllowed();

if (builder != null) {
singleElementAllowed("builder");
}
return builder = new Builder<>(S3ClientBuilder.class, getProject());
}

/**
* Create a nested {@link Credentials} element.
*
* @return {@link Credentials}
*/
public Credentials createCredentials() {
checkChildrenAllowed();

if (credentials != null) {
singleElementAllowed("credentials");
}
return credentials = new Credentials(getProject());
}

/**
* Create a nested {@link HttpConfiguration} element.
*
* @return {@link HttpConfiguration}
*/
public HttpConfiguration createHttp() {
checkChildrenAllowed();

if (httpConfiguration != null) {
singleElementAllowed("http");
}
return httpConfiguration = new HttpConfiguration(getProject());
}

/**
* {@inheritDoc}
*/
@Override
public S3Client get() {
if (isReference()) {
return getRefid().<Client> getReferencedObject().get();
}
final S3ClientBuilder scb = S3Client.builder();
Optional.ofNullable(builder).ifPresent(bb -> bb.accept(scb));

Stream.of(credentials, httpConfiguration).filter(Objects::nonNull).forEach(c -> c.accept(scb));

return scb.build();
}

private void singleElementAllowed(final String name) {
throw new BuildException(String.format("%s permits a single nested %s element", getDataTypeName(), name),
getLocation());
}
}

0 comments on commit a6252af

Please sign in to comment.