简体   繁体   中英

Can't compile gradle vaadin project in Intellij

I want to try out Vaadin 7 with java 8, gradle 2.1, and IntelliJ 13.1.5 on Mac OSX. I installed gradle with brew. Here's what I've done so far

  • I created a project using the gradle wizard in Intellij
  • I set up tomcat like this Creating a Project with Intellij IDEA vaadin tutorial.
  • I've added the vaadin-gradle-plugin to my build.gradle file.
  • I hit the gradle refresh button
  • I ran vaadinCreateProject in the intellij gradle plugin menu
  • I made sure my JAVA_HOME and GRADLE_HOME point to correct locations

Everything works correctly with gradle commands, I ran vaadinRun and navigated http://localhost://8080 and saw the hello world. But IntelliJ has all identifiers highlighted red with "cannot resolve symbol". I've tried every form of recompiling and clearing caches.

How can I get Intellij recognize the code?

My gradle.build file.

apply plugin: 'java'
apply from: 'http://plugins.jasoft.fi/vaadin.plugin'

sourceCompatibility = 1.5
version = '1.0'

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
}

第一个IntelliJ屏幕截图第二个IntelliJ屏幕截图

The Vaadin Gradle plugin injects the Vaadin dependencies at runtime which Intellij's JetGradle plugin does not pick up for some reason.

What you can do instead is use the Gradle idea plugin (apply plugin: 'idea' in your build.gradle) and run the idea task. After that import the project into Intellij and all dependencies should be on the classpath.

Whenever you add a dependency you need to run the idea task again so the classpath is updated.

According to JetBrains , Vaadin plugin requires Gradle 3.0+

// Vaadin plugin requires Gradle 3.0+
task wrapper(type: Wrapper) {
    gradleVersion = '3.0'
}

I am not sure your project will be OK with that spoon of groovy, but without it it shouldn't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM