I'm trying to run gradle to generate an eclipse project.
I'd like the following structure:
project
└── src
├── main
│ ├── ...
│ ├── ...
│ └── ...
└── test
├── ...
├── ...
└── ...
Here is the relevant part of my build.gradle
:
sourceSets {
main {
java {
srcDir 'main'
}
}
test {
resources {
srcDir 'test'
}
}
}
It generates this .classpath
:
<classpathentry kind="src" path="src/main"/>
<classpathentry kind="src" path="src/test"/>
...
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/test/java"/>
This seems to be confusing eclipse. I'd like to remove the default source sets in gradle (I think that's the solution) which will generate a proper .classpath
.
As per SourceDirectorySet documentation here
srcDir
adds a new location to the set, while setSrcDirs
replaces, and is likely what you're looking for.
Try
sourceSets {
main {
java { srcDirs = [ 'main' ] }
}
test {
java { srcDirs = [ 'test' ] }
}
}
This overrides the source set property, instead of extending it. You can add more comma-separated directories in square brackets.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With