1
1
/*
2
- * Copyright 2020-2021 the original author or authors.
2
+ * Copyright 2020-2022 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -33,7 +33,10 @@ class JShellPlugin implements Plugin<Project> {
33
33
Task jshellTask = project. tasks. create(' jshellSetup' )
34
34
def classesTask = project. tasks. find { it. name == " classes" }
35
35
if (classesTask) {
36
+ jshellTask. logger. info ' Task "classes" found.'
36
37
jshellTask. dependsOn classesTask
38
+ } else {
39
+ jshellTask. logger. warn ' Task "classes" NOT found.'
37
40
}
38
41
jshellTask. doLast {
39
42
if (! jshellTask. dependsOn) {
@@ -49,15 +52,26 @@ class JShellPlugin implements Plugin<Project> {
49
52
pathSet. addAll(classpath. findAll { it. exists() })
50
53
}
51
54
}
55
+ if (pathSet. isEmpty()) {
56
+ List<String > classesPaths = project. sourceSets. main. output. getClassesDirs(). collect { it. getPath() }
57
+ jshellTask. logger. info(' :jshell could not find the classpath, adding ' +
58
+ ' the following paths from project sourceSets: {}' , classesPaths)
59
+ pathSet. addAll(classesPaths)
60
+ List<String > depsPaths = project. configurations. compileClasspath. collect { it. getPath() }
61
+ depsPaths. addAll(project. configurations. runtimeClasspath. collect { it. getPath() })
62
+ jshellTask. logger. info(" :jshell could not find the dependencies' classpath, adding " +
63
+ ' the following paths from project configurations: {}' , depsPaths)
64
+ pathSet. addAll(depsPaths)
65
+ }
52
66
def path = pathSet. join(System . getProperty(" path.separator" ))
53
- jshellTask. logger. info(" :jshell executing with --class-path \" {} \" " , path)
67
+ jshellTask. logger. info(" :jshell executing with --class-path {} " , path)
54
68
shellArgs + = [
55
69
" --class-path" , path,
56
70
" --startup" , " DEFAULT" ,
57
71
" --startup" , " PRINTING"
58
72
]
59
73
if (project. findProperty(" jshell.startup" ) == " " ) {
60
- // Nothing, just avoid to run the startup.jsh if exists
74
+ jshellTask . logger . info ' :jshell "jshell.startup" set to empty, skipping " startup.jsh" execution '
61
75
}
62
76
else if (project. findProperty(" jshell.startup" )) {
63
77
def jshellStartup = project. findProperty(" jshell.startup" )
0 commit comments