Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ can't run gradle project due to missing Class

I just gave IntelliJ a try, because Eclipse annoyed me again. I imported my gradle project(jetty, vaadin) and it went quite smoothly. But when I tried to run it I encountered the following error message during "make":

Error:gradle-resources-test:vaadinsharedwidgets: java.lang.NoClassDefFoundError: org/apache/tools/ant/util/ReaderInputStream

"vaadinsharedwidgets" is a module of the project. From what I understand from the error, IntelliJ doesn't find ant, but this is intended because I don't use ant. It also not part of the transitive dependencies. The same project runs in eclipse fine and also building it in gradle works without any problems.

Update: I just checked in Eclipse and somehow the ant.jar is on the classpath in Eclipse but I can't link it to any project. I wonder how it got there.

Update2: Missing version information:

  • IntelliJ: v14.0.1 CE (no plugins)
  • Gradle: 2.2 (used via wrapper)
  • Java 8 (1.8.0 b05)
  • Vaadin 7.3.4

build.gradle:

apply from: 'http://nexus/gradle/vaadin.gradle'
apply from: 'http://nexus/gradle/java8.gradle'

version = '1.1'

description = "Gemeinsame Vaadin-Widgets"

vaadin.widgetset  'net.xyz.vaadinsharedwidgets.VaadinsharedWidgetsWidgetset'

dependencies {
    compile project(':ibhtheme')
    compile 'com.vaadin:vaadin-server:' + vaadin.version
    compile 'com.vaadin:vaadin-client:' + vaadin.version
}

jar{
    // Include source in jar
    from sourceSets.main.allJava
}

sourceSets.main.resources.srcDir  'src/main/webapp'

vaadin.gradle:

apply from: 'http://plugins.jasoft.fi/vaadin.plugin?version=0.9.2'

configurations {
    def conf = 'vaadin-client'
    def sources = project.sourceSets.main
    def testSources = project.sourceSets.test

    if (!project.configurations.hasProperty(conf)) {
        project.configurations.create(conf)

        sources.compileClasspath += project.configurations[conf]
        testSources.compileClasspath += project.configurations[conf]
        testSources.runtimeClasspath += project.configurations[conf]

        project.configurations[conf].exclude group: 'org.eclipse.jetty' 
    }
}


vaadin {
    version '7.3.4'
    push true
}

java8.gradle:

apply plugin: 'java'

sourceCompatibility = 1.8
targetCompatibility = 1.8

group = 'net.xyz'

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.5'
    compile 'com.google.guava:guava:16.0.1'
    compile 'org.springframework:spring-context:4.0.3.RELEASE'

    testCompile 'org.testng:testng:6.8.7'
    testCompile 'org.mockito:mockito-all:1.9.5'
    testCompile 'org.easytesting:fest-assert-core:2.0M10'
    testCompile 'org.springframework:spring-test:4.0.3.RELEASE'
}

Adding ant as an additional dependency to the module doesn't work.

like image 648
ssindelar Avatar asked Nov 18 '14 08:11

ssindelar


People also ask

How do I run Gradle project in IntelliJ?

From the main menu, select Run | Edit Configurations to open the run/debug configuration for your project. icon. In the list that opens, select Run Gradle task. In the Select Gradle Task dialog, specify the project and the task that you want to execute before launching the project.

How does IntelliJ recognize Gradle project?

In the Gradle tool window, right-click a linked project. From the context menu, select Open Gradle config F4 . IntelliJ IDEA navigates to the appropriate Gradle configuration file and the related build.


2 Answers

I encountered the same error in a Java project with multiple subprojects in IntelliJ 14.

Updating to 15.0.1, refreshing the Gradle projects via Views → Tool Windows → Gradle in IntelliJ and restarting fixed the issue.

like image 122
Matthias Braun Avatar answered Oct 28 '22 06:10

Matthias Braun


Choose File → Invalidate Caches / Restart from the menu and select Invalidate and Restart. That fixed the issue for me.

like image 42
neu242 Avatar answered Oct 28 '22 05:10

neu242