Closed akoscz closed 8 years ago
Thank you for the report. I will look into it.
I'm not using Eclipse, just installed it. I could use your configuration and the class file was built in build\/en/buildconfig/classes/main/com\sample/app
though I did not find a way to make Eclipse see the generated file as in "it should propse to import BuildConfig
if i don't have an import statement yet". The depencency of the generated files is added to the configuration automatically. I have to figure out why Eclipse is not aware of it.
This is what it looks like in Netbeans: Image
It seems that I should test this on Eclipse. Thanks for the hint.
You have a point. The GenerateBuildConfigTask needs to be configured with the the package dir appended. The easiest way to fix this would be to document it. Other solutions would break compatibility.
Thanks for looking into this. Essentially, what I ended up doing as a work around is to follow the Advanced usage: Manual creation of tasks and wiring
instructions and append the package name to the outputDir. This will work for now, but it feel like a brute force way of accomplishing the goal rather than allowing the plugin to perform the desired behavior.
task generateBuildConfig (type: de.fuerstenau.gradle.buildconfig.GenerateBuildConfigTask) {
packageName = 'com.sample.app'
outputDir = new File ("${buildDir}/gen/buildconfig/src/main/" + packageName.replace('.', '/'))
}
For my edification, could you elaborate a bit on how appending the package dir would break compatibility?
What you did is correct. I think that the user should have full controll over the tasks outputdir. Therefore it's the users responsibility to set the package as subdir if needed. After all the preferred way is to use the configuration closure and the manual wiring is only for the users that need full control.
I updated the plugin to version 1.1.2. This renders your workaround obsolete. The package as subdirectory structure should be added automatically.
@akoscz Please tell me if this works for you.
@mfuerstenau Thanks for the quick turnaround! Works like a charm.
@akoscz Just wanted to point out that version 1.1.4 has some Eclipse support of sort. I do not use Eclipse myself but I fiddled with it and tried to make Eclipse add the generated folder to the buildpath file .classpath
, there is also an example in the README.md how to do it manually if one's tasks are manually modelled.
@mfuerstenau Awesome! Thank you. I personally do not use Eclipse either, although the team that contributes to the project I am participating in uses Eclipse heavily.
It would be awesome if you could also add IntelliJ support. In other words, add the generated source file into the IntelliJ modules classpath. There is a gradle plugin that allows for editing of the IntelliJ modules file.
For the time being, I have added the following to my build.gradle file
sourceSets.main.java {
srcDir 'build/gen/buildconfig/src/main'
}
and I'm directing people through the README.md file that when building through an IDE to manually generate the BuildConfig.java file.
NOTE: When building from an IDE you will need to manually generate the BuildConfig.java file,prefereably before you import the project. Otherwise your IDE will complain about unresolved references to BuildConfig.
* Linux/Mac OSX ./gradlew compileBuildConfig
* Windows gradlew.bat compileBuildConfig
I'm working on a project where I need to provide support for the Eclipse IDE. Eclipse complains loudly and refuses to build if a source file does not reside in the declared package folder. For example:
The
BuildConfig.java
file that is produced is placed inbuild/gen/buildconfig/src/main/
. Since we specified a packageName, it should really reside inbuild/gen/buildconfig/src/main/com/sample/app/