src/main/java/com/digitalglobe/util/maven/plugin/CloudFormationDeployMavenPlugin.java
/**
     * This method checks to see if the master artifact is overriden with a stack specific artifact.  If it is, the
     * method finds the artfact on the local file system and saves it to S3 using the s3Bucket and s3Prefix.
     *
     * @param s3client is the S3 client to use when saving the artifact.
     * @param deploymentArtifactRegEx is a regular expresion for a file to find.
     * @param outputParameters is a collection of output parameters.
     * @throws IOException is throw when it can't perfom a file or path function call.
     * @throws MojoExecutionException is thrown if the regular expression is bad.
     * @throws NoSuchAlgorithmException is thrown if the SHA-256 algorithm doesn't exist for calculating a file hash.
     */
This method checks to see if the master artifact is overriden with a stack specific artifact.  If it is, the
method finds the artfact on the local file system and saves it to S3 using the s3Bucket and s3Prefix.

@param s3client is the S3 client to use when saving the artifact.
@param deploymentArtifactRegEx is a regular expresion for a file to find.
@param outputParameters is a collection of output parameters.
@throws IOException is throw when it can't perfom a file or path function call.
@throws MojoExecutionException is thrown if the regular expression is bad.
@throws NoSuchAlgorithmException is thrown if the SHA-256 algorithm doesn't exist for calculating a file hash.
This method checks to see if the master artifact is overriden with a stack specific artifact . If it is the method finds the artfact on the local file system and saves it to S3 using the s3Bucket and s3Prefix . @param s3client is the S3 client to use when saving the artifact . @param deploymentArtifactRegEx is a regular expresion for a file to find . @param outputParameters is a collection of output parameters . @throws IOException is throw when it can ' t perfom a file or path function call . @throws MojoExecutionException is thrown if the regular expression is bad . @throws NoSuchAlgorithmException is thrown if the SHA - 256 algorithm doesn ' t exist for calculating a file hash .
private void storeDeploymentArtifact(S3Client s3client, String deploymentArtifactRegEx,
                                         Map<String, String> outputParameters)
            throws IOException, MojoExecutionException, NoSuchAlgorithmException {
        if(deploymentArtifactRegEx != null) {
            audit.write("Finding a deployment artifact using regex: " + deploymentArtifactRegEx + "\n");
            if(!Pattern.matches(
                    "\\^?((/[A-Za-z0-9:\\[\\]{}_\\ -])+(.[A-Za-z0-9_-]+)?|[A-Za-z0-9:\\[\\]{}_\\ -.]+)[$]?",
                    deploymentArtifactRegEx))
                throw new MojoExecutionException("Invalid deployment artifact regular expression.");
            int endPos = deploymentArtifactRegEx.lastIndexOf('/');
            String path;
            String regex;
            if(endPos > -1) {
                path = deploymentArtifactRegEx.charAt(0) == '^' ?
                        deploymentArtifactRegEx.substring(1, endPos) :
                        deploymentArtifactRegEx.substring(0, endPos);
                regex = deploymentArtifactRegEx.substring(endPos + 1);
            } else {
                path = Paths.get("").toAbsolutePath().toString();
                regex = deploymentArtifactRegEx;
            }
            List<File> files = Files.find(Paths.get(path), 1, (file, attributes) ->
                    FileSystems.getDefault().getPathMatcher("regex:" + regex)
                            .matches(file.getFileName()))
                    .collect(ArrayList::new, (list, filePath) -> list.add(new File(filePath.toUri())), (f1, f2) -> {});
            if(files.size() != 1)
                throw new MojoExecutionException("Couldn't find deployment artifact.");
            audit.write("Deployment artifact: " + files.get(0).getName() + "\n");
            System.out.println("Deploying artifact to S3: " + files.get(0).getName());
            storeArtifact(s3client, files.toArray(new File[0]), null, outputParameters);
        }
    }
private void storeDeploymentArtifact ( S3Client s3client , String deploymentArtifactRegEx , Map < String , String > outputParameters ) throws IOException , MojoExecutionException , NoSuchAlgorithmException { if ( deploymentArtifactRegEx != null ) { audit . write ( "Finding a deployment artifact using regex: " + deploymentArtifactRegEx + "\n" ) ; if ( ! Pattern . matches ( "\\^?((/[A-Za-z0-9:\\[\\]{}_\\ -])+(.[A-Za-z0-9_-]+)?|[A-Za-z0-9:\\[\\]{}_\\ -.]+)[$]?" , deploymentArtifactRegEx ) ) throw new MojoExecutionException ( "Invalid deployment artifact regular expression." ) ; int endPos = deploymentArtifactRegEx . lastIndexOf ( '/' ) ; String path ; String regex ; if ( endPos > - 1 ) { path = deploymentArtifactRegEx . charAt ( 0 ) == '^' ? deploymentArtifactRegEx . substring ( 1 , endPos ) : deploymentArtifactRegEx . substring ( 0 , endPos ) ; regex = deploymentArtifactRegEx . substring ( endPos + 1 ) ; } else { path = Paths . get ( "" ) . toAbsolutePath ( ) . toString ( ) ; regex = deploymentArtifactRegEx ; } List < File > files = Files . find ( Paths . get ( path ) , 1 , ( file , attributes ) -> FileSystems . getDefault ( ) . getPathMatcher ( "regex:" + regex ) . matches ( file . getFileName ( ) ) ) . collect ( ArrayList :: new , ( list , filePath ) -> list . add ( new File ( filePath . toUri ( ) ) ) , ( f1 , f2 ) -> { } ) ; if ( files . size ( ) != 1 ) throw new MojoExecutionException ( "Couldn't find deployment artifact." ) ; audit . write ( "Deployment artifact: " + files . get ( 0 ) . getName ( ) + "\n" ) ; System . out . println ( "Deploying artifact to S3: " + files . get ( 0 ) . getName ( ) ) ; storeArtifact ( s3client , files . toArray ( new File [ 0 ] ) , null , outputParameters ) ; } }
This method checks to see if the master artifact is overriden with a stack specific artifact.
This method checks to see if the master artifact is overriden with a stack specific artifact .