Skip to content

Commit

Permalink
added deployment to ossrh repo in config w/build profiles
Browse files Browse the repository at this point in the history
* updated POM with build configs and ossrh deploy config
* updated source files to make JavaDocs cool with XML tags
* added .travis.settings.xml to set the ossrh creds for ossrh repo
* updated .travis.xml to test automated deploy on branch updates (non-pr)
  • Loading branch information
Clayton7510 committed May 5, 2019
1 parent 2f5fee1 commit fa9f3b9
Show file tree
Hide file tree
Showing 23 changed files with 216 additions and 56 deletions.
9 changes: 9 additions & 0 deletions .travis.settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<settings>
<servers>
<server>
<id>ossrh</id>
<username>${env.OSSRH_USERNAME}</username>
<password>${env.OSSRH_PASSWORD}</password>
</server>
</servers>
</settings>
25 changes: 20 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@

language: java
env:
global:
#OSSRH_USERNAME
- secure: "QtZ0h7bfVQ7Juw3SdaXk77AT5bQUlI3YhBZnOAOhjK6IVlPcYGMUY0J+CK2ogSoCkjoGFK+2PcBYvBalscQ0U3atY/MGvbmLA/uj8OjiFHoW2pdTWPIaiLOucOr6t2QVZoC4eSghpyTUVtdbVLt4h+rN3YRyVqxBC/wdN17lq+xgf2vRMk/4+DQxQrEu8UyvwJB1fPNJcU2goZRPwvxFp+PXQsTGfMWdNpl121lZrUnSk0ua+ZR4mFzWaNNFaQz7rSPhH/kpjhjRfTnH+vf9wYUA6iFxqx6YL0+pL64PFB+nYZnxL2gYYMU2uqnpKaWJ+6Hv0Q1OXOJ88LA6AtE6rlPZhBoglbk744Q8XK84ewwBt3NCTsZ3sM0sez9iWR8lkwmkiPlYxAosFRfVxQ8YYa0uoT1/GDwOBfsd4x3tsxQRFMV6quKAnaxM02tJOC4OxCw9ul/Gd8SJBumxPKLJCNA9Dbc1d1TVhgltyMMEzpz2lBgJwyV1i2xM/JAgoZd/dLP2JjLB397HnpIZYqO8prXKmX0Y+ba73uan6qpkobIJaV7tuDJznTjcrzrGo2akFmCeEcCSe+rKYSx7Y8buYQzDR4AeL4Te/FbP6CII2QK6MdmYvcTyMKnYL9viU+SkkM76EX1mzQrmviMm9Ze/Z6xWGdzFG39Ns0zMMbw1SyY="
#OSSRH_PASSWORD
- secure: "UZ5SRC7sZlkP/rBDzThtcYICpGCeaOzVAC0LzazYd1LgyF29EOiSTLhHjhXOr+E03konKAdKm3nVFld4rl5KJNk/egBlelmDQ6MoLLhGiAujukXPVi1rZ1f/ondpFbzysZub2JM6VkNqJRLKOWQbgZRLcmU2XFJVTQhR0G4O7E917RWF83JAXcTW4US5Dwiv3e90ne83wbA0d3CADrCU9FVi3Qqxv8Pu86x3rZFkcS9tvkhKUb0fJfEUwZaf5zs8o7FURrT7KUJ/cCItECEyBhLlX1C2Dm5s8hyhMsvN11LLPZu5uvqSKLCqY5AAsBxK1C0n5qEbT/ZkAPFQEMGQmqDsxayKqrvQAPJSdDx3tcTyd6zlrDmHuUGQNIDb/oQ0bIYR5qWf+ymRyCHGGhaCvoexJvKqQ9wzJIhlzQwAmWn+rwrwNCytP4C9krFlqpIpPqzXLk9pCIpbMMh302567UAmsfhO5/QQWQhaHnKdZKa6qmmG0QeIEhcAbxPZUOOHWHGjJMaU1O29GFioNgMTRLXAusvpx5bRowyHqtyicDapXACcyeqjr3vSXYq87DTe3rJTRcM6FnIa1eFg8KjyOxZVsdDg/RwXauEKBB1EH5SMmB5shwgegvvP6Khr2r5BLCE1i7CGqEUCOvQ6/Az/fRetkVsz+qNqTpffxL4zWpA="
sudo: false
branches:
only:
- develop
#branches:
# only:
# - develop
jdk:
- oraclejdk8
script:
- |
cd tf-maven-plugin
./mvnw clean test jacoco:report coveralls:report
echo "*** Downloading the help plugin and getting the project version ***"
./mvnw org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
if [ $TRAVIS_PULL_REQUEST = "false" ] && echo $VERSION | grep -q SNAPSHOT; then
echo "*** Validating the build and deploying to Sonatype SNAPSHOT repo ***"
cp ../.travis.settings.xml $HOME/.m2/settings.xml && ./mvnw clean test jacoco:report coveralls:report deploy -P snapshot
else
echo "*** Validating the build ***"
./mvnw clean test jacoco:report coveralls:report
fi
118 changes: 112 additions & 6 deletions tf-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.deliveredtechnologies.maven</groupId>
<groupId>com.deliveredtechnologies</groupId>
<artifactId>tf-maven-plugin</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>tf-maven-plugin</name>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<nexus.server.id>ossrh</nexus.server.id>
</properties>
<url>https://github.com/deliveredtechnologies/terraform-maven</url>
<licenses>
<license>
Expand Down Expand Up @@ -43,11 +49,58 @@
<timezone>America/New_York</timezone>
</developer>
</developers>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<profiles>
<profile>
<id>snapshot</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<nexus.server.url>https://oss.sonatype.org/content/repositories/snapshots</nexus.server.url>
</properties>
</profile>
<profile>
<id>release</id>
<properties>
<nexus.server.url>https://oss.sonatype.org/</nexus.server.url>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<distributionManagement>
<snapshotRepository>
<id>${nexus.server.id}</id>
<url>${nexus.server.url}</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
Expand All @@ -58,6 +111,59 @@
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>${nexus.server.id}</serverId>
<nexusUrl>${nexus.server.url}</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import java.nio.file.Path;
import java.util.concurrent.TimeUnit;

