Note that there are some explanatory texts on larger screens.

plurals
  1. POIdea "Groovyc: unable to resolve class" - Works on command line
    primarykey
    data
    text
    <p>I have a gradle project in Intellij Idea that contains two modules:</p> <pre><code>foo-core |--src | |--main | | |--java |--build.gradle foo-test |--src | |--test | | |--groovy |--build.gradle build.gradle settings.gradle </code></pre> <p>foo-test contains a spock test that should test a class from foo-core. When I try to run the tests in foo-test from IntelliJ Idea, I get the following error:</p> <pre><code>Groovyc: unable to resolve class ... </code></pre> <p>But when I run them from the command line with <code>gradle :foo-test:test</code>, everything works just fine.</p> <p>Here is my toplevel settings.gradle:</p> <pre><code>include ':foo-core', ':foo-test' </code></pre> <p>And here is the build.gradle from foo-test:</p> <pre><code>buildscript { repositories { mavenCentral() } } apply plugin: 'groovy' sourceCompatibility = 1.7 repositories { mavenCentral() } dependencies { compile project(':foo-core') compile "org.codehaus.groovy:groovy-all:2.2.1" compile "com.google.inject:guice:3.0" testCompile "org.spockframework:spock-core:0.7-groovy-2.0" testCompile group: 'junit', name: 'junit', version: '4.11' } </code></pre> <p>The project dependencies of foo-test are correct in Idea. When I "Refresh all Gradle Projects", any changed dependencies are imported correctly.</p> <p>I have already tried cleaning all caches in Idea.</p> <p>Why can I run the tests in gradle on the command line, but cannot compile them in IntelliJ Idea?</p> <p><strong>Update: Answers to questions from comments</strong><br> Idea version 13</p> <p>I created an Android Gradle project in Idea and added more modules by creating the directories+gradle files and adding them in the toplevel "settings.gradle". Then I did a "Refresh all Gradle Projects" in Idea. I do not use the gradle idea plugin.</p> <p>The source and test directories are recognized by Idea. All project settings seem to be correctly imported in Idea (from gradle). I can use the java classes from <code>foo-core</code> in another java project (<code>foo-ui</code>), but can not use them in the groovy files.</p> <p>Just compiling in IntelliJ does not work. A full rebuild does not work either. Even "Refresh all Gradle Projects" produces the Groovyc errors.</p> <p>Also, the tests already worked when I had only two modules (<code>foo-ui</code> and <code>foo-test</code>), but stopped working after I moved some classes to a new module (<code>foo-core</code>).</p> <p><strong>Update 2:</strong> I have now updated to Idea 13.0.1. I have also tried to close the project, delete all .iml files and "build" directories and import it again. Both did not work.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload