Cannot build using gradle when using clearcase - gradle

I have been trying to build my Java web application using gradle. Everything work fine in the local drive and the build goes through as expected. However, when I switch to using the clearcase MVFS File system (G:), the build seems to behave erratically. From the windows 10 command line, if I change directory to the G:\ drive location, and execute "gradle war", it works fine the first time. After that, I run the same command again - the already created war file gets deleted and the classes are removed. It's bizarre. I did the following and still the behavior is the same.
disabled daemon
disabled file watching
Its the same behavior with Gradle 7 and gradle 6.8.
When I delete the .gradle folder, everything works fine again.
So - Does gradle not support the NFS and MVFS File System ? What is the solution to this problem ? Any help is appreciated.

Does gradle not support the NFS and MVFS File System ?
That is why I proposed in 2018 to use gradle only in snapshot views.
Especially considering a "gradle --no-daemon build" does defeat the purpose of having the daemon at all.
A build is better served in a local filesystem than a mounted one (MVFS dynamic views) which relies on where your view server is.

Related

gradle-wrapper.properties not found after clean install intellij idea 2020.1.2 community edition on windows 10

Installed clean windows10(1607) and intellij idea(2020.1.2 community edition). When i create new gradle project
Invalid Gradle JDK configuration found. Open Gradle Settings
"gradle-wrapper.properties not found".
How can I fix it?
Install gradle 6.7
sdk install gradle 6.7
brew install gradle
Go to IntelliJ and set gradle version:
On File >> Settings >> Build, Execution , Deployment >> Gradle
or
Preferences >> Gradle
In Use Gradke from specific the correct location
If IDEA is set to use the Gradle wrapper (as it is in your screenshot: "Use Gradle from:" is set to "gradle-wrapper.properties"), IDEA expects the following file structure:
Gradle wrapper JAR: [project root]/gradle/wrapper/gradle-wrapper.jar
Gradle wrapper properties: [project root]/gradle/wrapper/gradle-wrapper.properties
Gradle wrapper script: [project root]/gradlew.bat
If you are missing one of these three elements, IDEA will attempt to generate the wrapper by calling the gradle wrapper task. It will do this using the Gradle JDK, which may or may not be the project SDK (File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM).
I'm not sure how it selects the version of Gradle it uses - I only have 6.8.3 installed on my machine, and I had my wrapper properties set to 7.0-rc-1, yet somehow it used 6.7.0 when generating the wrapper.
I tried various options for clearing the cache, but did not get the result.
Openjdk-14 installed by default and does not work. From site adoptopenjdk.net install OpenJDK 11 (LTS). When creating the project, I chose 11 version. Then the program suggested updating gradle to version 6 and it worked.
I ran into this problem a while ago when I upgraded to intellij 2020.* The first time I created a new project there was no problem: gradle daemon did its work and the project was created with no problems.
In my case, the project would start a new gradle daemon, and attempt to build the project, would get rejected by windows Security, and nothing would happen, so intellij goes ahead and starts another (unsuccessful) daemon. Soon, I had 20+ gradle daemon processes running on my system, all of them doing nothing.
So, it looks like intellij has messed in enabling that it places the appropriate permissions it requires for these folders that it depends on to run properly. So, you need to manually give these permissions, and then things (should) work.
The real issue here is security on your machine: either a virus checker or the security software, Windows Security on Windows 10, for example. The first time you make a project, Intellij goes and produces a number of folders that they need access to.
However, once these folders are available, for whatever, intellij doesn't make sure to give itself access.
On windows 10, in AppData, you'll find several folders required by Intellij to produce, in my case, produce gradle projects.
Try finding the various folders that Intellij has produced on your system, and give them exceptions on your virus checker and on whatever firewall/security software programs that may block access.

problems running state machine examples

