Gradle is failing in IntelliJ IDEA - gradle

trunk: failed at 11/26/2019 9:50AM
Could not create parent directory for lock file C:\Program Files\gradle-5.6.4\wrapper\dists\gradle-5.6.3-bin\82hbcx3fecbatlnap0jtj8ysr\gradle-5.6.3-bin.zip.lck

The folder C:\Program Files in Windows is by default protected and can only be changed if you do it with administrator rights. For the same reason, it is not supposed to be used as a work area for temporary or downloaded files. But this is what you are attempting to do.
When you run the Gradle wrapper scripts (through gradlew), it will download a Gradle distribution to your Gradle user home. The user home can be set by the environment variable GRADLE_USER_HOME, and if not set it will default to $USER_HOME/.gradle.
To me, it looks like you have downloaded a distribution manually (version 5.6.4) and then set GRADLE_USER_HOME to that folder. You shouldn't do that - just leave it to the default, or if you don't like that, another folder that doesn't require administrator rights to modify. Otherwise, Gradle will attempt to download the required distribution for your project (in your case version 5.6.3) to that folder and after that, create lock files and fill the cache with dependencies and more.
Some people also set a variable GRADLE_HOME to point to a default Gradle distribution. You can set this to the folder where you have manually downloaded it if you like, and then add %GRADLE_HOME%\bin to your PATH. But this is optional.

Related

Moving gradle build to another machine

It seems that when Gradle 3.1 downloads the dependencies for your project it stores them in:
C:\Users\username\.gradle\caches
I tried copying the contents of this folder to a different machine that has a fresh Gradle 3.1 installation, but when I try to build my project it still tries to download all of the dependencies from scratch, which then fails because the new machine has no internet connection.
How do I get around this?
Compress main folder C:\Users\username.gradle to gradleHome.zip
Copy and uncompress this gradleHome.zip file to another folder for example D:\gradle_home
set gradle_home environment variable to this new folder. See how to change environment variables in windows here.enter link description here

Gradle downloads to ?/.gradle directory when running tasks

Gradle created a ?/.gradle/ in the directory that gradle was run in. We would expect the cache directory to be created at ~/.gradle.
Example:
/project # Project root and cwd when running gradle command
/.gradle # Expected - project-specific gradle folder
/? # Directory literally named with a question mark
/.gradle # Unexpected - Global gradle folder with wrappers and cached artifacts
The user running the scripts did not have a home directory, giving the user a home directory or specifying a gradle-user-home solved the issue:
gradle --gradle-user-home=/foo/bar ...
or
GRADLE_USER_HOME=/foo/bar gradle ...
There are two different folders gradle stores information. ~/.gradle is used to store downloaded artifacts, gradle wrappers, etc. Basically everything that can be shared between multiple builds. The .gradle folder in your project is used to store project specific information used for example by the gradle up-to-date check mechanism.
let's find it out why it behaves like this.
As gradle use following code to get user home:
System.getProperty("user.home");
Follow the link for openjdk 8 source code.
It comes to conclusion: When JVM can not found user name in os, it will use ? as a return. So gradle will create ?/.gradle for usage.

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 package JMeter with Jar Bundler on Mac

I'm unable to use "Jar Bundler" on mac to create JMeter.app from ApacheJMeter.jar, I was wondering if anyone else had previous experience with configuring this tool? The problem for me seems to be that the lib folder being searched is set to an incorrect base path:
org.apache.jmeter.NewDriver: JMeter home directory was detected as: /Users/username/Applications/JMeter.app/Contents/Resources
I looked here: http://developer.apple.com/library/mac/#documentation/Java/Reference/Java_InfoplistRef/Articles/JavaDictionaryInfo.plistKeys.html
But no matter how I configured any of the said properties, the logs looked the same.
The real trick is making sure the bin and lib folders can be found. The only jar file you will need to add is ApacheJMeter.jar. Look in the bin/jmeter script for additional properties to put into the properties tab of the Jar Bundler. The java arguments in the bin/jmeter script should be copied into the VM Options field. Check Set Working Directory to Inside Application Package. Now create application. Open up the .app folder that was just created and copy the bin and lib folders into the Resources directory. Done.

Environment Variable for AppData\Local / Access Downloaded custom assemblies

I am trying to setup my TFS2010 Build and I want to access the files that are downloaded via the "Version control path to custom assemblies".
From what I can tell those files are downloaded to:
C:\User\<Build User>\AppData\Local\BuildAgent\<Built Agent Number>
I can directly access that folder via the above path, but it would be nice if there was an environment variable (or something I can use in the build) to access that folder indirectly.
Or... Is there a better way to get at these files? (I am putting a version file in there to be downloaded every time the build is run).
You can use %LOCALAPPDATA% environment variable. It expands to
RootDrive:\User\LoggedInUser\AppData\Local
Example: %LOCALAPPDATA%\BuildAgent
Note that %APPDATA% will expand to
RootDrive:\User\LoggedInUser\AppData\Roaming

Resources