Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
CloudFormation tasks and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Duarte committed Sep 3, 2014
1 parent 47a5c05 commit a9d37fc
Show file tree
Hide file tree
Showing 21 changed files with 1,520 additions and 484 deletions.
155 changes: 154 additions & 1 deletion README.md

Large diffs are not rendered by default.

259 changes: 150 additions & 109 deletions integration-tests.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-ant-tasks</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>aws-java-sdk-ant-tasks</name>
Expand Down
19 changes: 11 additions & 8 deletions src/main/java/com/amazonaws/ant/AWSAntTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@
import org.apache.tools.ant.Task;

import com.amazonaws.AmazonWebServiceClient;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;

/**
* Base class for AWS-related Ant tasks. Handles all shared logic.
*
* @author jesduart
*
*/
public abstract class AWSAntTask extends Task {

private static final String USER_AGENT_PREFIX = "AWS Ant Tasks/";
protected String awsAccessKeyId;
protected String awsSecretKey;

Expand Down Expand Up @@ -71,14 +70,18 @@ public void setAWSSecretKey(String awsSecretKey) {
public <T extends AmazonWebServiceClient> T createClient(
Class<T> clientClass) {
try {
ClientConfiguration clientConfiguration = new ClientConfiguration()
.withUserAgent(USER_AGENT_PREFIX + this.getClass().getSimpleName());
if (awsSecretKey != null && awsAccessKeyId != null) {
Constructor<T> constructor = clientClass
.getConstructor(AWSCredentials.class);
Constructor<T> constructor = clientClass.getConstructor(
AWSCredentials.class, ClientConfiguration.class);
return constructor.newInstance(new BasicAWSCredentials(
awsAccessKeyId, awsSecretKey));
awsAccessKeyId, awsSecretKey), clientConfiguration);
}
Constructor<T> constructor = clientClass.getConstructor();
return constructor.newInstance();
Constructor<T> constructor = clientClass
.getConstructor(ClientConfiguration.class);
return constructor
.newInstance(clientConfiguration);
} catch (Exception e) {
throw new RuntimeException("Unable to create client: "
+ e.getMessage(), e);
Expand Down
43 changes: 43 additions & 0 deletions src/main/java/com/amazonaws/ant/KeyValueNestedElement.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.amazonaws.ant;

/**
* This is a class to be used as a nested element with an Ant task. Many nested
* elements will only require a key and a value, so this class can be used for
* such elements to extend from. What the key and value should be will depend on
* the subclass.
*/
public abstract class KeyValueNestedElement {

private String key;
private String value;

public void setKey(String key) {
this.key = key;
}

public void setValue(String value) {
this.value = value;
}

public String getKey() {
return key;
}

public String getValue() {
return value;
}
}
33 changes: 33 additions & 0 deletions src/main/java/com/amazonaws/ant/SimpleNestedElement.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.amazonaws.ant;

/**
* This is a class to be used as a nested elements. Many nested elements will
* only need one parameter, so they can extend this class. What the parameter
* should be will depend on the subclass.
*/
public abstract class SimpleNestedElement {

private String value;

public void setValue(String value) {
this.value = value;
}

public String getValue() {
return value;
}
}
Loading

0 comments on commit a9d37fc

Please sign in to comment.