com.theoryinpractise.clojure.ClojureRunMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clojure-maven-plugin Show documentation
Show all versions of clojure-maven-plugin Show documentation
Maven plugin for compiling clojure source files
/*
* Copyright (c) Mark Derricutt 2010.
*
* The use and distribution terms for this software are covered by the Eclipse Public License 1.0
* (http://opensource.org/licenses/eclipse-1.0.php) which can be found in the file epl-v10.html
* at the root of this distribution.
*
* By using this software in any fashion, you are agreeing to be bound by the terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
package com.theoryinpractise.clojure;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@Mojo(name = "run", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class ClojureRunMojo extends AbstractClojureCompilerMojo {
/**
* The main clojure script to run
*/
@Parameter(property = "clojure.script")
private String script;
/**
* Additional scripts to run
*/
@Parameter private String[] scripts;
/**
* The fully qualified name of the main class to run. This main class is intended
* to be one generated by :gen-class, although any Java class with a standard main()
* function will do.
*/
@Parameter(property = "clojure.mainClass")
private String mainClass;
/**
* args specified on the command line.
*/
@Parameter(property = "clojure.args")
private String args;
/**
* Returns either a path to a temp file that loads all of the provided scripts,
* or simply returns the singular script
String (which therefore allows
* for @ classpath-loading paths to be passed in as a script).
*
* If multiple scripts are defined, they must all exist; otherwise an exception is thrown.
*/
private static String mergeScripts(String script, String[] scripts) throws MojoExecutionException {
if (script == null || script.trim().equals("")) {
throw new MojoExecutionException("