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

[FEATURE] gradlew support #200

Open
bguedel opened this issue Apr 15, 2021 · 23 comments · Fixed by #201
Open

[FEATURE] gradlew support #200

bguedel opened this issue Apr 15, 2021 · 23 comments · Fixed by #201
Labels
enhancement New feature or request released

Comments

@bguedel
Copy link

bguedel commented Apr 15, 2021

  • What are you trying to do?
    Run nexusiq from a gradle built project
  • What feature or behavior is this required for?
    Normal project related development
  • How could we solve this issue? (Not knowing is okay!)
    Support gradle in the project directory ./gradlew
  • Anything else?
    Related Add Gradle support #67 is to ask for gradle support but its most common to have have "gradle" installed but to actually have the wrapper in the project. Often enough people would be working on many projects some of which are not on the same version and thus the gradle wrapper.

It should be noted that I have also tried creating a symlink in my own ~/bin to gradlew named gradle but that is not working.
ln -s "./gradlew" gradle

running in my project

▶ gradle clean build      
executing gradlew instead of gradle
<=------------> 13% EXECUTING [1s]

image

cc @bhamail / @DarthHater

@bguedel bguedel added the enhancement New feature or request label Apr 15, 2021
@bguedel
Copy link
Author

bguedel commented Apr 15, 2021

i am wondering if this code is expecting to find an executable named gradle in the working directory

return PackageDependenciesHelper.checkIfValid("build.gradle", "gradle");

if thats the case; this will not work with projects with a wrapper; as the wrapper is in a folder named gradle.

@bguedel
Copy link
Author

bguedel commented Apr 15, 2021

An example for this could be created by going to
https://start.spring.io

making sure to select gradle (or maven if you want to prove that out as well; it comes with a wrapper).
Select a dependency... say spring-web (has known cve)

this is my example
image

@bguedel
Copy link
Author

bguedel commented Apr 15, 2021

Overall thanks to the community; on the gradle plugin, you have already fixed an issue for me :)

sonatype-nexus-community/scan-gradle-plugin#67

@DarthHater
Copy link
Member

@bguedel check out #201 , I haven't tested it yet (I will) but that might do the trick.

@bguedel
Copy link
Author

bguedel commented Apr 16, 2021

Yeah that does look promising.

@DarthHater
Copy link
Member

@bguedel I got a chance to test this morning, had to make some changes, but it looks like it's working now. I will go ahead and merge it, if you can give it a test!

@brent-spiner
Copy link

🎉 This issue has been resolved in version 1.0.26 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@bguedel
Copy link
Author

bguedel commented Apr 16, 2021

I dont think ill be able to test until it gets released

image
image

@bguedel
Copy link
Author

bguedel commented Apr 16, 2021

GET OUT OF MY HEAD @brent-spiner

@bguedel
Copy link
Author

bguedel commented Apr 16, 2021

@DarthHater Looks like it didnt solve it on my end.

image
image

@DarthHater
Copy link
Member

Interesting! What it's doing is checking to see if the command exists, do you have a gradle alias? etc...?

@bguedel
Copy link
Author

bguedel commented Apr 16, 2021

not anymore; removed the alias; removed the symlink
image
image

@DarthHater
Copy link
Member

Interesting. VS Code uses it's own interactive shell, so maybe in that shell there is an alias or something akin?

I just pushed up another commit to main that separates out where it checks for it. I'll add some logging in a bit and see if we can get to the bottom of it!

@DarthHater
Copy link
Member

DarthHater commented Apr 16, 2021

@bguedel there will be a new version released soonish that has logging implemented for the Gradle command stuff. Once that's released, take a look at this section of the README for info on the logger: https://github.com/sonatype-nexus-community/vscode-iq-plugin#development

