Commits

Meikel Brandmeyer committed 1ee26de

Make ClojureExecAction to always include the internal dependencies

Comments (0)

Files changed (3)

clojuresque/src/main/groovy/clojuresque/ClojurePluginConvention.groovy

 
     public ExecResult clojureexec(Closure spec) {
         ClojureExecAction action = ConfigureUtil.configure(spec,
-            new ClojureExecAction(project.fileResolver))
+            new ClojureExecAction(project.fileResolver, project.configurations.clojuresque))
         return action.execute()
     }
 }

clojuresque/src/main/java/clojuresque/ClojureExec.java

     private ClojureExecAction clojureExecAction;
 
     public ClojureExec() {
+        FileCollection driverConf = getProject().getConfigurations().getByName("clojuresque");
         FileResolver fileResolver = getServices().get(FileResolver.class);
-        clojureExecAction = new ClojureExecAction(fileResolver);
+        clojureExecAction = new ClojureExecAction(fileResolver, driverConf);
     }
 
     @TaskAction

clojuresque/src/main/java/clojuresque/ClojureExecAction.java

 
 package clojuresque;
 
+import org.gradle.api.file.FileCollection;
 import org.gradle.api.internal.file.FileResolver;
 import org.gradle.process.ExecResult;
 import org.gradle.process.internal.ExecHandle;
 import org.gradle.process.internal.JavaExecAction;
 import org.gradle.process.internal.JavaExecHandleBuilder;
+import org.gradle.util.GUtil;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 
 public class ClojureExecAction extends JavaExecHandleBuilder implements JavaExecAction {
-    public ClojureExecAction(FileResolver fileResolver) {
+    FileCollection driverClasspath;
+
+    public ClojureExecAction(FileResolver fileResolver, FileCollection driver) {
         super(fileResolver);
+        this.driverClasspath = driver;
+    }
+
+    @Override
+    public List<String> getAllJvmArgs() {
+        List<String> allArgs = super.getAllJvmArgs();
+        String driver = GUtil.join(driverClasspath.getFiles(), File.pathSeparator);
+
+        int pos = allArgs.indexOf("-cp") + 1;
+        if (pos > 0) {
+            String oldClasspath = allArgs.remove(pos);
+            allArgs.add(pos, oldClasspath + File.pathSeparator + driver);
+        } else {
+            allArgs.add("-cp");
+            allArgs.add(driver);
+        }
+
+        return allArgs;
     }
 
     @Override
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.