How to clean buildSrc dir from root project in Gradle? - build

I have multiproject build in the buildSrc dir.
buildSrc
---build
--- subProject1
----build (2)
--- subProject2
----build (3)
--- subProject3
----build (4)
--- subProject4
----build (5)
config
gradle
src
build (1)
When I am in the root dir of my project I write:
gradle clean
but only build dir of the root project was deleted(marked with 1). How to trigger Gradle to delete all build directories prom buildSrc without to go manually to buildSrc and to write gradle clean.(marked with 2,3,4,5)

Since buildSrc is just a gradle project, you can start gradle in buildSrc folder with clean task specified using -p gradle option:
./gradlew -p buildSrc clean
Unfortunately it still requires another gradle invocation before your main build.

There is no way to do this (but you shouldn't ever have to clean buildSrc).

Related

How do I copy a directory every time I build the project?

I'm trying to copy the res directory into the build directory but it only happens when I reload the CMake file and build the project. Here's the code I'm using to achieve this:
add_custom_command(
TARGET project PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/res/ $<TARGET_FILE_DIR:project>/res/
)
I've tried using the file command to copy the directory, but that method also has this issue. Is there a way to copy a directory every time I build the project?

Why settings.gradle file is not used when -b is specified?

From Gradle User Guide we can read that
You can use the -b option to select another build file. If you use -b option then settings.gradle file is not used.
So lets have:
-Example #Project root
--src
--main
--test
--build.gradle
--second.gradle #Second build script
--settings.gradle
What is the purpose of this? If I want to try something different with my multiproject build I create another script file - second.gradle and put it in the same directory. But want old settings.gradle file to include my subprojects.
If I execute my gradle comands when I am in the root directory of Example project for ex:
gradle -b second.gradle clean build
Why Gradle does not use settings.gradle file? To protect itself when specified build file is not in the same dir, because Gradle will looks for settings.gradle in the direcotry of build.gradle file and after that in the parent directory. But they can empty or can be from another project?
-b allows to pass a different build script for a single-project build. It is not meant to be used for multi-project builds, where settings.gradle alone determines where build scripts are located.

TeamCity: How to setup a build with two VCS roots

I have two separate projects from two separate TFS VCS roots that I want to be part of the same build and was wondering if this is possible.
Project 1
VCS Root: $/ProductName/Development/Project1
Build file path: API/API.sln
Project 2:
VCS Root: $/QA/Test/Tools/Project2
Build file path: Test/Test.sln
I want step #1 of the build to compile Project 1, and step #2 to compile Project 2. How can I do this if the build file path is relative to the VCS root/checkout directory and the solutions are from two different VCS roots?
Thanks in advance!
it is possible to have two VCS Roots and change the checkout folder of them (so not check out both in the root folder). For that, change the "Checkout Rule" on our "VCS Roots" dialog and add for your project:
For Project1:
+:.=>project1
And for Project2:
+:.=>project2
Than you get this structure in the root:
root
- project1
- project2

Gradle build: does someone tried alternative build script with alternative setting.gradle?

I am using gradle 1.4, and renamed a build.gradle to buildExpr.gradle and settings.gradle to settingExpr.gradle, both files are in the project root, and I am using following command to run gradle build.
'gradle C:\myProject>gradle -i -b buildExpr.gradle -c settingsExpr.gradle project'
it seems command line option '-c' is not being honored and gradle is not picking settingsExpr.gradle file, hence it is not able to display all modules defined in settings.gradle file while executing project task.
I am getting following log
-------------------------------------LOG----------------------------------------------------
C:\ASM\asm_workspace\asm71\AutoLab>gradle -i -c settingsExpr.gradle -b buildExpr.gradle project
Starting Build
Settings evaluated using empty settings script.
Projects loaded. Root project using build file 'C:\ASM\asm_workspace\asm71\AutoLab\buildExpr.gradle'.
Included projects: [root project 'AutoLab']
Evaluating root project 'AutoLab' using build file 'C:\ASM\asm_workspace\asm71\AutoLab\buildExpr.gradle'.
All projects evaluated.
Selected primary task 'projects'
Tasks to be executed: [task ':projects']
:projects
Root project
Root project 'AutoLab'
No sub-projects
it is very strange behavior by gradle command line shows. but if I change buildExpr.gradle to build.gradle and settingsExpr.gradle to settings.gradle, it executes normally and shows all sub-modules in log
-b and -c can't be used together. When using a settings file, everything else (e.g. the locations of build files) is determined from the settings file.

How to pass build.gradle directory to gradlew?

./gradlew can be run in the same directory as the build.gradle file, but how can I run gradlew (standard Gradle wrapper) from another directory? For Make, one can pass "-C DIRECTORY" to "Change to DIRECTORY before doing anything.". Is there an equivalent parameter in Gradle?
Just found it from Appendix D. Gradle Command Line.
The answer is -p <your project directory>, which defaults to the current directory.