./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.
Related
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?
I would like to use wsig : I followed the guide .
So in step of deployement:
Prepare the WSIG web application content in the webModule directory. This step can be performed by means of the build target of the ANT build file included in the WSIG distribution.
When I launch the command ANT like this :
c:\JADE-all-4.5.0\add-ons\wsig>ant build.xml
it's displays this error :
buildfile: C:\Users\acer\Downloads\JADE-all-4.5.0\add-ons\wsig\build.xml
BUILD FAILED
Target "build.xml" does not exist in the project "wsig".
I checked the folder wsig , build.xml file exists in wsig folder.
Try this instead.
>ant -f build.xml
If you need to specify a target in the build.xml file then put that on the end. For example -
ant -f build.xml mytarget
See here for more information.
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).
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.
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.