I have a gradle project that I am trying to build.
when I execute gradle clean build, it fails with the following error message
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':FacebookUpdateDependencies'.
> Could not resolve all dependencies for configuration ':compiler'.
> Could not resolve com.company.facebook:compiler:1.2+.
Required by:
::1.0
> Could not resolve com.company.facebook:compiler:1.2+.
> Failed to list versions for com.company.facebook:compiler.
> Unable to load Maven meta-data from http://mycompanynexus/compiler/maven-metadata.xml.
> Could not GET 'http://mycompanynexus/compiler/maven-metadata.xml'. Received status code 500 from server: Internal Server Error
However, when I tried
./gradlew clean build the build is successful.
why the build fails in the former and not the latter?
here is revelant portion of build.gradle
task wrapper(type: Wrapper) {
gradleVersion = '2.11'
}
EDIT
local$: gradle -v
------------------------------------------------------------
Gradle 2.13
------------------------------------------------------------
Build time: 2016-04-25 04:10:10 UTC
Build number: none
Revision: 3b427b1481e46232107303c90be7b05079b05b1c
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.7.0_79 (Oracle Corporation 24.79-b02)
OS: Mac OS X 10.11.1 x86_64
local$ ./gradlew -v
------------------------------------------------------------
Gradle 1.12
------------------------------------------------------------
Build time: 2014-04-29 09:24:31 UTC
Build number: none
Revision: a831fa866d46cbee94e61a09af15f9dd95987421
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy: 2.2.0
JVM: 1.7.0_79 (Oracle Corporation 24.79-b02)
OS: Mac OS X 10.11.1 x86_64
I just noticed that the wrapper version is 1.12 and not 2.12. That is, there is a very large version difference between the wrapper and the installed version of gradle. There have probably been many incompatible changes to the different gradle plugins over the last 2 years, which may lead to the build problems you observe.
As already mentioned the gradle wrapper is a separate version of gradle that resides in the gradle/wrapper folder of your project. The wrapper is only built/updated, when executing the wrapper task in your project (gradle wrapper). That is your project's wrapper has not been updated for the last 2 years or has been created with the wrong version initially (1.12 instead of 2.11).
Given the above it's hard the tell what is actually causing the build to fail - apart from the incompatibilities between gradle 1.12 and 2.13. But this version mismatch is probably the root cause of your problem.
Most likely your project won't built anymore using the wrapper once you regenerated the wrapper with version 2.11 (the version mentioned in the build file), as 2.11 is likely to be incompatible to 1.12 as well...
This tells you that your Gradle version 2.11 will be used when gradlew command is invoked instead of the one installed on system. Always run gradlew command as it ensures your build is run against the gradle version it is supposed to, you are never required to install the correct version of gradle and really speeds up the build time.
Here is an excerpt from Gradle Wrapper definition:
Most tools require installation on your computer before you can use them. If the installation is easy, you may think that’s fine. But it can be an unnecessary burden on the users of the build. Equally importantly, will the user install the right version of the tool for the build? What if they’re building an old version of the software?
The Gradle Wrapper (henceforth referred to as the “Wrapper”) solves both these problems and is the preferred way of starting a Gradle build.
If a Gradle project has set up the Wrapper (and we recommend all projects do so), you can execute the build using one of the following commands from the root of the project:
./gradlew (on Unix-like platforms such as Linux and Mac OS X)
gradlew (on Windows using the gradlew.bat batch file)
Each Wrapper is tied to a specific version of Gradle, so when you first run one of the commands above for a given Gradle version, it will download the
corresponding Gradle distribution and use it to execute the build.
Related
Issue Description
Running "gradle clean" failed to artifacts from project output directory. After enable --stacktrace I can see below error
Caused by: org.gradle.api.file.UnableToDeleteFileException: Unable to delete file: C:\Users\xxxx\my-project-root\build\libs\some.jar
Here is my "gradle --version" output
------------------------------------------------------------
Gradle 5.1.1
------------------------------------------------------------
Build time: 2019-01-10 23:05:02 UTC
Revision: 3c9abb645fb83932c44e8610642393ad62116807
Kotlin DSL: 1.1.1
Kotlin: 1.3.11
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 1.8.0_152 (Oracle Corporation 25.152-b16)
OS: Windows 10 10.0 amd64
Initially my thought process was that some gradle daemon might be still be holding a reference to build artifacts. But after running "gradle --stop" I still get the same error for clean task.
Do note that if I open command prompt/powershell with administrative mode ":clean" tasks works fine.
I am not sure if anyone has faced this strange issue.
Solution
Please suggest if any.
As mentioned by Eric Anderson in this comment:
Is it possible you compiled once as Administrator earlier? It would have generated that file and your normal user may not have permission to it. I'd expect that after a gradle clean and gradle --stop as Administrator you would be able to compile as a normal user.
I ran into this same problem after having done sudo gradle run earlier, and a sudo gradle clean fixed it.
The file is likely open by another process. The easiest way to find the process keeping the file open is to use Process Explorer and "Find a Handle or DLL". Search for the file name. Then close the processes listed.
If you prefer a command-line tool, execute handle like:
handle c:\path\to\file
I am trying to execute a test inside a gradle project.But when Itry to execute the tests using 'gradle test' in Intellij it fails .
what I have tried
create and build the project without error using 'gradle clean build'
open run configuration in intellij , select gradle , and create and execution with gradle task 'test'
execute newly created gradle run configuration
what I observe
gradle fails at task 'test' with error 'Error: Could not create the Java Virtual Machine.'
also gradle run never stops until I forcefully stop it
also it keep printing ' gradle executor 1(,2,3 and so on) executing , failed '
I am using java 9 , intellij , gradle .
I am running Kotlin project with gradle in IntelliJ.
------------------------------------------------------------
Gradle 5.2.1
------------------------------------------------------------
Build time: 2019-02-08 19:00:10 UTC
Revision: f02764e074c32ee8851a4e1877dd1fea8ffb7183
Kotlin DSL: 1.1.3
Kotlin: 1.3.20
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 11.0.2 (Amazon.com Inc. 11.0.2+9-LTS)
OS: Mac OS X 10.14.3 x86_64
Getting similar issue, but to be specific:
Task :run FAILED
Unrecognized option: -d64
Error: Could not create the Java Virtual Machine.
...
To solve my issue, I basically had to select correct JDK for my IntelliJ.
To switch the Java runtime used to run IntelliJ IDEA:
On the Help menu, click Find Action, or press ⇧⌘A.
Find and select the Switch Boot JDK action.
Select the desired JDK and click OK.
Found this resource that helps! https://www.jetbrains.com/help/idea/tuning-the-ide.html
If by any chance you select a wrong JDK version, and the IDE not starting anymore, delete idea.jdk file: https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under?page=3
I'm a newer to gradle,and when i open a gradle application with idea,Then it throw an error Gradle 3.1 requires Java 7 or later to run. Your build is currently configured to use Java 6.
My gradle info:
Gradle 3.1
Build time: 2016-09-19 10:53:53 UTC
Revision: 13f38ba699afd86d7cdc4ed8fd7dd3960c0b1f97
Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_60 (Oracle Corporation 25.60-b23)
OS: Mac OS X 10.11.6 x86_64
idea
error
idea setting
file -> other settings -> default project setting
EIDT
Log
2016-10-30 14:25:06,941 [1651420] INFO - .BaseProjectImportErrorHandler - Failed to import Gradle project at '/Users/famoss/Downloads/btrace-master/gradle'
org.gradle.tooling.GradleConnectionException: Could not create an instance of Tooling API implementation using the specified Gradle installation '/Users/famoss/Downloads/gradle-3.1'.
Caused by: org.gradle.internal.jvm.UnsupportedJavaRuntimeException: Gradle 3.1 requires Java 7 or later to run. You are currently using Java 6.
Update the idea version to 2016.2.5 and the problem solved.
Check your local.properties file to see which version of java gradle is trying to reference. This file should be in the same directory as your gradle file.
Typically this file is automatically configured on project creation, but it depends on your intellij settings.
I have a java-maven project. I want to convert it to gradle so I did:
gradle init --type pom
And I got an error:
FAILURE: Could not determine which tasks to execute.
* What went wrong:
Task 'init' not found in root project 'my-project'.
* Try:
Run gradle tasks to get a list of available tasks.
BUILD FAILED
Total time: 1.78 secs
I have the last version of gradle:
$ gradle --version
------------------------------------------------------------
Gradle 1.4
------------------------------------------------------------
Gradle build time: Monday, September 9, 2013 8:44:25 PM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.3 compiled on April 8 2014
Ivy: non official version
JVM: 1.7.0_51 (Oracle Corporation 24.51-b03)
OS: Linux 3.13.0-24-generic amd64
Are you sure that you don't have a multi-project build? Specifically, be sure that you haven't already init a gradle project in the directory one level above.
I had the same problem on Debian. I installed gradle using apt-get. It installed version 1.5. (it was built in 2014)
Then I installed gradle manually, and now it works fine.
To complete mate00's answer... Let's say "my-project" is the sub-project that fails on init. If you have a multi-project build and you have the line include 'my-project' in the main project's settings.gradle file, it will throw this error.
The solution is to comment out include 'my-project' in the main projects settings.gradle, run the init command on my-project, and then uncomment that line.
I have a project that needs to use an older version of Findbugs but I would like to use the version of Gradle that I currently have installed on my computer and that is on my Path.
Here is part of my configuration with Java version and Findbugs:
apply plugin: 'findbugs'
apply plugin: 'java'
sourceCompatibility = 1.7
targetCompatibility = 1.7
findbugs {
effort = "max"
ignoreFailures = false
// Only run findbugs on source files
sourceSets = [sourceSets.main]
// File has exclusions for Findbugs
excludeFilter = file("${rootProject.projectDir}/config/findbugs.xml")
toolVersion = '2.0.3'
}
The target project needs to be compiled for Java 7 with a Java 7 compatible version of FindBugs. Here is the version of Gradle and Java that are on the Path:
$ gradle --version
------------------------------------------------------------
Gradle 2.1
------------------------------------------------------------
Build time: 2014-09-08 10:40:39 UTC
Build number: none
Revision: e6cf70745ac11fa943e19294d19a2c527a669a53
Groovy: 2.3.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0 (Oracle Corporation 25.0-b70)
OS: Windows 7 6.1 amd64
And if I try and run the FindBugs task I get the following error output:
$ gradle :findbugsMain
:Project:compileJava UP-TO-DATE
:Project:processResources UP-TO-DATE
:Project:classes UP-TO-DATE
:Project:findbugsMain FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Project:findbugsMain'.
> The version of FindBugs (2.0.3) inferred from FindBugs classpath is too low to work with currently used Java version (1.8). Please use higher version of
FindBugs. Inspected FindBugs classpath: [findbugs-2.0.3.jar, jcip-annotations-1.0.jar, jsr305-2.0.1.jar, bcel-2.0.1.jar, jFormatString-2.0.1.jar, dom4j-1.6
.1.jar, asm-3.3.jar, asm-commons-3.3.jar, commons-lang-2.6.jar, AppleJavaExtensions-1.4.jar, jaxen-1.1.6.jar, xml-apis-1.0.b2.jar, asm-tree-3.3.jar]
How do I configure this project to run an older version of FindBugs appropriately without having to edit my environment variables? How do I get it to run FindBugs with a different JDK than Gradle is currently running with?
You can't configure the JDK used specifically for the Findbugs task, but you can configure gradle to use a specific jvm in general by setting a property in your gradle.properties file:
org.gradle.java.home
Not that this java will be used for the whole gradle process and not just for Findbugs, but it does not require to change your environment variables.