This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create abstract base class for compile and testCompile
- Loading branch information
Stuart Sierra
committed
Mar 19, 2011
1 parent
367185b
commit 2f5d8ef
Showing
3 changed files
with
44 additions
and
43 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/main/java/org/clojure/maven/AbstractClojureCompileMojo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.clojure.maven; | ||
|
||
import java.io.File; | ||
import java.net.URLClassLoader; | ||
import java.util.Arrays; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
|
||
/** | ||
* Ahead-of-time (AOT) compile Clojure source or test files | ||
* | ||
*/ | ||
public abstract class AbstractClojureCompileMojo extends AbstractClojureMojo { | ||
|
||
/** | ||
* Namespaces to be compiled. | ||
* @parameter | ||
* @required | ||
*/ | ||
protected String[] namespaces; | ||
|
||
public void compile(String outputDirectory, int classpathScope) | ||
throws MojoExecutionException { | ||
|
||
try { | ||
new File(outputDirectory).mkdirs(); | ||
Classpath classpath = new Classpath(project, classpathScope, null); | ||
URLClassLoader classloader = classpath.getClassLoader(); | ||
getLog().debug("Classpath URLs: " + Arrays.toString(classloader.getURLs())); | ||
runIsolated(classloader, new ClojureCompileTask(outputDirectory, namespaces)); | ||
} catch (Exception e) { | ||
throw new MojoExecutionException("Clojure execution failed", e); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters