[GRADLE-3086] Changing rootProject projectDir from settings.gradle does not work Created: 11/May/14 Updated: 15/Jul/14 Resolved: 15/Jul/14 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | 2.1-rc-1 |
Type: | Bug | ||
Reporter: | Gradle Forums | Assignee: | Luke Daley |
Resolution: | Fixed | Votes: | 1 |
Description |
The User Guide says that you can change the location of the root project from settings.gradle. |
Comments |
Comment by Gradle Forums [ 11/May/14 ] |
Please give a minimal self-contained example and explain the desired vs. actual outcome (i.e. how do you tell that it doesn't work). |
Comment by Gradle Forums [ 11/May/14 ] |
Sure, here the example: [1]https://github.com/Vampire/change-roo... Command: ```./gradlew test -c settings1.gradle && ./gradlew test -c settings2.gradle``` Actual oucome: D:\cygwin\home\bkautler\testing BUILD SUCCESSFUL Total time: 2.518 secs BUILD SUCCESSFUL Total time: 2.474 secs Expected oucome: D:\cygwin\home\bkautler\testing BUILD SUCCESSFUL Total time: 2.518 secs BUILD SUCCESSFUL Total time: 2.474 secs or Command: ```./gradlew :test :sub:test -c settings1.gradle && ./gradlew :test :sub:test -c settings2.gradle``` Actual oucome: D:\cygwin\home\bkautler\testing BUILD SUCCESSFUL Total time: 2.76 secs FAILURE: Build failed with an exception.
BUILD FAILED Total time: 2.599 secs Expected oucome: D:\cygwin\home\bkautler\testing BUILD SUCCESSFUL Total time: 2.76 secs BUILD SUCCESSFUL Total time: 2.76 secs *Note: The build.gradle next to the settingsX.gradle files is only there to have the test task working as the root project directory did not get changed. In the correctly working version it should not be present!* |
Comment by Björn Kautler [ 11/May/14 ] |
While playing I found another edge case. FAILURE: Build failed with an exception. * What went wrong: Could not select the default project for this build. No projects in this build have project directory 'D:\cygwin\home\bkautler\testing'. > No projects in this build have project directory 'D:\cygwin\home\bkautler\testing'. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 2.219 secs |
Comment by Björn Kautler [ 13/May/14 ] |
Some more information. I see now that settings3.gradle is working as expected as far as it gets, as it complains that the directory where I invoke gradle is not part of the build which is kind of correct as it is no project directory anymore but only the settings directory. May I suggest to use the root project as default project in this case? Adding -p root to the command line with settings3, resulting in ./gradlew :test :sub:test -c ./settings3.gradle -p root will yield again the same result as settings2.gradle, except that the root project is correctly the one from root, not from master, just the sub project is missing. Furthermore, cd root && ../gradlew :test :sub:test -c ../settings2.gradle and ./gradlew :test :sub:test -c ./settings2.gradle -p root work correctly as I just found out. |
Comment by Björn Kautler [ 13/May/14 ] |
Here you have the culprit: https://github.com/gradle/gradle/blob/RB_1.11/subprojects/core/src/main/groovy/org/gradle/initialization/SettingsHandler.java#L55 |
Comment by Björn Kautler [ 14/May/14 ] |
https://github.com/gradle/gradle/pull/277 should fix this issue. |