简体   繁体   中英

gradle: how to exclude non-jars from eclipse build path

When I work on my Java project I let Gradle Eclipse plugin do the dirty work:

gradlew eclipse

However, after that there are non-jar files in the build path. Some extensions: .xml, .pom and .orbit. Naturally, Eclipse detects non-jar files on its build path and tells me the following:

The project cannot be built until build path errors are resolved

I remove these from the build path by hand, which is of course slower than I'd like it to be. I know there has to be an easy way that I haven't yet discovered to eliminate these files from the build path using the gradle(w) eclipse command.

So how is this done?

cd到项目后,尝试从命令行运行命令:

gradle cleanEclipse eclipse 

Closest I've got is by defining copy and remove tasks in my build file thus:

dependencies {
  ...
  myname 'only:non-jars-in-here:1.0.0'
}

task copyXXX(type: Copy) {
  from configurations.myname
  into 'dir'
}

task removeXXX(type: Delete) {
  delete configurations.myname
}

classes.dependsOn copyXXX
copyXXX.finalizedBy removeXXX

A bit pedantic but I'm open to optimizations, since I still have lots to learn from Gradle.

Even with what I have above the question remains unsolved, since although these (in my case xsd files) are moved and don't appear in build path, some dependencies include both jars and xml files. Those xmls I have to remove by hand from eclipse build path.

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