Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non jar files should be excluded from the path sent to jshell #16

Closed
davidnavas opened this issue Jan 18, 2023 · 9 comments · Fixed by #19
Closed

Non jar files should be excluded from the path sent to jshell #16

davidnavas opened this issue Jan 18, 2023 · 9 comments · Fixed by #19

Comments

@davidnavas
Copy link
Contributor

davidnavas commented Jan 18, 2023

See the code
https://github.com/johnpoth/jshell-maven-plugin/blob/master/src/main/java/com/github/johnpoth/jshell/JShellMojo.java#L118

Recommended remediation for gradle plugin:
pathSet = pathSet.findAll{ it.isDirectory() || it.toString().endsWith('.jar') }
[prior to the join()]

Our specific problem is that hk2-jar (org.glassfish.ha/ha-api/3.1.12/*/ha-api-3.1.12.hk2-jar) is being pulled into our classpath, and it is not an actual jar file.

@mrsarm
Copy link
Owner

mrsarm commented Jan 19, 2023

Hi @davidnavas !

I took a look to the source code (of my project) and I don't see any part where files that are not jars are filtered out, so maybe instead of filtering out I need to include more files, but not sure how, reading from another variable maybe? feel free to create a PR and I can test whether it breaks other builds, or you can point me where you think in the code the filtering happens.

@davidnavas
Copy link
Contributor Author

Hey! Yes, that's absolutely correct, your project doesn't filter non-jar files.
However, jshell complains when it gets a classpath that includes files that aren't jars.
I'm arguing that your project should filter non-jar files because jshell expects only directories or jar files.
You can see that JShellMojo does perform that filtering (probably for a similar reason, but I didn't look).

It's not a big deal, as the whole reason why hk2-jar (which isn't a jar) is included is a gradle/ha-api packaging issue, just thought you should know that jshell complains loudly when the classpath includes non-jars.

That said, I can create a PR if you want. I was just going to put that "pathSet..." line prior to line 66 of JShellPlugin.groovy.

@mrsarm
Copy link
Owner

mrsarm commented Jan 19, 2023

Ooh right, right, sorry I did understand the opposite. Yes please if you create a PR I can review it and release tomorrow a beta version in plugins.gradle.org

@davidnavas
Copy link
Contributor Author

It's been ... awhile since I used github. Let's hope I get this right :>

@davidnavas
Copy link
Contributor Author

Let me know if there's a suite of tests to run for this. I copied working code, but it's gone through a couple of copy-paste sessions.

This was referenced Jan 29, 2023
@mrsarm
Copy link
Owner

mrsarm commented Jan 29, 2023

Hi @davidnavas , I just sent a release candidate to the Gradle Plugins repo with your patch, so please replace in your build.gradle file:

id "com.github.mrsarm.jshell.plugin" version "1.2.0"

With:

id "com.github.mrsarm.jshell.plugin" version "1.2.1-RC6"

I'm not sure though if the release is are already available or still pending of approval, just give it a try whenever you can.

@davidnavas
Copy link
Contributor Author

davidnavas commented Jan 29, 2023 via email

@davidnavas
Copy link
Contributor Author

@mrsarm I can confirm that 1.2.1-RC6 works great!
Thank you.

@mrsarm
Copy link
Owner

mrsarm commented Feb 3, 2023

Great @davidnavas ! I will release a new stable version soon before close the ticket.

@mrsarm mrsarm closed this as completed in #19 Feb 3, 2023
@mrsarm mrsarm reopened this Feb 3, 2023
@mrsarm mrsarm closed this as completed Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants