Brief introduction
Gradle is a project automation build tool based on Apache Ant and Apache maven that declares build settings using a particular domain-specific language (Domain-specific language DSL) based on groovy. Support multi-language project building, including Android, C + +, Groovy, Java, Javascript, Kotlin, Scala.
Official website https://gradle.org/. Https://gradle.org/releases/.
Installation
As with Maven, unzip and drop to/opt/gradle
Run
To build the Java project structure:
mkdir java-democd java-demo//opt/gradle/latest/bin/gradle init--type java-applicationtree# Generated directory structure ├──build.gradle├──gradle│└──wrapper│ ├──gradle-wrapper.jar│ └──gradle-Wrapper . properties├──gradlew├──gradlew.bat├──settings.gradle└──src ├──main │└──java │ └──app.java
└──test └──java └──apptest.java
Build
Direct execution
java-demo$./Gradlew builddownloading https://services.gradle.org/distributions/ Gradle-4.9-bin.zip... ^c-------
This download will be slow because gradle-4.9-bin.zip has actually been downloaded, but it cannot be placed directly into the. Gradle directory because there is a hash string in the directory path
~/.gradle$ find ./-name gradle-*. zip /wrapper/dists/gradle-4.4 -all/9br9xq1tocpiv8o6njlyu5op1/gradle-4.4 -all. zip /wrapper/dists/gradle-4.6 -bin/4jp4stjndanmxuerzfseyb6wo/gradle-4.6 -bin. zip /wrapper/dists/gradle-4.9 -bin/dv6yjbd5p4c085k06brhv9r3f/gradle-4.9 -bin. zip /wrapper/dists/gradle-4.1 -all/bzyivzo6n839fup2jbap0tjew/gradle-4.1 -all. zip
You can put the file in the project's Gradle/wrapper directory, and modify the Gradle-wrapper.properties, modify the following line
# distributionurl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip distributionurl=gradle-4.9-bin. Zip
It will then be downloaded directly from the local
java-demo$./Gradlew builddownloadingfile:/home/milton/ideaprojects/untitled3/java-demo/gradle/wrapper/gradle-4.9-bin.Zip........................................................................ Download https://Jcenter.bintray.com/com/google/guava/guava/23.0/guava-23.0.pomDownload https://Jcenter.bintray.com/com/google/guava/guava-parent/23.0/guava-parent-23.0.pomDownload https://Jcenter.bintray.com/com/google/guava/guava/23.0/guava-23.0.jarBUILD Successfulinch39s7Actionable tasks:7Executed
Update: After this process, if you change the gradle-wrapper.properties back again, the operation will be downloaded again, you can use another method:
# View the hash directory under directory~/.gradle/wrapper/dists/gradle-4.9-bin~/.gradle/wrapper/dists/gradle-4.9-bin$ lltotal Adrwxr-xr-x2Milton Milton4096Jul + xx:Genevacuv0xpj2z1lkier1i57jl72tr/drwxr-xr-x3Milton Milton4096Jul - at: +dv6yjbd5p4c085k06brhv9r3f/drwxr-xr-x2Milton Milton4096Jul + xx:Genevae9cinqnqvph59rr7g70qubb4t/# sub-directories can see incomplete downloads~/.gradle/wrapper/dists/gradle-4.9-bin$ ll cuv0xpj2z1lkier1i57jl72tr/ Total0-rw-r--r--1Milton Milton0Jul - at: thegradle-4.9-bin.Zip. Lck-rw-r--r--1Milton Milton0Jul - at: thegradle-4.9-bin.Zip. part# remove the. part file, and the complete ZIP file CP comes in ... # after running and then looking at the directory, it becomes such a structure~/.gradle/wrapper/dists/gradle-4.9-bin$ ll cuv0xpj2z11kier1i57j172tr/ Total74552drwxr-xr-x6Milton Milton4096Jul + xx:Genevagradle-4.9/-rw-r--r--1Milton Milton76334709Jul + xx:Genevagradle-4.9-bin.Zip-rw-r--r--1Milton Milton0Jul - at: .gradle-4.9-bin.Zip. Lck-rw-r--r--1Milton Milton0Jul + xx:Genevagradle-4.9-bin.Zip. OK
Gradle library files are stored in the. GRADLE/CACHES/MODULES-2/FILES-2.1/Directory
Other commands that you can also run
# See how those are built. /Gradlew tasks# Run, Runs this project as a JVM application. /- Runs the unit tests. /gradlew Test
Load a separate JAR package
Add the Libs directory under the project and continue the jar package into the Libs directory
The Build.gradle configuration is as follows:
dependencies {Compile files (' Lib/ojdbc-14.jar ')}
Load the jar package for the entire directory
Create a folder in your own Gradle project named Libs (which you can define yourself, not necessarily the name), and copy your local jar package to this folder.
The Build.gradle configuration is as follows:
dependencies {Compile filetree (dir: ' Libs ', include:[' *.jar '])}
.
.
Ubuntu18.04 running Gradle 4.9