I am trying to run gradlew on offline machine. It starts from message
Downloading https://services.gradle.org/distributions/gradle-2.10-all.zip
and then fails with exception.
What it wants and how to satisfy it?
Option 1. If you have possibility go online temporary
Command gradlew means you are trying to use Gradle Wrapper. It is a tool for automated downloading of Gradle distribution.
In order to download Gradle Wrapper you have to execute gradlew command with a proper network connection at least once.
Make sure you have correct network and proxy settings.
./gradlew build
Only after that you can build a project offline. Example:
./gradlew build --offline
Option 2. Download distribution by hand
Or, alternatively, you could download distribution from official site. Then extract it, add gradle to PATH variable, and run:
gradle build --offline
Related
I am trying to update my local gradle(out of ide) from 6.5.1 to 7.0.0.
I try two commands from gradle website and network in cmd and path is the root of one of my project(there are gradlew.bat and gradlew files):
gradle wrapper --gradle-version=7.0 --distribution-type=all
gradlew wrapper --gradle-version=7.0 --distribution-type all
And, i try those commands to check the version
gradle -v
gradlew -v
The gradlew updates sucessfully. It prints version 7.0.0.
However, the version of gradle is still in v6.5.1.
How can I update it without download the v7.0.0 packet and cover the files in disk(I am worrying about that i should download all of my packages again in new gradle)?
ps: the gradle is locating in D:\gradle in my disk and java environment is openJDK 15
Thanks agains
I had the same problem and, in my case, the problem was a running gradle demon using the previous version. Check running demons with:
gradle --status
Stop the demons with
gradle --stop
Also I restarted the console/terminal.
You cannot update your gradle standalone version without downloading it, and with gradle wrapper you cannot upgrade your gradle installation, it always works on your current project folder (command gradlew) only. To upgrade a standalone gradle installation (command gradle without the wrapper prefix w), you have to manually download the binaries, include the new bin directory in your PATH environment as described in the manual on the gradle homepage, or use a package manager like sdk man, chocolatey, brew etc.
If you are using the gradle wrapper gradlew for your builds, it works completely independent from your gradle installation.
I'm learning gradle and some questions bother me
When I want to use gradle, I'd better use gradlew. But when I want to use gradlew, I need a installed gradle. So is that a story about chicken and egg?
Should be gradle-wrapper.jar uploaded to git repository? Some docs say git should track it, but it seems not good to track a binary file with git.
Using ./gradlew you are using a gradle wrapper. The wrapper is part of a project and it is able to download and install a specific version of gradle.
The Gradle Wrapper consists of a few files in your project directory:
gradlew: The shell script Unix users can run to execute Gradle tasks
gradlew.bat The bat script Windows users can run to execute Gradle tasks
gradle/wrapper/gradle-wrapper.jar The wrapper’s executable JAR; this is where the wrapper code resides
gradle/wrapper/gradle-wrapper.properties A properties file for configuring the wrapper
Using the wrapper guarantees that every developer on your team in a specified project is using the same version of Gradle and that they can run Gradle builds.
You should make sure all these are committed to version control
You can easily change the version of gradle used in the project just changing the gradle/wrapper/gradle-wrapper.properties file with the distributionUrl properties. For example:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip
You can find more info about the wrapper here.
Using ./gradle you need to download and install manually the gradle version before.
It means that every developer in a team can use different version on the same project.
I download elasticsearch source code from :https://github.com/elastic/elasticsearch,
I found there is a build.gradlefile,and I have install gradle,
how to build source it?
There is a description fo the way you can build it in the readme file in the repo. According to it:
Building from Source
Elasticsearch uses Gradle for its build system. You’ll need to have
version 2.13 of Gradle installed.
In order to create a distribution, simply run the gradle assemble
command in the cloned directory.
The distribution for each project will be created under the
build/distributions directory in that project.
See the TESTING file for more information about running the
Elasticsearch test suite.
So all you need is to get into the root directory and in command line call gradle assemble, if you have Gradle installed properly, you will find all artifacts under build/distributions directory
gradle assemble seems to yield some errors such as cannot find symbol in my macOS environment.
According to the latest description in the repo (as of time writing the answer):
To build a distribution for your local OS and print its output location upon completion, run:
./gradlew localDistro
To build a distribution for another platform, run the related command:
./gradlew :distribution:archives:linux-tar:assemble
./gradlew :distribution:archives:darwin-tar:assemble
./gradlew :distribution:archives:windows-zip:assemble
To build distributions for all supported platforms, run:
./gradlew assemble
Distributions are output to distributions/archives.
How can I configure my Gradle script to automatically download PhantomJS for my tests to use, so that I don't have to manually install it somewhere on my build server?
I see a phantomjs-maven-plugin that seems to do exactly what I want, but I don't know how to use it in Gradle.
What is the difference between using gradlew and gradle or are they the same?
The difference lies in the fact that ./gradlew indicates you are using a gradle wrapper. The wrapper is generally part of a project and it facilitates installation of gradle. If you were using gradle without the wrapper you would have to manually install it - for example, on a mac brew install gradle and then invoke gradle using the gradle command. In both cases you are using gradle, but the former is more convenient and ensures version consistency across different machines.
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.
Not only does this mean that you don’t have to manually install Gradle
yourself, but you are also sure to use the version of Gradle that the
build is designed for. This makes your historical builds more reliable
Read more here - https://docs.gradle.org/current/userguide/gradle_wrapper.html
Also, Udacity has a neat, high level video explaining the concept of the gradle wrapper - https://www.youtube.com/watch?v=1aA949H-shk
gradle vs gradlew
gradlew is a wrapper(w - character) that uses gradle.
Under the hood gradlew performs three main things:
Download and install the correct gradle version
Parse the arguments
Call a gradle task
Using Gradle Wrapper we can distribute/share a project to everybody to use the same version and Gradle's functionality(compile, build, install...) even if it has not been installed.
To create a wrapper run:
gradle wrapper
This command generate:
gradle-wrapper.properties will contain the information about the Gradle distribution
*./ Is used on Unix to specify the current directory