/**
* Command line abstraction; executes any command via the command line (cmd.exe or bash based on OS).
*/
public class CommandLine implements Executable {

private static int DEFAULT_TIMEOUT = 600000;
Expand All @@ -17,6 +20,14 @@ public CommandLine(Path directory) {
this.directory = directory;
}

/**
* Runs the command specified on the command line (cmd.exe or bash based on OS).
* @param command the command to be run on the command line
* @param timeout the max amount of time in milliseconds the command is allowed to run before interruption
* @return the output from the command line
* @throws IOException
* @throws InterruptedException
*/
@Override
public String execute(String command, int timeout) throws IOException, InterruptedException {
boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("windows");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,21 @@
import java.io.IOException;
import java.nio.file.Path;

/**
* An interface for creating compressed files.
*/
public interface Compressable {
/**
* Adds an artifact to the compressed file.
* @param artifactToAdd an artifact to be added to the compressed file
* @return true if successfully added, otherwise false
*/
public boolean addToCompressedFile(Path artifactToAdd);

/**
* Creates the compressed file.
* @return the Path pointing to the compressed file just created
* @throws IOException
*/
public Path compress() throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

/**
* Class abstraction for creating a ZIP file.
*/
public class CompressableZipFile implements Compressable {
private static int BUFFER_SIZE = 4096;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.Optional;

/**
* A compressed artifact that can be expanded.
* Interface for a compressed artifact that can be expanded.
*/
public interface Expandable {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

/**
* Class abstraction for expanding a ZIP file.
*/
public class ExpandableZippedArtifact implements Expandable {

private static int BUFFER_SIZE = 4096;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ public TerraformApply() throws IOException {
/**
* Executes terraform apply.
* <p>
* Valid Properties: <br/>
* tfVars - a comma delimited list of terraform variables<br/>
* varFiles - a comma delimited list of terraform vars files<br/>
* lockTimeout - state file lock timeout<br/>
* target - resource target<br/>
* autoApprove - approve without prompt<br/>
* Valid Properties: <br>
* tfVars - a comma delimited list of terraform variables<br>
* varFiles - a comma delimited list of terraform vars files<br>
* lockTimeout - state file lock timeout<br>
* target - resource target<br>
* autoApprove - approve without prompt<br>
* tfRootDir - the directory in which to run the apply command
* plan - the plan file to run the apply against<br/>
* noColor - remove color encoding from output<br/>
* timeout - how long in milliseconds the terraform apply command can run<br/>
* plan - the plan file to run the apply against<br>
* noColor - remove color encoding from output<br>
* timeout - how long in milliseconds the terraform apply command can run<br>
* </p>
* @param properties parameter options and properties for terraform apply
* @return the output of terraform apply
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public TerraformCommandLineDecorator(TerraformCommand cmd, Executable commandLin
}

/**
* Instantiates TerraformCommandLineDecorator using TerraformCommand.<br/>
* Instantiates TerraformCommandLineDecorator using TerraformCommand.<br>
* The directory where commands are executed is src/main/tf/{root module dir}.
* @param cmd the Terraform command to be executed
* @throws IOException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public String execute(Properties properties) throws TerraformException {
/**
* Deploys a file w/POM to the Maven repo at the specified URL.
* <p>
* Properties accepted:<br/>
* file - the file to be deployed to the Maven repo<br/>
* url - the url of the Maven repo<br/>
* pomFile - the POM file to be associated with the file<br/>
* Properties accepted:<br>
* file - the file to be deployed to the Maven repo<br>
* url - the url of the Maven repo<br>
* pomFile - the POM file to be associated with the file<br>
* </p>
* @param invoker Maven Invoker
* @param request Maven InvocationRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ public TerraformDestroy() throws IOException {
}

/**
* Executes terraform destroy. <br/>
* Executes terraform destroy. <br>
* <p>
* Valid Properties: <br/>
* lockTimeout - state file lock timeout<br/>
* target - resource target<br/>
* autoApprove - approve without prompt<br/>
* Valid Properties: <br>
* lockTimeout - state file lock timeout<br>
* target - resource target<br>
* autoApprove - approve without prompt<br>
* tfRootDir - the directory in which to run the apply command
* noColor - remove color encoding from output<br/>
* timeout - how long in milliseconds the terraform apply command can run<br/>
* noColor - remove color encoding from output<br>
* timeout - how long in milliseconds the terraform apply command can run<br>
* </p>
* @param properties paramter options and properties for terraform apply
* @return the output of terraform apply
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public TerraformInit() throws IOException {
}

/**
* Executes terraform init. <br/>
* Executes terraform init. <br>
* <p>
* Valid Properties: <br/>
* Valid Properties: <br>
* tfRootDir - the directory where terraform init is called
* </p>
* @param properties paramter options and properties for terraform init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public TerraformPackage(MavenProject project) {
* Packages a Terraform config as a zip file.
* <p>
* Valid Properties:
* tfModulesDir - the directory where Terraform Modules dependencies (i.e. Maven Terraform dependencies) are stored; defaults to src/main/.tfmodules<br/>
* tfRootDir - the directory containing the Terraform root module configuration; defaults to src/main/tf/{first dir found}<br/>
* tfModulesDir - the directory where Terraform Modules dependencies (i.e. Maven Terraform dependencies) are stored; defaults to src/main/.tfmodules<br>
* tfRootDir - the directory containing the Terraform root module configuration; defaults to src/main/tf/{first dir found}<br>
* isFatZip - if "true", then zip contains the Terraform code for all Maven dependencies ( valid values are "true" or "false"); defaults to "false"
* </p>
* @param properties property options for packaging a Terraform configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ public TerraformPlan() throws IOException {
/**
* Executes terraform plan.
* <p>
* Valid Properties: <br/>
* tfVars - a comma delimited list of terraform variables<br/>
* varFiles - a comma delimited list of terraform vars files<br/>
* lockTimeout - state file lock timeout<br/>
* target - resource target<br/>
* planInput - ask for input for variables not directly set<br/>
* Valid Properties: <br>
* tfVars - a comma delimited list of terraform variables<br>
* varFiles - a comma delimited list of terraform vars files<br>
* lockTimeout - state file lock timeout<br>
* target - resource target<br>
* planInput - ask for input for variables not directly set<br>
* tfRootDir - the directory in which to run the apply command
* planOutputFile - path to save the generated execution plan<br/>
* refreshState - if true then refresh the state prior to running plan<br/>
* tfState - path to the state file; defaults to "terraform.tfstate"<br/>
* noColor - remove color encoding from output<br/>
* destroyPlan - if set then output a destroy plan<br/>
* planOutputFile - path to save the generated execution plan<br>
* refreshState - if true then refresh the state prior to running plan<br>
* tfState - path to the state file; defaults to "terraform.tfstate"<br>
* noColor - remove color encoding from output<br>
* destroyPlan - if set then output a destroy plan<br>
* </p>
* @param properties parameter options and properties for terraform apply
* @return the output of terraform apply
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

/**
* Mojo terraform apply goal.
* <br/>
* <br>
* Runs 'terraform apply'
*/
@Mojo(name = "apply")
Expand Down
Loading

0 comments on commit fa9f3b9

Please sign in to comment.