pax_global_header 0000666 0000000 0000000 00000000064 11405124532 0014507 g ustar 00root root 0000000 0000000 52 comment=37e9be0164493894aaa019f0cd6cad15edbfe6eb
clojure-maven-plugin-1.3.3.orig/ 0000775 0000000 0000000 00000000000 11405124532 0016515 5 ustar 00root root 0000000 0000000 clojure-maven-plugin-1.3.3.orig/.gitignore 0000664 0000000 0000000 00000000027 11405124532 0020504 0 ustar 00root root 0000000 0000000 .*
*~
.DS_Store
target
clojure-maven-plugin-1.3.3.orig/README.markdown 0000664 0000000 0000000 00000022627 11405124532 0021227 0 ustar 00root root 0000000 0000000 Welcome to the clojure-maven-plugin plugin for Apache Maven 2.
## Available goals
* clojure:compile
* clojure:test
* clojure:run
* clojure:repl
* clojure:swank
* clojure:nailgun
## Compiling clojure sources
To use this plugin and start compiling clojure code as part of your maven build, add the following:
com.theoryinpractiseclojure-maven-plugin1.3.1
Without any additional configuration, the clojure-maven-plugin will compile any
namespaces in ./src/main/clojure/*.clj and ./src/test/clojure/*.clj.
To change, or add additional source directories you can add the following configuration:
src/main/clojuresrc/test/clojure
NOTE: The plugin will prepend the project's ${basedir} before each source/testSource directory specified.
The plugin provides a clojure:run goal for run a predefined clojure script defined by:
whilst you could easily launch your tests from the clojure:run goal, the clojure:test goal is more appropriate,
without any additional configuration the plugin will generate and execute the following temporary clojure
"test launcher" script:
(require 'one.require.for.each.discovered.namespace)
(use 'clojure.test)
(when-not *compile-files*
(let [results (atom [])]
(let [report-orig report]
(binding [report (fn [x] (report-orig x)
(swap! results conj (:type x)))]
(run-tests 'one.require.for.each.discovered.namespace)))
(shutdown-agents)
(System/exit (if (empty? (filter {:fail :error} @results)) 0 -1))))
The generated script requires any discovered *test* namespaces, runs all the tests, and fails the build when any FAIL or
ERROR cases are found.
If you require different test behaviour, you can provide your own test script with the following configuration:
src/test/clojure/com/jobsheet/test.clj
If you wish to limit or filter out namespaces during your compile/test, simply add a `` or ``
configuration section:
com.foonet.*!testing.*
The namespace declaration is actually a regex match against discovered namespaces, and can also be
prepended with an ! to filter the matching namespace.
If you wish to further limit test/compile usage to only the namespaces you define, you can enable this with the
configuration block:
truetrue
If you want to provide additional arguments to all spawned java/clojure processes, add a
`` configuration element. In addition, a `` configuration
element is available as a shortcut to specifying the system property that controls whether or
not the AOT clojure compilation process emits reflection warnings:
-Xmx512mtrue
The plugin can also copy source files to the output directory, filtered using the namespace mechanism
that is used to control compilation. If you want to copy all compiled source files to the output:
true
If you want to copy only a subset:
com.foo!com.foo.private.*true
If you want to do no compilation at all, but copy all source files:
true!.*true
Note that it will only copy clojure source files, which must a) end in .clj and b) contain a namespace declaration.
Enjoy.
## clojure:run, clojure:repl, clojure:swank and clojure:nailgun goals
clojure-maven-plugin supports four goals intended to make it easier
to developers to run clojure shells in the context of maven projects.
This means that all dependencies in a project's runtime and test scopes
will be automatically added to the classpath and available for experimentation.
By default these goals will use the test classpath, if you wish to only use the
compile classpath/dependencies, you can disable this with:
false
or by running maven with:
-Dclojure.runwith.test=false
Goal
Description
clojure:repl
Starts an interactive clojure REPL right on the command line. An
initialisation script can be specified in the pom using the
replScript configuration element.
clojure:swank
Starts a Swank server that accepts connections on port 4005
(can be changed using the `-Dclojure.swank.port=X`option). You can
connect to this server from emacs with `M-x slime-connect`.
clojure:nailgun
Starts a nailgun server that accepts connections on port 2113
(can be changed using the `-Dclojure.nailgun.port=X`option). You can
connect to this server from vim using vimclojure
(http://kotka.de/projects/clojure/vimclojure.html).
clojure:run
Runs a clojure script specified in the pom using the <script> and/or <scripts>
configuration element.
### Dependencies
In order to run clojure:repl, clojure:swank or clojure:nailgun, your project
needs to have a recent (1.0 or later) version of clojure as a dependency in
pom.xml.
#### JLine
If JLine is detected in the classpath, it will be used to provide the
clojure:repl goal with history, tab completion, etc. A simple way of
enabling this is to put the following in your pom.xml:
jlinejline0.9.94
#### Swank
The clojure:swank goal requires a recent version of swank-clojure as a
dependency. Unfortunatly, this library is currently not available in
the central maven repository, and has to be downloaded and installed
manually:
1. Download `http://cloud.github.com/downloads/jochu/swank-clojure/swank-clojure-1.0-SNAPSHOT-distribution.zip`
2. Unzip the distribution and extract the swank-clojure-1.0-SNAPSHOT.jar file within.
3. Run the following command to install the jar file to your local repository:
mvn install:install-file -DgroupId=com.codestuffs.clojure -DartifactId=swank-clojure -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/jarfile
4. Put the following in your pom.xml
com.codestuffs.clojureswank-clojure1.0-SNAPSHOT
#### Nailgun
The clojure:nailgun goal requires a recent version of vimclojure as a
dependency. Unfortunatly, this library is currently not available in
the central maven repository, and has to be downloaded and installed
manually:
1. Download vimclojure source code from `http://cloud.github.com/downloads/jochu/swank-clojure/swank-clojure-1.0-SNAPSHOT-distribution.zip`.
2. Follow the README to compile and install vimclojure.
3. Locate vimclojure.jar and run the following command to install it to your local repository (replace X.X.X with your version of vimclojure):
mvn install:install-file -DgroupId=de.kotka -DartifactId=vimclojure -Dversion=X.X.X -Dpackaging=jar -Dfile=/path/to/jarfile
4. Put the following in your pom.xml (replace X.X.X with your version of vimclojure)
de.kotkavimclojureX.X.X
### Configuration
The following options that can be configured as system properties:
Property
Default value
Description
clojure.nailgun.port
4005
Only applicable for the clojure:nailgun goal.
The port number that the Nailgun server should listen to.
clojure.swank.port
4005
Only applicable for the clojure:swank goal.
The port number that the Swank server should listen to.
clojure.swank.protocolVersion
2009-09-14
Only applicable for the clojure:swank goal.
Specifies the version of the swank protocol.
### Support
Join the discussion mailing list at:
http://groups.google.com/group/clojure-maven-plugin
clojure-maven-plugin-1.3.3.orig/epl-v10.html 0000664 0000000 0000000 00000031165 11405124532 0020575 0 ustar 00root root 0000000 0000000
Eclipse Public License - Version 1.0
Eclipse Public License - v 1.0
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS
AGREEMENT.
1. DEFINITIONS
"Contribution" means:
a) in the case of the initial Contributor, the initial
code and documentation distributed under this Agreement, and
b) in the case of each subsequent Contributor:
i) changes to the Program, and
ii) additions to the Program;
where such changes and/or additions to the Program
originate from and are distributed by that particular Contributor. A
Contribution 'originates' from a Contributor if it was added to the
Program by such Contributor itself or anyone acting on such
Contributor's behalf. Contributions do not include additions to the
Program which: (i) are separate modules of software distributed in
conjunction with the Program under their own license agreement, and (ii)
are not derivative works of the Program.
"Contributor" means any person or entity that distributes
the Program.
"Licensed Patents" mean patent claims licensable by a
Contributor which are necessarily infringed by the use or sale of its
Contribution alone or when combined with the Program.
"Program" means the Contributions distributed in accordance
with this Agreement.
"Recipient" means anyone who receives the Program under
this Agreement, including all Contributors.
2. GRANT OF RIGHTS
a) Subject to the terms of this Agreement, each
Contributor hereby grants Recipient a non-exclusive, worldwide,
royalty-free copyright license to reproduce, prepare derivative works
of, publicly display, publicly perform, distribute and sublicense the
Contribution of such Contributor, if any, and such derivative works, in
source code and object code form.
b) Subject to the terms of this Agreement, each
Contributor hereby grants Recipient a non-exclusive, worldwide,
royalty-free patent license under Licensed Patents to make, use, sell,
offer to sell, import and otherwise transfer the Contribution of such
Contributor, if any, in source code and object code form. This patent
license shall apply to the combination of the Contribution and the
Program if, at the time the Contribution is added by the Contributor,
such addition of the Contribution causes such combination to be covered
by the Licensed Patents. The patent license shall not apply to any other
combinations which include the Contribution. No hardware per se is
licensed hereunder.
c) Recipient understands that although each Contributor
grants the licenses to its Contributions set forth herein, no assurances
are provided by any Contributor that the Program does not infringe the
patent or other intellectual property rights of any other entity. Each
Contributor disclaims any liability to Recipient for claims brought by
any other entity based on infringement of intellectual property rights
or otherwise. As a condition to exercising the rights and licenses
granted hereunder, each Recipient hereby assumes sole responsibility to
secure any other intellectual property rights needed, if any. For
example, if a third party patent license is required to allow Recipient
to distribute the Program, it is Recipient's responsibility to acquire
that license before distributing the Program.
d) Each Contributor represents that to its knowledge it
has sufficient copyright rights in its Contribution, if any, to grant
the copyright license set forth in this Agreement.
3. REQUIREMENTS
A Contributor may choose to distribute the Program in object code
form under its own license agreement, provided that:
a) it complies with the terms and conditions of this
Agreement; and
b) its license agreement:
i) effectively disclaims on behalf of all Contributors
all warranties and conditions, express and implied, including warranties
or conditions of title and non-infringement, and implied warranties or
conditions of merchantability and fitness for a particular purpose;
ii) effectively excludes on behalf of all Contributors
all liability for damages, including direct, indirect, special,
incidental and consequential damages, such as lost profits;
iii) states that any provisions which differ from this
Agreement are offered by that Contributor alone and not by any other
party; and
iv) states that source code for the Program is available
from such Contributor, and informs licensees how to obtain it in a
reasonable manner on or through a medium customarily used for software
exchange.
When the Program is made available in source code form:
a) it must be made available under this Agreement; and
b) a copy of this Agreement must be included with each
copy of the Program.
Contributors may not remove or alter any copyright notices contained
within the Program.
Each Contributor must identify itself as the originator of its
Contribution, if any, in a manner that reasonably allows subsequent
Recipients to identify the originator of the Contribution.
4. COMMERCIAL DISTRIBUTION
Commercial distributors of software may accept certain
responsibilities with respect to end users, business partners and the
like. While this license is intended to facilitate the commercial use of
the Program, the Contributor who includes the Program in a commercial
product offering should do so in a manner which does not create
potential liability for other Contributors. Therefore, if a Contributor
includes the Program in a commercial product offering, such Contributor
("Commercial Contributor") hereby agrees to defend and
indemnify every other Contributor ("Indemnified Contributor")
against any losses, damages and costs (collectively "Losses")
arising from claims, lawsuits and other legal actions brought by a third
party against the Indemnified Contributor to the extent caused by the
acts or omissions of such Commercial Contributor in connection with its
distribution of the Program in a commercial product offering. The
obligations in this section do not apply to any claims or Losses
relating to any actual or alleged intellectual property infringement. In
order to qualify, an Indemnified Contributor must: a) promptly notify
the Commercial Contributor in writing of such claim, and b) allow the
Commercial Contributor to control, and cooperate with the Commercial
Contributor in, the defense and any related settlement negotiations. The
Indemnified Contributor may participate in any such claim at its own
expense.
For example, a Contributor might include the Program in a commercial
product offering, Product X. That Contributor is then a Commercial
Contributor. If that Commercial Contributor then makes performance
claims, or offers warranties related to Product X, those performance
claims and warranties are such Commercial Contributor's responsibility
alone. Under this section, the Commercial Contributor would have to
defend claims against the other Contributors related to those
performance claims and warranties, and if a court requires any other
Contributor to pay any damages as a result, the Commercial Contributor
must pay those damages.
5. NO WARRANTY
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
responsible for determining the appropriateness of using and
distributing the Program and assumes all risks associated with its
exercise of rights under this Agreement , including but not limited to
the risks and costs of program errors, compliance with applicable laws,
damage to or loss of data, programs or equipment, and unavailability or
interruption of operations.
6. DISCLAIMER OF LIABILITY
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. GENERAL
If any provision of this Agreement is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of
the remainder of the terms of this Agreement, and without further action
by the parties hereto, such provision shall be reformed to the minimum
extent necessary to make such provision valid and enforceable.
If Recipient institutes patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that the
Program itself (excluding combinations of the Program with other
software or hardware) infringes such Recipient's patent(s), then such
Recipient's rights granted under Section 2(b) shall terminate as of the
date such litigation is filed.
All Recipient's rights under this Agreement shall terminate if it
fails to comply with any of the material terms or conditions of this
Agreement and does not cure such failure in a reasonable period of time
after becoming aware of such noncompliance. If all Recipient's rights
under this Agreement terminate, Recipient agrees to cease use and
distribution of the Program as soon as reasonably practicable. However,
Recipient's obligations under this Agreement and any licenses granted by
Recipient relating to the Program shall continue and survive.
Everyone is permitted to copy and distribute copies of this
Agreement, but in order to avoid inconsistency the Agreement is
copyrighted and may only be modified in the following manner. The
Agreement Steward reserves the right to publish new versions (including
revisions) of this Agreement from time to time. No one other than the
Agreement Steward has the right to modify this Agreement. The Eclipse
Foundation is the initial Agreement Steward. The Eclipse Foundation may
assign the responsibility to serve as the Agreement Steward to a
suitable separate entity. Each new version of the Agreement will be
given a distinguishing version number. The Program (including
Contributions) may always be distributed subject to the version of the
Agreement under which it was received. In addition, after a new version
of the Agreement is published, Contributor may elect to distribute the
Program (including its Contributions) under the new version. Except as
expressly stated in Sections 2(a) and 2(b) above, Recipient receives no
rights or licenses to the intellectual property of any Contributor under
this Agreement, whether expressly, by implication, estoppel or
otherwise. All rights in the Program not expressly granted under this
Agreement are reserved.
This Agreement is governed by the laws of the State of New York and
the intellectual property laws of the United States of America. No party
to this Agreement will bring a legal action under this Agreement more
than one year after the cause of action arose. Each party waives its
rights to a jury trial in any resulting litigation.
clojure-maven-plugin-1.3.3.orig/pom.xml 0000664 0000000 0000000 00000011336 11405124532 0020036 0 ustar 00root root 0000000 0000000
4.0.0clojure-maven-plugin Maven Mojocom.theoryinpractiseclojure-maven-pluginmaven-plugin1.3.3Maven plugin for compiling clojure source fileshttp://github.com/talios/clojure-maven-pluginscm:git:git://github.com/talios/clojure-maven-plugin.gitscm:git:git://github.com/talios/clojure-maven-plugin.githttp://github.com/talios/clojure-maven-pluginUTF-8taliosMark Derricuttmark@talios.comhttp://www.talios.comTim Dysingertim -on- dysinger.netStuart Sierramail@stuartsierra.comScott Fleckensteinnullstyle@gmail.comJukka Zittingjukka.zitting@gmail.comChas Emerickcemerick@snowtide.comEclipse Public Licensesonatype-stagingoss.sonatype.org Staging Repositoryhttp://oss.sonatype.org/service/local/staging/deploy/maven2/github-snapshotsoss.sonatype.org github Release Repository Snapshot Repositoryhttp://oss.sonatype.org/content/repositories/github-snapshots/releaseperformReleasetrueorg.apache.maven.pluginsmaven-gpg-pluginsign-artifactsverifysignmaven-compiler-plugin1.51.5org.apache.mavenmaven-plugin-api2.1.0junitjunit4.7testorg.easytestingfest-assert1.0testorg.mockitomockito-all1.8.0testorg.apache.commonscommons-exec1.0.1org.apache.commonscommons-io1.3.2commons-langcommons-lang2.4org.apache.mavenmaven-toolchain1.0org.apache.mavenmaven-core2.0.9
clojure-maven-plugin-1.3.3.orig/src/ 0000775 0000000 0000000 00000000000 11405124532 0017304 5 ustar 00root root 0000000 0000000 clojure-maven-plugin-1.3.3.orig/src/main/ 0000775 0000000 0000000 00000000000 11405124532 0020230 5 ustar 00root root 0000000 0000000 clojure-maven-plugin-1.3.3.orig/src/main/java/ 0000775 0000000 0000000 00000000000 11405124532 0021151 5 ustar 00root root 0000000 0000000 clojure-maven-plugin-1.3.3.orig/src/main/java/com/ 0000775 0000000 0000000 00000000000 11405124532 0021727 5 ustar 00root root 0000000 0000000 clojure-maven-plugin-1.3.3.orig/src/main/java/com/theoryinpractise/ 0000775 0000000 0000000 00000000000 11405124532 0025323 5 ustar 00root root 0000000 0000000 clojure-maven-plugin-1.3.3.orig/src/main/java/com/theoryinpractise/clojure/ 0000775 0000000 0000000 00000000000 11405124532 0026766 5 ustar 00root root 0000000 0000000 AbstractClojureCompilerMojo.java 0000664 0000000 0000000 00000025702 11405124532 0035167 0 ustar 00root root 0000000 0000000 clojure-maven-plugin-1.3.3.orig/src/main/java/com/theoryinpractise/clojure /*
* 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 java.io.FileNotFoundException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.exec.*;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.toolchain.Toolchain;
import org.apache.maven.toolchain.ToolchainManager;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
public abstract class AbstractClojureCompilerMojo extends AbstractMojo {
/**
* The current toolchain maanager instance
*
* @component
*/
private ToolchainManager toolchainManager;
/**
* The current build session instance. This is used for
* toolchain manager API calls.
*
* @parameter expression="${session}"
* @required
* @readonly
*/
private MavenSession session;
/**
* Base directory of the project.
*
* @parameter expression="${basedir}"
* @required
* @readonly
*/
protected File baseDirectory;
/**
* Project classpath.
*
* @parameter default-value="${project.compileClasspathElements}"
* @required
* @readonly
*/
protected List classpathElements;
/**
* Project test classpath.
*
* @parameter default-value="${project.testClasspathElements}"
* @required
* @readonly
*/
protected List testClasspathElements;
/**
* Location of the file.
*
* @parameter default-value="${project.build.outputDirectory}"
* @required
*/
protected File outputDirectory;
/**
* Location of the file.
*
* @parameter default-value="${project.build.testOutputDirectory}"
* @required
*/
protected File testOutputDirectory;
/**
* Location of the source files.
*
* @parameter
*/
private String[] sourceDirectories = new String[]{"src/main/clojure"};
/**
* Location of the source files.
*
* @parameter
*/
private String[] testSourceDirectories = new String[]{"src/test/clojure"};
/**
* Location of the source files.
*
* @parameter default-value="${project.build.testSourceDirectory}"
* @required
*/
protected File baseTestSourceDirectory;
/**
* Location of the generated source files.
*
* @parameter default-value="${project.build.outputDirectory}/../generated-sources"
* @required
*/
protected File generatedSourceDirectory;
/**
* Should we compile all namespaces or only those defined?
*
* @parameter default-value="false"
*/
protected boolean compileDeclaredNamespaceOnly;
/**
* A list of namespaces to compile
*
* @parameter
*/
protected String[] namespaces;
/**
* Should we test all namespaces or only those defined?
*
* @parameter default-value="false"
*/
protected boolean testDeclaredNamespaceOnly;
/**
* A list of test namespaces to compile
*
* @parameter
*/
protected String[] testNamespaces;
/**
* Classes to put onto the command line before the main class
*
* @parameter
*/
private List prependClasses;
/**
* Clojure/Java command-line options
*
* @parameter
*/
private String clojureOptions = "";
/**
* Run with test-classpath or compile-classpath?
*
* @parameter expression="${clojure.runwith.test}" default-value="true"
*/
private boolean runWithTests;
/**
* A list of namespaces whose source files will be copied to the output.
*
* @parameter
*/
protected String[] copiedNamespaces;
/**
* Should we copy the source of all namespaces or only those defined?
*
* @parameter default-value="false"
*/
protected boolean copyDeclaredNamespaceOnly;
/**
* Should the source files of all compiled namespaces be copied to the output?
* This overrides copiedNamespaces and copyDeclaredNamespaceOnly.
*
* @parameter default-value="false"
*/
private boolean copyAllCompiledNamespaces;
/**
* Should reflective invocations in Clojure source emit warnings? Corresponds with
* the *warn-on-reflection* var and the clojure.compile.warn-on-reflection system property.
*
* @parameter default-value="false"
*/
private boolean warnOnReflection;
private String getJavaExecutable() throws MojoExecutionException {
Toolchain tc = toolchainManager.getToolchainFromBuildContext("jdk", //NOI18N
session);
if (tc != null) {
getLog().info("Toolchain in clojure-maven-plugin: " + tc);
String foundExecutable = tc.findTool("java");
if (foundExecutable != null) {
return foundExecutable;
} else {
throw new MojoExecutionException("Unable to find 'java' executable for toolchain: " + tc);
}
}
return "java";
}
private File[] translatePaths(String[] paths) {
File[] files = new File[paths.length];
for (int i = 0; i < paths.length; i++) {
files[i] = new File(baseDirectory, paths[i]);
}
return files;
}
protected NamespaceInFile[] discoverNamespaces() throws MojoExecutionException {
return new NamespaceDiscovery(getLog(), compileDeclaredNamespaceOnly).discoverNamespacesIn(namespaces, translatePaths(sourceDirectories));
}
protected NamespaceInFile[] discoverNamespacesToCopy() throws MojoExecutionException {
if (copyAllCompiledNamespaces)
return discoverNamespaces();
else
return new NamespaceDiscovery(getLog(), copyDeclaredNamespaceOnly).discoverNamespacesIn(copiedNamespaces, translatePaths(sourceDirectories));
}
public enum SourceDirectory {
COMPILE, TEST
}
;
public File[] getSourceDirectories(SourceDirectory... sourceDirectoryTypes) {
List dirs = new ArrayList();
if (Arrays.asList(sourceDirectoryTypes).contains(SourceDirectory.COMPILE)) {
dirs.add(generatedSourceDirectory);
dirs.addAll(Arrays.asList(translatePaths(sourceDirectories)));
}
if (Arrays.asList(sourceDirectoryTypes).contains(SourceDirectory.TEST)) {
dirs.add(baseTestSourceDirectory);
dirs.addAll(Arrays.asList(translatePaths(testSourceDirectories)));
}
return dirs.toArray(new File[]{});
}
public List getRunWithClasspathElements() {
return runWithTests ? testClasspathElements : classpathElements;
}
protected void copyNamespaceSourceFilesToOutput(File outputDirectory, NamespaceInFile[] discoveredNamespaces) throws MojoExecutionException {
for (NamespaceInFile ns : discoveredNamespaces) {
File outputFile = new File(outputDirectory, ns.getFilename());
outputFile.getParentFile().mkdirs();
try {
FileInputStream is = new FileInputStream(ns.getSourceFile());
try {
FileOutputStream os = new FileOutputStream(outputFile);
try {
int amountRead;
byte[] buffer = new byte[4096];
while ((amountRead = is.read(buffer)) >= 0) {
os.write(buffer, 0, amountRead);
}
is.close();
} finally {
is.close();
}
} finally {
is.close();
}
} catch (IOException ex) {
throw new MojoExecutionException("Couldn't copy the clojure source files to the output", ex);
}
}
}
protected void callClojureWith(
File[] sourceDirectory,
File outputDirectory,
List compileClasspathElements,
String mainClass,
NamespaceInFile[] namespaceArgs) throws MojoExecutionException {
String[] stringArgs = new String[namespaceArgs.length];
for (int i = 0; i < namespaceArgs.length; i++) {
stringArgs[i] = namespaceArgs[i].getName();
}
callClojureWith(sourceDirectory, outputDirectory, compileClasspathElements, mainClass, stringArgs);
}
protected void callClojureWith(
File[] sourceDirectory,
File outputDirectory,
List compileClasspathElements,
String mainClass,
String[] clojureArgs) throws MojoExecutionException {
outputDirectory.mkdirs();
String cp = "";
for (File directory : sourceDirectory) {
cp = cp + directory.getPath() + File.pathSeparator;
}
cp = cp + outputDirectory.getPath() + File.pathSeparator;
for (Object classpathElement : compileClasspathElements) {
cp = cp + File.pathSeparator + classpathElement;
}
final String javaExecutable = getJavaExecutable();
getLog().debug("Java exectuable used: " + javaExecutable);
getLog().debug("Clojure classpath: " + cp);
CommandLine cl = new CommandLine(javaExecutable);
cl.addArgument("-cp");
cl.addArgument(cp);
cl.addArgument("-Dclojure.compile.path=" + outputDirectory.getPath() + "");
if (warnOnReflection) cl.addArgument("-Dclojure.compile.warn-on-reflection=true");
cl.addArguments(clojureOptions, false);
if (prependClasses != null) {
cl.addArguments(prependClasses.toArray(new String[prependClasses.size()]));
}
cl.addArgument(mainClass);
if (clojureArgs != null) {
cl.addArguments(clojureArgs, false);
}
Executor exec = new DefaultExecutor();
Map env = new HashMap(System.getenv());
// env.put("path", ";");
// env.put("path", System.getProperty("java.home"));
ExecuteStreamHandler handler = new PumpStreamHandler(System.out, System.err, System.in);
exec.setStreamHandler(handler);
int status;
try {
status = exec.execute(cl, env);
} catch (ExecuteException e) {
status = e.getExitValue();
} catch (IOException e) {
status = 1;
}
if (status != 0) {
throw new MojoExecutionException("Clojure failed.");
}
}
}
clojure-maven-plugin-1.3.3.orig/src/main/java/com/theoryinpractise/clojure/ClojureCompilerMojo.java 0000664 0000000 0000000 00000002051 11405124532 0033552 0 ustar 00root root 0000000 0000000 /*
* 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;
/**
* @goal compile
* @phase compile
* @requiresDependencyResolution compile
*/
public class ClojureCompilerMojo extends AbstractClojureCompilerMojo {
public void execute() throws MojoExecutionException {
callClojureWith(
getSourceDirectories(SourceDirectory.COMPILE),
outputDirectory, classpathElements, "clojure.lang.Compile",
discoverNamespaces());
copyNamespaceSourceFilesToOutput(outputDirectory, discoverNamespacesToCopy());
}
}
clojure-maven-plugin-1.3.3.orig/src/main/java/com/theoryinpractise/clojure/ClojureGenDocMojo.java 0000664 0000000 0000000 00000006026 11405124532 0033145 0 ustar 00root root 0000000 0000000 /*
* 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 java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
/**
* @goal gendoc
* @phase package
* @requiresDependencyResolution test
*/
public class ClojureGenDocMojo extends AbstractClojureCompilerMojo {
/**
* Should we compile all namespaces or only those defined?
*
* @parameter default-value="false"
*/
private boolean generateTestDocumentation;
public void execute() throws MojoExecutionException {
File genDocClj;
File docsDir;
try {
genDocClj = File.createTempFile("generate-docs", ".clj");
if (!outputDirectory.getParentFile().exists()) {
outputDirectory.getParentFile().mkdir();
}
docsDir = new File(outputDirectory.getParentFile(), "clojure");
getLog().debug("Creating documentation directory " + docsDir.getPath());
docsDir.mkdir();
System.out.println(docsDir.getPath() + " exists " + docsDir.exists());
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage());
}
StringBuilder sb = new StringBuilder();
sb.append("(use 'clojure.contrib.gen-html-docs)\n");
sb.append("(generate-documentation-to-file \n");
int count = 0;
sb.append(" \"").append(docsDir.getPath().replace('\\', '/')).append("/index.html\"\n");
sb.append(" [");
final NamespaceInFile[] allNamespaces = new NamespaceDiscovery(getLog(), compileDeclaredNamespaceOnly)
.discoverNamespacesIn(namespaces, getSourceDirectories(SourceDirectory.COMPILE, SourceDirectory.TEST));
for (NamespaceInFile namespace : allNamespaces) {
sb.append("'").append(namespace.getName());
if (count++ < allNamespaces.length - 1) {
sb.append("\n ");
}
}
sb.append("])\n");
try {
final PrintWriter pw = new PrintWriter(genDocClj);
pw.print(sb.toString());
pw.close();
getLog().info("Generating docs to " + docsDir.getCanonicalPath() + " with " + genDocClj.getPath());
getLog().debug(sb.toString());
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage());
}
callClojureWith(
getSourceDirectories(SourceDirectory.COMPILE, SourceDirectory.TEST),
outputDirectory, testClasspathElements, "clojure.main",
new String[]{genDocClj.getPath()});
}
}
clojure-maven-plugin-1.3.3.orig/src/main/java/com/theoryinpractise/clojure/ClojureNailgunMojo.java 0000664 0000000 0000000 00000002570 11405124532 0033403 0 ustar 00root root 0000000 0000000 /*
* 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;
/**
* Mojo to start a clojure REPL running vimclojure's nailgun.
*
* @goal nailgun
* @execute phase="compile"
* @requiresDependencyResolution compile
*/
public class ClojureNailgunMojo extends AbstractClojureCompilerMojo {
/**
* The clojure script to preceding the switch to the repl
*
* @parameter
*/
private String replScript;
/**
* @parameter expression="${clojure.nailgun.port}" default-value="2113"
*/
protected int port;
public void execute() throws MojoExecutionException {
String[] args = new String[]{Integer.toString(port)};
callClojureWith(getSourceDirectories(SourceDirectory.TEST, SourceDirectory.COMPILE),
outputDirectory,
getRunWithClasspathElements(),
"com.martiansoftware.nailgun.NGServer", args);
}
}
clojure-maven-plugin-1.3.3.orig/src/main/java/com/theoryinpractise/clojure/ClojureReplMojo.java 0000664 0000000 0000000 00000004166 11405124532 0032713 0 ustar 00root root 0000000 0000000 /*
* 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 java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Mojo to start a clojure repl
*
* @goal repl
* @execute phase="compile"
* @requiresDependencyResolution compile
*/
public class ClojureReplMojo extends AbstractClojureCompilerMojo {
/**
* The clojure script to preceding the switch to the repl
*
* @parameter
*/
private String replScript;
private static final Pattern JLINE = Pattern.compile("^.*/jline-[^/]+.jar$");
boolean isJLineAvailable(List elements) {
if (elements != null) {
for (String e : elements) {
Matcher m = JLINE.matcher(e);
if (m.matches())
return true;
}
}
return false;
}
public void execute() throws MojoExecutionException {
List args = new ArrayList();
String mainClass = "clojure.main";
if (isJLineAvailable(classpathElements)) {
getLog().info("Enabling JLine support");
args.add("clojure.main");
mainClass = "jline.ConsoleRunner";
}
if (replScript != null && new File(replScript).exists()) {
args.add("-i");
args.add(replScript);
args.add("-r");
}
callClojureWith(
getSourceDirectories(SourceDirectory.TEST, SourceDirectory.COMPILE),
outputDirectory, getRunWithClasspathElements(), mainClass,
args.toArray(new String[args.size()]));
}
}
clojure-maven-plugin-1.3.3.orig/src/main/java/com/theoryinpractise/clojure/ClojureRunMojo.java 0000664 0000000 0000000 00000007470 11405124532 0032556 0 ustar 00root root 0000000 0000000 /*
* 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 java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @goal run
* @requiresDependencyResolution compile
*/
public class ClojureRunMojo extends AbstractClojureCompilerMojo {
/**
* The main clojure script to run
*
* @parameter expression="${clojure.script}"
* @required
*/
private String script;
/**
* Additional scripts to run
*
* @parameter
*/
private String[] scripts;
/**
* args specified on the command line.
*
* @parameter expression="${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("