11/*
2- * Copyright 2020-2021 the original author or authors.
2+ * Copyright 2020-2022 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -33,7 +33,10 @@ class JShellPlugin implements Plugin<Project> {
3333 Task jshellTask = project. tasks. create(' jshellSetup' )
3434 def classesTask = project. tasks. find { it. name == " classes" }
3535 if (classesTask) {
36+ jshellTask. logger. info ' Task "classes" found.'
3637 jshellTask. dependsOn classesTask
38+ } else {
39+ jshellTask. logger. warn ' Task "classes" NOT found.'
3740 }
3841 jshellTask. doLast {
3942 if (! jshellTask. dependsOn) {
@@ -49,15 +52,25 @@ class JShellPlugin implements Plugin<Project> {
4952 pathSet. addAll(classpath. findAll { it. exists() })
5053 }
5154 }
55+ if (pathSet. isEmpty()) {
56+ List<String > classesPaths = project. sourceSets. main. output. getClassesDirs(). collect { it. getPath() }
57+ jshellTask. logger. info(" :jshell couldn't find the classpath, adding " +
58+ ' the following paths from project sourceSets: {}' , classesPaths)
59+ pathSet. addAll(classesPaths)
60+ List<String > depsPaths = project. configurations. default. collect { it. getPath() }
61+ jshellTask. logger. info(" :jshell couldn't find the dependencies' classpath, adding " +
62+ ' the following paths from project configurations: {}' , depsPaths)
63+ pathSet. addAll(depsPaths)
64+ }
5265 def path = pathSet. join(System . getProperty(" path.separator" ))
53- jshellTask. logger. info(" :jshell executing with --class-path \" {} \" " , path)
66+ jshellTask. logger. info(" :jshell executing with --class-path {} " , path)
5467 shellArgs + = [
5568 " --class-path" , path,
5669 " --startup" , " DEFAULT" ,
5770 " --startup" , " PRINTING"
5871 ]
5972 if (project. findProperty(" jshell.startup" ) == " " ) {
60- // Nothing, just avoid to run the startup.jsh if exists
73+ jshellTask . logger . info ' :jshell "jshell.startup" set to empty, skipping " startup.jsh" execution '
6174 }
6275 else if (project. findProperty(" jshell.startup" )) {
6376 def jshellStartup = project. findProperty(" jshell.startup" )
0 commit comments