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

Automatic dependency/classpath handling with maven #26

Open
mdealer opened this issue Jan 28, 2022 · 7 comments
Open

Automatic dependency/classpath handling with maven #26

mdealer opened this issue Jan 28, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@mdealer
Copy link

mdealer commented Jan 28, 2022

Good work so far, this extension looks promising.

But, I have a maven Groovy project (Jenkins shared library) and there are around 14000 files in the maven repo cache with direct and indirect dependencies of various versions of Jenkins and their plugins. It would be nice if adding every JAR file would not be required and the extension would detect maven and use its repo cache and searched it for the required JARs.

Right now I am facing many java.lang.NoClassDefFoundError or squiggly lines everywhere. All in all I think it's around 10-50 JARs, but it's cumbersome to adjust the list in extension settings as soon as a dependency tree changes versions.

@shadycuz
Copy link
Member

Let me take this issue to the maintainers of the groovy language server, as that is where the logic for the jars is held.

@shadycuz
Copy link
Member

shadycuz commented Feb 10, 2022

@mdealer

You said: "It would be nice if adding every JAR file would not be required"

You can also just set a directory, instead of each individual jar file. Like this in your vscode settings:

"groovy.classpath": [
        "/home/shadycuz/repos/dsty/jenkins-std-lib/build/dependencies"
    ],

@shadycuz shadycuz added the enhancement New feature or request label Feb 10, 2022
@mdealer
Copy link
Author

mdealer commented Feb 10, 2022

@mdealer

You said: "It would be nice if adding every JAR file would not be required"

You can also just set a directory, instead of each individual jar file. Like this in your vscode settings:

"groovy.classpath": [
        "/home/shadycuz/repos/dsty/jenkins-std-lib/build/dependencies"
    ],

Is it supposed to recurse into subdirectories? I tried and kept getting the same errors. It only seemed to load the immediate JARs from that directory.

@shadycuz
Copy link
Member

Correct, It only reads jars from the parent directories. Would recursion fix the issue for you?

@mdealer
Copy link
Author

mdealer commented Feb 11, 2022

Correct, It only reads jars from the parent directories. Would recursion fix the issue for you?

I don't think so, because maven cache contains many different versions of everything. Versions are project specific and defined in the pom.xml.

@shadycuz
Copy link
Member

oh I see @mdealer

Thanks

@turchinc
Copy link

turchinc commented May 30, 2024

I was also struggling with this (still am!) - I am trying to setup a groovy scripting environment for my java based application framework in VS Code.

I use gradle for dependency management. I have a working gradle groovy project that builds the code (on the command line and in vscode: gradle compileGroovy completes as expected) but the dependencies are not recognized in the code editor, with lots of unable to resolve class xxx errors for my imports.

I thought I could automatically update the groovy.classpath setting in my workspace setttings.json directly in my gradle file like this, basically adding all the gradle dependencies to the extension classpath:

task updateGroovyClasspath  {
		doLast {
			def javaDeps = configurations.runtimeClasspath.files.collect { "$it" }
			def f = file("../.vscode/settings.json")
			def builder = new JsonBuilder(new JsonSlurper().parse(f))
			builder.content['groovy.classpath'] = javaDeps 
			f.write(builder.toPrettyString())
		}
}

compileGroovy {
		dependsOn updateGroovyClasspath
}

This works (at least I see lots of dependencies now in the settings), but the unable to resolve class xxx errors persist. Should this work? Am I missing something? Thanks.

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

No branches or pull requests

3 participants