Invalid classpath publish/ export dependency /ouat-contract. Project entries not supported

arthurfnsc picture arthurfnsc · May 28, 2015 · Viewed 10.5k times · Source

I am trying create an Gradle multi project similar to this structure

ouat-services
  - ouat-contract
  - ouat-servicesImpl (web project)

I followed the eclipse example and define my ouat-services settings.gradle as

include "ouat-contract", "ouat-servicesImpl"

In my ouat-servicesImpl build-gradle I define

dependencies {
  compile project(':ouat-contract')
}

My problem starts when I try apply war plug-in in ouat-servicesImpl, I receive the following message in eclipse problem view:

Invalid classpath publish/ export dependency /ouat-contract. Project entries not supported

My ouat-services build.gradle

configure(subprojects) {

  apply plugin: 'com.github.ben-manes.versions'
  apply plugin: 'eclipse'
  apply plugin: 'java'

  version = '1.0'

  sourceCompatibility = 1.8
  targetCompatibility = 1.8

  def defaultEncoding = 'UTF-8'
  [compileJava, compileTestJava]*.options*.encoding = defaultEncoding

  repositories {

    jcenter()
    mavenLocal()
    mavenCentral()
  }

  jar {
    manifest.attributes provider: 'Company'
  }
}

configure(project(':ouat-servicesImpl')) {

  apply plugin: 'checkstyle'
  apply plugin: 'eclipse-wtp'
  apply plugin: 'findbugs'
  apply plugin: 'jacoco'
  //apply plugin: 'jetty'
  apply plugin: 'pmd'
  apply plugin: 'war'
}

buildscript {

  repositories {

    jcenter()
    mavenCentral()
    mavenLocal()
  }

  dependencies {
    classpath 'com.github.ben-manes:gradle-versions-plugin:0.10.1'
  }
}

My ouat-servicesImpl build gradle was changed to:

dependencies {

  compile project(':ouat-contract')

  cxfArtifacts.each { artifact ->
    compile "org.apache.cxf:$artifact:$cxfVersion"
  }

  springArtifacts.each { artifact ->
    compile "org.springframework:$artifact:$springVersion"
  }

  testCompile "org.testng:testng:$testNGVersion"
  testCompile "org.hamcrest:hamcrest-all:$hamcrestVersion"
  testCompile "org.springframework:spring-test:$springVersion"

  //WAR PLUGIN
  providedCompile "javax.servlet:javax.servlet-api:$servletAPIVersion"
  runtime "javax.servlet:jstl:$jstlVersion"
}

Is this an eclipse plug-in problem or I am doing something wrong?

Answer

ATrubka picture ATrubka · Sep 2, 2015

Here's the magic steps I've discovered to make it work without messing with Project settings manually.

  1. Run command: gradle cleanEclipse eclipse

    • as a result of this command Eclipse forgets that the project was supposed to have a gradle nature.
  2. Add gradle nature back to the project by doing Configure -> Convert to Gradle Project.

    • as a result of this command the error reappears.
    • if incompatible plugin java version error appears then just delete .settings directory and refresh.
  3. Run command: gradle cleanEclipseClasspath eclipseClasspath

    • this final step should get it fixed until the next time.