Set it to INFO and give me the bits that are around Gradle (I don't need anything past this block of info (just trying to see what it is happening more or less in the Gradle muncher):

Screen Shot 2021-04-16 at 11 06 36 AM

@bguedel
Copy link
Author

bguedel commented Apr 16, 2021

sure can we "unclose" this issue so that its not lost in the wrong tab?

@DarthHater DarthHater reopened this Apr 16, 2021
@bguedel
Copy link
Author

bguedel commented Apr 16, 2021

{
  "startTime": "2021-04-16T19:47:32.378Z",
  "categoryName": "sonatypeIQ",
  "data": ["Starting to Munch on GradleDependencies dependencies"],
  "level": {
    "level": 20000,
    "levelStr": "INFO",
    "colour": "green"
  },
  "context": {},
  "pid": 26473
}, {
  "startTime": "2021-04-16T19:47:32.378Z",
  "categoryName": "sonatypeIQ",
  "data": ["Starting to attempt to get gradle dependencies"],
  "level": {
    "level": 10000,
    "levelStr": "DEBUG",
    "colour": "cyan"
  },
  "context": {},
  "pid": 26473
}, {
  "startTime": "2021-04-16T19:47:32.379Z",
  "categoryName": "sonatypeIQ",
  "data": ["Does gradle exist as a command?", true],
  "level": {
    "level": 10000,
    "levelStr": "DEBUG",
    "colour": "cyan"
  },
  "context": {},
  "pid": 26473
}, {
  "startTime": "2021-04-16T19:47:32.379Z",
  "categoryName": "sonatypeIQ",
  "data": ["Set gradle Command Base Command", "gradle"],
  "level": {
    "level": 20000,
    "levelStr": "INFO",
    "colour": "green"
  },
  "context": {},
  "pid": 26473
}, {
  "startTime": "2021-04-16T19:47:32.379Z",
  "categoryName": "sonatypeIQ",
  "data": ["Full gradle command constructed", "gradle dependencies --configuration runtimeClasspath"],
  "level": {
    "level": 20000,
    "levelStr": "INFO",
    "colour": "green"
  },
  "context": {},
  "pid": 26473
}, {
  "startTime": "2021-04-16T19:47:32.380Z",
  "categoryName": "sonatypeIQ",
  "data": ["Attempting to run gradle command", "gradle dependencies --configuration runtimeClasspath"],
  "level": {
    "level": 10000,
    "levelStr": "DEBUG",
    "colour": "cyan"
  },
  "context": {},
  "pid": 26473
}

@DarthHater
Copy link
Member

WILD, so it is finding a gradle, at least in that shell. Let me see if I can cook up something else.

@bguedel
Copy link
Author

bguedel commented Apr 16, 2021

Yeah. A little more debugging on my side and I was right.

i am wondering if this code is expecting to find an executable named gradle in the working directory
vscode-iq-plugin/ext-src/packages/gradle/GradleDependencies.ts

Line 29 in 33010ee

if thats the case; this will not work with projects with a wrapper; as the wrapper is in a folder named gradle.

I renamed the gradle folder to gradlez

{"startTime":"2021-04-16T19:55:18.853Z","categoryName":"sonatypeIQ","data":["Does gradle exist as a command?",false],"level":{"level":10000,"levelStr":"DEBUG","colour":"cyan"},"context":{},"pid":26473},
{"startTime":"2021-04-16T19:55:18.853Z","categoryName":"sonatypeIQ","data":["Operating system determination","darwin"],"level":{"level":20000,"levelStr":"INFO","colour":"green"},"context":{},"pid":26473},
{"startTime":"2021-04-16T19:55:18.854Z","categoryName":"sonatypeIQ","data":["Set gradle Command Base Command","./gradlew"],"level":{"level":20000,"levelStr":"INFO","colour":"green"},"context":{},"pid":26473},

@bguedel
Copy link
Author

bguedel commented Apr 16, 2021

but then it fails b/c the wrapper tries to call the jar that is in ./gradle/wrapper/gradle-wrapper.jar and the path does not exist b/c its now gradlez.

:(

@DarthHater
Copy link
Member

That is wild, that means the library I'm using is hilariously bad.

I'll cook something better up tomorrow, everything worked fine for me locally on OS X, but I am not a gradle power user. I was using the scan-gradle-plugin to test it!

@bguedel
Copy link
Author

bguedel commented Apr 28, 2021

Hey @DarthHater,
We kind of left this knowing there was a slight issue with a lib you were using.

Any updates on getting a new version in with a better library?

@DarthHater
Copy link
Member

@bguedel I had to do a quick trip from Seattle to Alaska via car and it kinda knocked me out of commission, I'm going to look at this a bit more today!

@madpah
Copy link
Collaborator

madpah commented Jan 17, 2022

@bguedel - can you check if you still have these issues with version 1.2.3 please? This includes some changes also that prioritise gradlew support over gradle.

Thanks

FYI @DarthHater / @bhamail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants