无效的类路径发布/导出依赖性/ ouat-contract.项目条目不受支持

art*_*nsc 3 gradle gradle-eclipse

我正在尝试创建一个类似于此结构的Gradle多项目

ouat-services
  - ouat-contract
  - ouat-servicesImpl (web project)
Run Code Online (Sandbox Code Playgroud)

我按照eclipse示例定义了我的ouat-services settings.gradle as

include "ouat-contract", "ouat-servicesImpl"
Run Code Online (Sandbox Code Playgroud)

在我定义的ouat-servicesImpl build-gradle中

dependencies {
  compile project(':ouat-contract')
}
Run Code Online (Sandbox Code Playgroud)

当我尝试在ouat-servicesImpl中应用war插件时,我的问题开始了,我在eclipse问题视图中收到以下消息:

Invalid classpath publish/ export dependency /ouat-contract. Project entries not supported
Run Code Online (Sandbox Code Playgroud)

我的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'
  }
}
Run Code Online (Sandbox Code Playgroud)

我的ouat-servicesImpl构建gradle更改为:

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"
}
Run Code Online (Sandbox Code Playgroud)

这是一个eclipse插件问题还是我做错了什么?

ATr*_*bka 11

这是我发现的神奇步骤,使其无需手动处理项目设置.

  1. 运行命令:gradle cleanEclipse eclipse

    • 由于这个命令,Eclipse忘记了项目应该具有gradle性质.
  2. 通过Configure - > Convert to Gradle Project将gradle nature添加回项目.

    • 作为此命令的结果,错误重新出现.
    • 如果出现不兼容的插件java版本错误,则只需删除.settings目录并刷新.
  3. 运行命令:gradle cleanEclipseClasspath eclipseClasspath

    • 这最后一步应该一直固定到下一次.

  • 我只是针对违规项目进行了最后一步,它对我有用.不需要重新进口. (5认同)

rom*_*ara 6

就我而言,这是由于混合了"分面"和非分面项目.带有错误的项目已经转换为多面形式,他们引用的项目也没有被引用.您可以通过使用eclipse-wtp插件将项目配置为分面,方法是将其添加到您的ouat-contract gradle文件中:

eclipse{
    wtp{
        facet{}
    }
}
Run Code Online (Sandbox Code Playgroud)

这将在使用java和war插件时添加Java和实用程序模块的方面(有关默认值的更多信息,请参阅EclipseWTPFacet文档,如果不使用war插件,请参阅Eclipse的手动添加方面).实用模块部分是避免错误的关键.

请注意,在此块中,如果需要执行其他操作(如指定特定的Apache Tomcat Runtime或类似操作),您还可以直接访问facet文件以执行手动XML操作.

一旦你做了这个改变,你可以使用Eclipse在工作区内的ouat-contract上做Gradle - >全部刷新 - 一旦我这样做,错误就消失了