Congratulations on the spring state machine, I found it yesterday and have been trying it out, specifically the turnstile example running in STS. I found it very easy and intuitive to build a FSM.
Because spring shell doesn't work well in STS I tracked down the instructions to run the examples from the command line in the reference doc,
"java -jar
spring-statemachine-samples-turnstile-1.0.0.BUILD-SNAPSHOT.jar"
,
but running it got an error
"no main manifest attribute, in spring-statemachine-samples-turnstile-1.0.0.BUILD-SNAPSHOT.jar".
Although not even a novice in using gradle, I tried fixing this by adding this line to build.gradle in the jar section
"manifest.attributes['Main-Class'] = 'demo.turnstile.Application'"
(which doesn't handle the various sub-projects I know) but got this error
"NoClassDefFoundError: org/springframework/shell/Bootstrap".
If it is possible to run the samples from gradle, could you include them in the reference document? I tried running the samples using
gradle run
but it there was no interaction with the shell scripts.
Samples are designed to be run as executable jar and with shell so that you can interact without a need to recompile with every change. Your error indicates that you didn't build that sample jar as mentioned in docs.
./gradlew clean build -x test
This will automatically use spring boot plugin which will add the necessary jar manifest headers to jar meta info to make it a true executable jar. Essentially every every sample is a spring boot app.
Building SM sample projects in Windows Environment:
Open Command prompt (windows key + r -->cmd-->Enter), Change directory to project root folder spring-statemachine-master (Inside the Extracted folder).
Run gradlew install to get all spring dependencies copied to local machine.
Run gradlew clean build -x test to get the spring shell jars built. Courtesy Janne
These steps should ideally get all .jar built, look into \build\libs folder of respective sample project for jar files.
Run the like any other java jar file java -jar [jar-file-name.jar] (make sure to be change directory to jar file directory location).
One more thing where I was stuck was, How to give events to SM:
It's like this sm event EVENT_NAME_AS_DEFINED_IN_CLASS. Ref
E.g.: sm event RINSE --> to washer project

Gradle Could not create service of type InitScriptHandler using BuildScopeServices.createInitScriptHandler()

I used gradle build command in Centos 7 terminal and I got output:
FAILURE: Build failed with an exception.
* What went wrong:
Could not create service of type InitScriptHandler using BuildScopeServices.createInitScriptHandler().
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
For me, killing the Gradle daemon (gradle --stop) really helped and fixed the issue.
Try setting your GRADLE_USER_HOME variable to a folder where you have valid access. Then this error will go away.
For ex: I faced the same issue today while I was running gradle clean command on a new slave machine.
My Gradle version was 2.3.
With --stacktrace, I came to know it was trying to create .gradle folder for storing Gradle's cache data (while I invoked Gradle to run clean task on the slave) and it was trying to create that folder under /some/location/where/gradle/exists OR some /path/location/xxx/yyy where the user which was running Gradle on the slave machine didn't have valid access to write (create folder/files).
i.e. the user which I used to connect from Jenkins machine to the slave didn't have write access to touch/mkdir anything in the default location (where Gradle thought, OK I should create .gradle folder here).
To fix it, I added the above GRADLE_USER_HOME variable in the slave's ENVIRONMENT Variable section. Now, as I have valid access in my home directory, I was OK.
Setting:
GRADLE_USER_HOME=~/gradle_2_3_cache/.gradle
resolved the issue.
You can set it to ~/.gradle as well. But I set it under a custom folder inside my ~ home directory (gradle_2_3_cache). This will help me in case I have another job/build run running on the same Slave machine but with a different Gradle version for ex: 2.5 etc version and if I want the .gradle cache for 2.3 and 2.5/x version in separate folders.
NOTE: When using parallel section within Jenkinsfile, it's best to avoid Gradle greatness (i.e. using same Gradle's cache i.e. using same GRADLE_USER_HOME) as otherwise, you'll land into a mine of interesting issues as listed here: Jenkins - java.lang.IllegalArgumentException: Last unit does not have enough valid bits & Gradle error: Task 'null' not found in root project
The Problem solved by simply using "sudo" and giving access to gradle to create a folder and write cache. use:
sudo ./gradlew
If you using wrapper gradlew, in root make directory .gradle_new
mkdir .gradle_new
chmod -R 777 .gradle_new
and run gradlew with arguments:
--project-cache-dir .gradle_new
Restarting the machine solved the issue.
I had the same problem.
For me it worked after I exclude the .gradle folder if you can not delete try to rename.
If you have just updated your JDK version and you have set up a Gradle wrapper in your project, you may want to double-check the wrapper version supports your new JDK. If not, consider removing wrapper-related files from the project (gradlew, gradlew.bat and gradle/wrapper/*) and re-generating them with the Gradle CLI, like so:
gradle wrapper --gradle-version <new-version-number>
e.g. gradle wrapper --gradle-version 4.10.2
This of course assumes your Gradle installation is up-to-date. If not, you will want to update that first.
I got the same error, got rid of it by using the correct version of Java / JDK. I was trying to build a Java 8 project with the Java 11 JDK. Check which version of Java JDK you are using.
To develop projects with different Java versions in parallel I now use jEnv to manage the different JDK versions: http://www.jenv.be/
This is a permission issue.
do a
gradle wrapper --stacktrace
you should see something like this
Failed to create parent directory '/home/cloud_user/my-project/gradle' when creating directory '/home/cloud_user/my-project/gradle/wrapper'
the user, cloud_user, has no permission to the directory
make cloud_user owner of the folder
sudo chown -R cloud_user:cloud_user /home/cloud_user/my-project/
I got this error when running code in IntelliJ Idea, and
gradle --stop
really not helped, as it said that "No Gradle daemons are running."
But simple kill of all gradle processes helped:
ps aux | grep gradle
kill -9 $PID
Permission issue. This fixed the issue for me:
sudo chown -R $USER dir
For me this was to do with Java versions. I have Java 10 installed and as the default Java on my system. Setting a JAVA_HOME pointing at Java 8 was sufficient for the project (graphql-spring-boot) to build.
If using the "Invoke Gradle script" build step, click on Advanced to reveal additional options. Locate "Force GRADLE_USER_HOME to use workspace" and check it.
If anyone is still struggling with this, my issue was caused by Microsoft preventing Java from running due to Controlled Folder Access security restrictions.
I didn't get the popup notification since my computer is set to Do Not Disturb Mode. Once I allowed access, Gradle ran fine.
For future reference.
I had the same problem, the issue was that the antivirus was blocking OpenJdk platform binary and java.exe which prevented android studio from being able to modify the files
I ran into this exception when trying to build a project that was mounted as read-only filesystem in a VM. The project set its own gradle cache so changing GRADLE_USER_HOME did not work. I had to change the filesystem to be read/write.
You Just Have to Run it under the super user (sudo ....) it works for me
If you run Docker-in-Docker and mount the project directory from docker host directly to docker container:
-v ${PWD}:/path_to_project -w /path_to_project
the owners are different and docker container user (either gradle or root) can't override/delete ./buildSrc/build or ./build/
One of the fixes - copy the sources inside the container to temporary directory and build there.
Smth like this (first mounted to project, but then copied to project-copy to "decouple" with the host system real files and run the build in the copy):
docker run -v "${PWD}":/home/gradle/project -w /home/gradle/project-copy \
--rm \
--entrypoint sh \
gradle:5.5.1-jdk11 \
-- -c "cp -r -T /home/gradle/project ./ && ./gradlew build"
In my case I had bad credentials to private Maven repository. JIdea does not show the inner exception but running gradle build reveals the problem immediately.
I used a Gradle project in Eclipse, Eclipse's Gradle was giving that error. When I installed NetBeans and its Gradle Plugin, the problem has gone, project was building okay. Another way to circumvent this error was using commandline ./gradlew , project also built successfully.
It seems that Eclipse's era is over, they appear to be unable to follow the progress.
This can happen if you run Gradle commands from separate terminals at the same time - I assume Gradle somehow locks ~/.gradle when it is running to prevent any problems.
I had that same error, while running gradle with java 14 (openjdk) as my default java implementation. Setting default java back to java 8 solved the issue
sudo update-alternatives --auto java
just run (taskkill /im java.exe /f) in command
In my case the error was different but I landed here, my error was:
Could not create service of type ExecutionHistoryStore using ExecutionGradleServices.createExecutionHistoryStore().
> Timeout waiting to lock execution history cache (/Volumes/Extreme SSD/FlutterProject/test/android/.gradle/6.7/executionHistory). It is currently in use by another Gradle instance.
Owner PID: unknown
Our PID: 94001
Owner Operation: unknown
Our operation:
Lock file: /Volumes/Extreme SSD/FlutterProject/test/android/.gradle/6.7/executionHistory/executionHistory.lock
It happens when you try to run flutter run from two separate terminals.
So I solved it by executing cd <projectPath> && flutter run from the active terminal which I was using first.
Basically, while executing some Gradle command, in this case building an android file, the terminal locks down some Gradle PID, so either you stop them or just simply use that terminal.
in my case manual removing the .gradle and .idea folders helped me
you can find them in the Android Studio if Project view selected
after this just clean and rebuild app
kill -9 'pid' solved the issue. pid can be found in the error log
To fix this issue, restarting your PC is the main solution
I got the same issue and for me worked below command.
./gradlew --stop
After that restart my system and wipe data of simulator and run again everything works fine.

Jenkins corrupted, need to know which files I need

I am having issues with Jenkins that I am unable to resolve, and all the solutions I've found online I've used in the past, but are not helping.
I am on windows 2008r2, utilizing svn, jenkins version 1.407.
Initially the service failed, and was not resolved with past methods. In the past I have successfully troubleshoot Jenkins by killing hung processes, restoring the war file, ect.
I have attempted a new install with bringing over the files in the jobs folder. The end result was a partially functioning Jenkins would attempt a build it would report no change and not update.
What I'm trying to determine is a list of files/folders beyond the jobs folder that I need to move to the new install. The initial install predates me and was Hudson. The folder has a number of obviously obsolete files and folders (both a jenkins.war and a hudson.war)
Go to Jenkins home folder and collect:
all ./*.xml files in - these are configuration files for plugins and jenkins itself
users/* in case you have security enabled
subversion-credentials/** and secrets/** for any kind of keys provided in jenkins to access svn or other resources
plugins/*.*pi folder for all plugins - you don't need to have the unpacked folders
jobs/*/config.xml - to retrieve all job configurations; jobs/*/nextBuildNumber if you care to continue build numbers
plugins may create additional folders which you may want to use
with that you should recreate Jenkins as it was. Pay especially attention to config.xml file in root folder - this holds main jenkins configuration. If your issue reproduces on new system most likely a plugin is cause for problems - in that case review log files most likely you will find out which plugin causes trouble.
You didn't indicate if you tried new setup with same version of Jenkins or newer one; if you are using newest version it may be that ssh key handling / svn authentication for each job needs to be updated as somewhen in last few months authentication / security handling changed. Best is to look into Jenkins release log.
I'm using Jenkins 1.55x on CentOS installed as RPM; given that it is a webapp I assume Windows 1.4x setup is similar.

Copying files between two windows servers through jenkins

I am working on a project where i want to copy the compiled file (which compiled through jenkins) from one windows server to another through jenkins. Jenkins is installed on a windows server and after building the code, those compiled file should be copied to another windows server through jenkins. Is there any way to achive it?
Jenkins might be able to do it, via the script steps running the scp command; however, if this is part of a build, I would suggest attaching the file(s) to a project, and distributing them through the maven repository.

Resources