Skip to content

Commit 240618f

Browse files
authored
Merge pull request #179 from clojurephant/jack-in
minor(cider): Support jack-in of dependencies
2 parents 474a415 + c8a8421 commit 240618f

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

manual-test/build.gradle

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ dependencies {
3232
implementation 'com.stuartsierra:component:1.1.0'
3333
devImplementation 'com.stuartsierra:component.repl:0.2.0'
3434

35-
// cider
36-
devImplementation 'cider:cider-nrepl:0.28.5'
37-
devImplementation 'cider:piggieback:0.5.3'
38-
3935
// figwheel
4036
devImplementation 'com.bhauman:figwheel-repl:0.2.18'
4137
devImplementation 'ring:ring-jetty-adapter:1.9.5'
@@ -45,10 +41,6 @@ tasks.withType(Test) {
4541
useJUnitPlatform()
4642
}
4743

48-
tasks.named('clojureRepl') {
49-
middleware = ['cider.nrepl/cider-middleware', 'cider.piggieback/wrap-cljs-repl']
50-
}
51-
5244
clojure {
5345
builds {
5446
main {

src/compatTest/clojure/dev/clojurephant/compat_test/repl.clj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@
6868
(is (= "0.28.2" (-> (send-repl client {:op "cider-version"}) :cider-version :version-string)))
6969
(is (pr-str 7) (eval-repl client '(do (require 'basic-project.core) (basic-project/use-ns 4)))))))
7070

71+
(deftest cider-jack-in
72+
(testing "nREPL dependencies can be jacked-in via command line"
73+
(with-client [client "BasicClojureProjectTest" "--handler=cider.nrepl/cider-nrepl-handler" "-Pdev.clojurephant.jack-in.nrepl=nrepl:nrepl:0.9,cider:cider-nrepl:0.28.3"]
74+
(is (= "0.28.3" (-> (send-repl client {:op "cider-version"}) :cider-version :version-string)))
75+
(is (pr-str 7) (eval-repl client '(do (require 'basic-project.core) (basic-project/use-ns 4)))))))
76+
7177
(deftest task-dependencies-clj
7278
(testing "No Clojure compiles happen when REPL is requested, but other languages are compiled"
7379
(gradle/with-project "MixedJavaClojureTest"
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
package dev.clojurephant.plugin.common.internal;
22

3-
43
import org.gradle.api.Plugin;
54
import org.gradle.api.Project;
5+
import org.gradle.api.artifacts.Configuration;
66
import org.gradle.api.plugins.JavaBasePlugin;
77
import org.gradle.api.tasks.SourceSetContainer;
88

99
public class ClojureCommonBasePlugin implements Plugin<Project> {
10+
public static final String NREPL_JACK_IN_PROPERTY = "dev.clojurephant.jack-in.nrepl";
11+
1012
@Override
1113
public void apply(Project project) {
1214
project.getPluginManager().apply(JavaBasePlugin.class);
15+
configureNreplDependencies(project);
16+
}
17+
18+
public void configureNreplDependencies(Project project) {
19+
Configuration nrepl = project.getConfigurations().create(ClojureCommonPlugin.NREPL_CONFIGURATION_NAME);
20+
if (project.hasProperty(NREPL_JACK_IN_PROPERTY)) {
21+
String[] jackInDeps = project.findProperty(NREPL_JACK_IN_PROPERTY).toString().split(",");
22+
for (String jackInDep : jackInDeps) {
23+
project.getLogger().lifecycle("Jacking {} into the {} configuration", jackInDep, ClojureCommonPlugin.NREPL_CONFIGURATION_NAME);
24+
project.getDependencies().add(ClojureCommonPlugin.NREPL_CONFIGURATION_NAME, jackInDep);
25+
}
26+
} else {
27+
project.getDependencies().add(ClojureCommonPlugin.NREPL_CONFIGURATION_NAME, "nrepl:nrepl:0.9.0");
28+
}
1329
}
1430
}

src/main/java/dev/clojurephant/plugin/common/internal/ClojureCommonPlugin.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ private void configureDev(Project project, SourceSetContainer sourceSets) {
4747
SourceSet test = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME);
4848
SourceSet dev = sourceSets.create(DEV_SOURCE_SET_NAME);
4949

50-
Configuration nrepl = project.getConfigurations().create(NREPL_CONFIGURATION_NAME);
51-
project.getDependencies().add(NREPL_CONFIGURATION_NAME, "nrepl:nrepl:0.9.0");
52-
50+
Configuration nrepl = project.getConfigurations().getByName(NREPL_CONFIGURATION_NAME);
5351
project.getConfigurations().getByName(dev.getCompileClasspathConfigurationName()).extendsFrom(nrepl);
5452
project.getConfigurations().getByName(dev.getRuntimeClasspathConfigurationName()).extendsFrom(nrepl);
5553

0 commit comments

Comments
 (0)