`-?, -h, --help` Shows this help message.
`-a, --no-rebuild` Do not rebuild project dependencies.
`-b, --build-file` Specifies the build file.
`-C, --cache` Specifies how compiled build scripts should be cached. Possible values are: 'rebuild' and 'on'. Default value is 'on' [deprecated - Use '--rerun-tasks' or '--recompile-scripts' instead]
`-c, --settings-file` Specifies the settings file.
`--continue` Continues task execution after a task failure.
`-D, --system-prop` Set system property of the JVM (e.g. -Dmyprop=myvalue).
`-d, --debug` Log in debug mode (includes normal stacktrace).
`--daemon` Uses the Gradle daemon to run the build. Starts the daemon if not running.
`--foreground` Starts the Gradle daemon in the foreground. [incubating]
`-g, --gradle-user-home` Specifies the gradle user home directory.
`--gui` Launches the Gradle GUI.
`-I, --init-script` Specifies an initialization script.
`-i, --info` Set log level to info.
`-m, --dry-run` Runs the builds with all task actions disabled.
`--no-color` Do not use color in the console output.
`--no-daemon` Do not use the Gradle daemon to run the build.
`--no-opt` Ignore any task optimization. [deprecated - Use '--rerun-tasks' instead]
`--offline` The build should operate without accessing network resources.
`-P, --project-prop` Set project property for the build script (e.g. -Pmyprop=myvalue).
`-p, --project-dir` Specifies the start directory for Gradle. Defaults to current directory.
`--parallel` Build projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use. [incubating]
`--parallel-threads` Build projects in parallel, using the specified number of executor threads. [incubating]
`--profile` Profiles build execution time and generates a report in the <build_dir>/reports/profile directory.
`--project-cache-dir` Specifies the project-specific cache directory. Defaults to .gradle in the root project directory.
`-q, --quiet` Log errors only.
`--recompile-scripts` Force build script recompiling.
`--refresh` Refresh the state of resources of the type(s) specified. Currently only 'dependencies' is supported. [deprecated - Use '--refresh-dependencies' instead.]
`--refresh-dependencies` Refresh the state of dependencies.
`--rerun-tasks` Ignore previously cached task results.
`-S, --full-stacktrace` Print out the full (very verbose) stacktrace for all exceptions.
`-s, --stacktrace` Print out the stacktrace for all exceptions.
`--stop` Stops the Gradle daemon if it is running.
`-u, --no-search-upward` Don't search in parent folders for a settings.gradle file.
`-v, --version` Print version info.
`-x, --exclude-task` Specify a task to be excluded from execution.
gradle help --task init
Task :help
Detailed task information for init
Path
:init
Type
InitBuild (org.gradle.buildinit.tasks.InitBuild)
Options
--type Set type of build to create.
Available values are:
basic
groovy-application
groovy-library
java-application
java-library
pom
scala-library
--test-framework Set alternative test framework to be used.
Available values are:
spock
testng
Description
Initializes a new Gradle build.
Group
Build Setup
BUILD SUCCESSFUL in 2s
repositories {
maven { url "http://wjwtest:8081/nexus/content/groups/public" }
maven { url "http://repo.springsource.org/plugins-release" }
}
Java Lib
项目框架
执行: gradle init --type java-library
会生成如下目录结构/ProhectPath:
│ build.gradle
│ gradlew
│ gradlew.bat
│ settings.gradle
│
├─.gradle
│ ├─4.2.1
│ │ ├─fileChanges
│ │ │ last-build.bin
│ │ │
│ │ ├─fileHashes
│ │ │ fileHashes.bin
│ │ │ fileHashes.lock
│ │ │
│ │ └─taskHistory
│ │ fileSnapshots.bin
│ │ taskHistory.bin
│ │ taskHistory.lock
│ │
│ └─buildOutputCleanup
│ buildOutputCleanup.lock
│ cache.properties
│ outputFiles.bin
│
├─gradle
│ └─wrapper
│ gradle-wrapper.jar
│ gradle-wrapper.properties
│
└─src
├─main
│ └─java
│ Library.java
│
└─test
└─java
LibraryTest.java
Java APP
项目框架
执行: gradle init --type java-library
会生成如下目录结构/ProhectPath:
│ build.gradle
│ gradlew
│ gradlew.bat
│ settings.gradle
│
├─.gradle
│ ├─4.2.1
│ │ ├─fileChanges
│ │ │ last-build.bin
│ │ │
│ │ ├─fileHashes
│ │ │ fileHashes.bin
│ │ │ fileHashes.lock
│ │ │
│ │ └─taskHistory
│ │ fileSnapshots.bin
│ │ taskHistory.bin
│ │ taskHistory.lock
│ │
│ └─buildOutputCleanup
│ buildOutputCleanup.lock
│ cache.properties
│ outputFiles.bin
│
├─gradle
│ └─wrapper
│ gradle-wrapper.jar
│ gradle-wrapper.properties
│
└─src
├─main
│ └─java
│ App.java
│
└─test
└─java
AppTest.java
gradle init --type pom
你的maven项目已经秒变gradle项目build.gradle
文件下定义repositories {
mavenLocal()
}
Gradle使用与Maven相同的策略去定位本地Maven缓存的位置。如果在settings.xml中定义了本地Maven仓库的地址,则使用该地址。 在USER_HOME/.m2下的settings.xml文件中的配置会覆盖存放在M2_HOME/conf下的settings.xml文件中的配置。 如果没有settings.xml配置文件,Gradle会使用默认的USER_HOME/.m2/repository地址。