how to specify the gradle local.properties path in command line param? - gradle

I hope to build my android app in both windows and WSL(win10's ubuntu),
but with the same local.properties file, it can't provide different style of path corresponding to each OS.
so I want to have two local.properties for each other and specify one in command line param, how could this be done?

Related

Providing system properties via command line with dot in the name in Gradle

We are migrating our project from Maven to Gradle. Our CI uses system properties like -Dwebdriver.type=firefox to set certain behaviour thus we don't want to hardcode such props in gradle.properties file etc. Is there a way to provide a system property with a dot in the name using command line?
If you run the following:
build.gradle:
logger.lifecycle("some.property ${System.properties['some.property']}")
with:
gradle -Dsome.property=lol
It should give you the expected output.

How can I make “gradle --console=rich” the default?

Along the lines of this answer (which works for me, BTW) and the javadocs, I tried
gradle.startParameter.consoleOutput = org.gradle.api.logging.configuration.ConsoleOutput.Rich
in my ~/.gradle/init.gradle. However, I still need --console=rich to get color output. Why?
Tested with Gradle 2.14.1 and 3.2.1.
Terminal is cygwin urxvt with TERM variable set to rxvt-unicode-256color.
Since Gradle 4.3 you can use org.gradle.console property in gradle.properties:
org.gradle.console=rich
A new console verbose mode will print outcomes of all tasks (like UP-TO-DATE) like Gradle 3.5 and earlier did. You can set this via --console=verbose or by a new Gradle property org.gradle.console=(plain rich verbose).
I am not sure if you can force the rich console from a gradle script, as the detection happens likely before the script is interpreted.
NativeServices class provides the integration with the console. If you look at the source code, there are two messages possibly printed in log:
Native-platform terminal integration is not available. Continuing with fallback.
Unable to load from native-platform backed ConsoleDetector. Continuing with fallback.
The latter might give you more information why. Try running the gradle script with --debug. You will likely find out that you are missing a native library that is either not available in cygwin or it is, but is not on library path.
I believe it works when you specify the rich console from the command line, because gradle forces the colours even though the console doesn't indicate it supports them.
Does it work if you don't use the cygwin console in Windows native command line or maybe GitBash?
There is a workaround how you can make this work. You can create an alias in cygwin that will always add the --console=rich.
If you are using gradle wrapper, you can edit the gradlew script and add the command line parameter. To make it automated, you can change the wrapper task to alter your script in the doLast part.
Create a file called gradle.properties inside your ~/.gradle/ folder.
Inside gradle.properties, add the line org.gradle.console=rich.
Each builds will run under --console=rich automatically because the new gradle.properties will be merged with the gradle.properties of your project.
If your project's gradle.properties contains the same tag as the local file, your project's will be used overriding the local file's
If you are on Linux/Mac set
alias gradle='gradle --console rich'
in your ~/.bashrc.
In Gradle Wrapper, add the following line:
org.gradle.console=rich
to ./gradle.properties in the root folder, where the gradlew script is located.

Relocate eclipse.ini

Is there a way to build an RCP application an relocate the eclipse.ini in a different location from where the eclipse.exe is located?
The Eclipse Product wizard only provides a "Root directory" where all files are exported to. It seems eclipse.exe has something built into it to look in the same directory for the ini parameters.
You can override where Eclipse looks for the eclipse.ini using the --launcher.ini command line argument to eclipse.
So if you do:
/path/to/eclipse -data /path/to/workspace
then it will use /path/to/eclipse.ini (on linux/win) and /path/Eclipse/eclipse.ini (on osx), if you want it to read a different file, do this:
/path/to/eclipse --launcher.ini /anotherpath/to/eclipse.ini -data /path/to/workspace
will cause eclipse to read /anotherpath/to/eclipse.ini instead of the default.
See Eclipse Help on the launcher command line arguments.

How to represent directory of IzPack installer?

I'm using Maven and IzPack. I'm looking for a way to put a file into the directory of the installer file. In the install.xml I've got a file tag set with a targetdir of "." but that will only work if the installer is executed from that directory. If executed from a different directory, the file is put in the current working directory of the user instead.
Having checked IzPack documentation, there's a built-in variable for $INSTALL_PATH, but I need the path of the installer. There's no way to predict where this installer will be when executed so specifying a pre-set directory won't work. Trying to specify the local directory via Maven just gives the path to the POM.
Is there an undocumented variable that would do the job or something else I've overlooked?

How to tell maven to get MAVEN_OPTS from specific file?

mvn command, among others, have following options:
-f,--file <arg> Force the use of an alternate POM file. (This is for pointing file instead of default pom.xml file.)
-gs,--global-settings <arg> Alternate path for the global settings file. (This one is for pointing the settings.xml file, which is by default in .m2 directory.)
Still there is yet one config file uncovered by these options - .mavenrc
So, my question is - Is there a way to tell maven from which file it should get MAVEN_OPTS?
MAVEN_OPTS is a environment variable from the OS. You can set it anyway you want before launching maven.
In bash (linux):
export MAVEN_OPTS=...
On windows:
set MAVEN_OPTS=...
I think you could even edit the 'mvn' of 'mvn.bat' shell script to get different variables.
Starting with Maven 3.3.1, you can put these settings into the .mvn/maven.config file in your project repository.
References:
JVM and Command Line Options
MNG-5767

Resources