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

Unable to resolve class for qualified imports #229

Open
gallardo opened this issue Aug 21, 2015 · 23 comments
Open

Unable to resolve class for qualified imports #229

gallardo opened this issue Aug 21, 2015 · 23 comments

Comments

@gallardo
Copy link

NetBeans reports an 'unable to resolve class ...' if using a qualified import. See screenshot below.

The error can be safely ignored.

Using:

  • NetBeans 8.0.2
  • Gradle 2.6 (explicitly set)
  • Gradle Support 1.3.7

To reproduce:

  1. New Project->Gradle->Gradle Root Project
  2. Import qualified class. For example: org.apache.tools.ant.filters.ReplaceTokens
  3. NetBeans report the error

image

@kelemen
Copy link
Owner

kelemen commented Aug 21, 2015

You need to specify the directory to where you have Gradle downloaded in the global settings and then the plugin should use the jars in its "lib" folder.

@gallardo
Copy link
Author

Uhmmm... this is currently the case. See screenshots below.

$grep ReplaceTokens ~/usr/gradle-2.6/lib/*.jar
Binary file /home/alberto/usr/gradle-2.6/lib/ant-1.9.3.jar matches

Global gradle properties:
image
Project gradle properties:
image

@gallardo
Copy link
Author

This issue is also applicable to "Single Gradle Projects"

@kelemen
Copy link
Owner

kelemen commented Aug 21, 2015

I have just checked the sources and it seems you are right. For some reason I just include the jar files starting with "gradle-". I will update this.

kelemen added a commit that referenced this issue Aug 21, 2015
@kelemen
Copy link
Owner

kelemen commented Aug 21, 2015

I have pushed some changes which should fix this in theory but to me currently it doesn't. However, due to some other circumstances I believe that I'm hitting a bug in the Groovy plugin, so it might work for you. Can you try building the plugin from the sources and see if it works for you?

@gallardo
Copy link
Author

Thanks! I'd love to, but the weekend keeps me away from my keyboard. I'll give it a try on Monday.

@gallardo
Copy link
Author

Thanks! It now looks much better :-)
image

@gallardo
Copy link
Author

Why are you excluding groovy-* ? The script I'm working with makes use of an XmlParser. I have rebuilt the plugin without the lowerCaseName.startsWith("groovy-") filtering and I finally had another warning solved:

before:
image

after:
image

@gallardo gallardo reopened this Aug 24, 2015
@kelemen
Copy link
Owner

kelemen commented Aug 24, 2015

I'm excluding it because the Groovy plugin uses the groovy-all jar defined in the library manager (or at least, this is what it says). So, I do not want to conflict with the Groovy plugin. To be honest I don't really know what the Groovy plugin does, I simply removed it because that was written in the Groovy global settings dialog. Though, I can add it if you think that including "groovy-all" is what solves the problem.

But first can you try if configuring the Groovy plugin properly works as intended or do I need to apply the change?

@gallardo
Copy link
Author

the Groovy plugin uses the groovy-all jar defined in the library manager

Interesting. I completely missed that the gradle plugin depends on the groovy plugin, but unfortunately, configuring groovy in the LibraryManager doesn't help either:

image

XmlParser is still not found:
image

@gallardo
Copy link
Author

By the way, I have desperately tried to create a test case for this issue mimicking https://github.com/kelemen/netbeans-gradle-project/blob/master/netbeans-gradle-default-models/src/test/java/org/netbeans/gradle/model/java/Issue101Test.java, but I'm failing miserably with FileNotFound errors:

java.io.FileNotFoundException: /tmp/gradle-dyn-model-test5453917525107490602/project-issue-229/build.gradle (No such file or directory)

I'm giving up for the moment, but if it helps, this build.gradle could be used as test data.

@gallardo
Copy link
Author

In any case, these issues doesn't impede the use of the plugin, so feel free to mark this (and #231) as enhancements.

@kelemen
Copy link
Owner

kelemen commented Aug 24, 2015

I'm not sure what test case did you try doing but I'm not sure it is reasonably possible to test from this plugin. In any case probably the solution is not to exlude the groovy-all. Maybe the Groovy config is meant only for some kind of Groovy projects (say for the Ant project type).

@gallardo
Copy link
Author

For the time being, I have patched it locally so I don't get distracted with the red flags. I'll report if I have any kind of undesired side-effects, but I doubt that with my use of the plugin I come in conflict with any other groovy installations.

Regarding the tests, the above mentioned Issue101Test.java seems to check for dependencies resolution (JavaModelTests.checkNoDependencyResolultionError) in a sample project. It looked very promising.

@kelemen
Copy link
Owner

kelemen commented Aug 25, 2015

Yes, but that only checks if I can request the compile/runtime dependencies from Gradle. I do no such thing for Gradle files (I'm not even sure if it is possible). That is, I just assume that the dependencies are the jars of the lib dir.

gallardo added a commit to gallardo/netbeans-gradle-project that referenced this issue Aug 25, 2015
It does read groovy-*.jar and it recurses into gradle/lib/plugins to resolve buildscript dependencies.
@ansiblejunky
Copy link

I have the latest Gradle plugin for Netbeans, but I am seeing these warnings in Netbeans (as discussed here). How can I fix this issue?
Also, I am able to successfully build my gradle project in my terminal window, but when I use Netbeans to build it has errors after downloading the dependencies that say File Not Found, but the files are definitely there! Why is it working without problems on my terminal but Netbeans wants to behave differently? Your help would be appreciated.

@kelemen
Copy link
Owner

kelemen commented Oct 15, 2016

@munichman2008 What exactly do you see? For you other problem, please open another issue with exact error messages and a detailed description.

@ansiblejunky
Copy link

Within the build.gradle file, Netbeans shows these lines cannot be resolved:
import org.apache.tools.ant.filters.ReplaceTokens
PublishingExtension publishingExtension = project.extensions.getByType(PublishingExtension)

I have the latest Netbeans and latest version of this plugin.

@kelemen
Copy link
Owner

kelemen commented Oct 15, 2016

I probably should list those .jar files in the plugin folder, I just never checked the implications of adding them (if it has some adverse effect). Regardless, you will have much more issues with the Groovy editor but I have seen that Sven is working on NB's Groovy support and it looked promising.

I personally rarely write complicated logic into .gradle files but instead use buildSrc, you might use that if it makes sense in your context (i.e., if this is not a small single project build).

@ansiblejunky
Copy link

What is buildSrc?
Which jar files are required to resolve these references?

@kelemen
Copy link
Owner

kelemen commented Oct 15, 2016

For every Gradle project (multi project build) you can have a Groovy project named buildSrc in the root project's directory. That project (buildSrc) will practically become the dependency of all your Gradle scripts , so you can use anything from that project (you may even define your own plugins to apply in build scripts). As an example, you can look at the buildSrc of this project: https://github.com/kelemen/netbeans-gradle-project/tree/master/buildSrc

@ghost
Copy link

ghost commented Jun 25, 2018

Not sure if this is the same root cause, but with NetBeans 9 (beta1) the editor flags the line:

import groovy.sql.Sql

as invalid as well, even though the build script works fine from within NetBeans and from the command line. t's not a real problem, just a bit annoying. This is with version 2.0.0.2 of the plugin.

Here is a screenshot:

2018-06-25 11_41_05

@kelemen
Copy link
Owner

kelemen commented Jun 25, 2018

I have seen and checked this problem many-many times and I strongly believe that this is a non-deterministic issue of the Groovy integration, so I can't really do anything about it.

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

No branches or pull requests

3 participants