com.thesett.maven.run.ScriptGenMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of run-maven-plugin Show documentation
Show all versions of run-maven-plugin Show documentation
Maven plugin for running main methods of projects from the command line. This plugin generates the
necessary classpath for the project from its runtime classpath in the pom, and creates a script to
invoke the projects main methods with.
/*
* Copyright The Sett Ltd, 2005 to 2014.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License 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.thesett.maven.run;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
/**
*
CRC Card
* Responsibilities Collaborations
*
*
* @author Rupert Smith
* @goal script
* @phase package
* @requiresDependencyResolution test
*/
public class ScriptGenMojo extends AbstractMojo
{
protected static final String UNIX_SCRIPT_LANGUAGE = "#!/bin/bash\n\n";
protected static final String UNIX_OPT_PARSER =
"# Parse arguements taking all - prefixed args as JAVA_OPTS\n" + "for arg in \"$@\"; do\n" +
" if [[ $arg == -java#* ]]; then\n" + " JAVA_OPTS=\"${JAVA_OPTS}-`echo $arg|cut -d '#' -f 2` \"\n" +
" else\n" + " ARGS=\"${ARGS}$arg \"\n" + " fi\n" + "done\n\n";
/** Used for debugging purposes. */
protected final Log log = getLog();
/**
* Where to write out the scripts.
*
* @parameter
*/
protected String scriptOutDirectory;
/**
* The build artifact as a .jar.
*
* @parameter property="project.build.finalName"
*/
protected String outputJar;
/**
* The system properties to pass to java runtime.
*
* @parameter
*/
protected Properties systemproperties;
/**
* The classpath elements of the project being tested.
*
* @parameter property="project.testClasspathElements"
* @readonly
* @required
*/
protected List classpathElements;
/**
* The TKTest runner command lines. There are passed directly to the TKTestRunner main method.
*
* @parameter
*/
protected final Map© 2015 - 2024 Weber Informatics LLC | Privacy Policy