二、build.gradle的一些详解
来源:互联网 发布:数据挖掘技术 客户微盘 编辑:程序博客网 时间:2024/05/17 05:04
查看build.gradle文件
apply plugin: 'java'apply plugin: 'eclipse'sourceCompatibility = 1.7version = '1.0'jar { manifest { attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version }}repositories { mavenCentral()}dependencies { compile group: 'commons-collections', name: 'commons-collections', version: '3.2' testCompile group: 'junit', name: 'junit', version: '4.+'}test { systemProperties 'property': 'value'}uploadArchives { repositories { flatDir { dirs 'repos' } }}
以下内容引入自网络及官方文档
apply plugin: ‘maven’: 使用maven做为jar包的信赖管理,通过mave仓库下载项目所需的信赖包
apply plugin: ‘war’:指定web项目,项目编译(在项目提示符下执行:gradle build)时生成项目的war包。
apply plugin: ‘java’: 指定项目为java项目,项目编译(在项目提示符下执行:gradle build)时生成项目的jar包。
apply plugin: ‘eclipse-wtp’:插件将构建web项目的开发环境,生成所需要的.project,.classpath等文件。因为我web开发使用的是eclipse-j2ee版本,所以指定为wtp环境。
apply plugin: ‘eclipse’:java项目的eclipse开发环境构建.生成所需要的.project,.classpath等文件。
apply plugin: ‘jetty’:加入jetty的支持,代码修改后直接执行命令gradle jettyRun即可运行web项目。
repositories: 指定仓库使用。
dependencies:项目依赖定义,compile为编译级别依赖,还有testCompile为测试级别的依赖等。
Build script structure
A build script is made up of zero or more statements and script blocks. Statements can include method calls,property assignments, and local variable definitions. A script block is a method call which takes a closureas a parameter. The closure is treated as a configuration closure which configuressome delegate object as it executes. The top level script blocks are listed below.
allprojects { }
Configures this project and each of its sub-projects.
artifacts { }
Configures the published artifacts for this project.
buildscript { }
Configures the build script classpath for this project.
configurations { }
Configures the dependency configurations for this project.
dependencies { }
Configures the dependencies for this project.
repositories { }
Configures the repositories for this project.
sourceSets { }
Configures the source sets of this project.
subprojects { }
Configures the sub-projects of this project.
publishing { }
Configures the PublishingExtension
added by the publishing plugin.
A build script is also a Groovy script, and so can contain those elements allowed in a Groovy script,such as method definitions and class definitions.
Task types
Listed below are the various task types which are available for use in your build script:
AntlrTask
Generates parsers from Antlr grammars.
BuildEnvironmentReportTask
Provides information about the build environment for the project that the task is associated with.
Checkstyle
Runs Checkstyle against some source files.
CodeNarc
Runs CodeNarc against some source files.
CompareGradleBuilds
Executes two Gradle builds (that can be the same build) with specified versions and compares the outcomes.Please see the “Comparing Builds” chapter of the Gradle User Guide for more information.
Copy
Copies files into a destination directory. This task can also rename and filter files as it copies. The taskimplements CopySpec
for specifying what to copy.
CreateStartScripts
Creates start scripts for launching JVM applications.
Delete
Deletes files or directories. Example:
Ear
Assembles an EAR archive.
Exec
Executes a command line process. Example:
FindBugs
Analyzes code with FindBugs. See the FindBugs Manual for additional information on configurationoptions.
GenerateIvyDescriptor
Generates an Ivy XML Module Descriptor file.
GenerateMavenPom
Generates a Maven module descriptor (POM) file.
GenerateBuildDashboard
Generates build dashboard report.
GradleBuild
Executes a Gradle build.
GroovyCompile
Compiles Groovy source files, and optionally, Java source files.
Groovydoc
Generates HTML API documentation for Groovy source, and optionally, Java source.
HtmlDependencyReportTask
Generates an HTML dependency report. This reportcombines the features of the ASCII dependency report and those of the ASCIIdependency insight report. For a given project, it generates a tree of the dependenciesof every configuration, and each dependency can be clicked to show the insight ofthis dependency.
JacocoReport
Task to generate HTML, Xml and CSV reports of Jacoco coverage data.
JacocoMerge
Task to merge multiple execution data files into one.
JacocoCoverageVerification
Task for verifying code coverage metrics. Fails the task if violations are detected based on specified rules.
Jar
Assembles a JAR archive.
JavaCompile
Compiles Java source files.
Javadoc
Generates HTML API documentation for Java classes.
JavaExec
Executes a Java application in a child process.
JDepend
Analyzes code with JDepend.
JettyRun
Deploys an exploded web application to an embedded Jetty web container. Does not require that the web applicationbe assembled into a war, saving time during the development cycle.
JettyRunWar
Deploys a WAR to an embedded Jetty web container.
JettyStop
Stops the embedded Jetty web container, if it is running.
Pmd
Runs a set of static code analysis rules on Java source code files and generates a report of problems found.
PublishToIvyRepository
Publishes an IvyPublication to an IvyArtifactRepository.
PublishToMavenRepository
Publishes a MavenPublication
to a MavenArtifactRepository
.
ScalaCompile
Compiles Scala source files, and optionally, Java source files.
ScalaDoc
Generates HTML API documentation for Scala source files.
InitBuild
Generates a Gradle project structure.
Sign
A task for creating digital signature files for one or more; tasks, files, publishable artifacts or configurations.
Sync
Synchronizes the contents of a destination directory with some source directories and files.
Tar
Assembles a TAR archive.
Test
Executes JUnit (3.8.x or 4.x) or TestNG tests. Test are always run in (one or more) separate JVMs.The sample below shows various configuration options.
TestReport
Generates an HTML test report from the results of one or more Test
tasks.
Upload
Uploads the artifacts of a Configuration
to a set of repositories.
War
Assembles a WAR archive.
Wrapper
Generates scripts (for *nix and windows) which allow you to build your project with Gradle, without having toinstall Gradle.
WriteProperties
Writes a Properties
in a way that the results can be expected to be reproducible.
Zip
Assembles a ZIP archive.The default is to compress the contents of the zip.
详细参考https://docs.gradle.org/3.5/dsl/
- 二、build.gradle的一些详解
- Build.gradle的妙用<二>
- android build.gradle的一些配置
- app目录下的build.gradle详解
- 详解build.gradle
- build.gradle详解
- 《详解build.gradle文件》
- build.gradle文件详解
- build.gradle文件详解
- build.gradle文件详解
- 【转载】详解build.gradle
- build.gradle文件详解
- 详解build.gradle文件
- build.gradle文件详解
- build.gradle 文件详解
- 详解build.gradle
- gradle 配置文件 build.gradle 属性详解
- Android Studio - 详解build.gradle
- libcurl post图片 base64编码
- java面试总结
- Leetcode Algorithm 416. Partition Equal Subset Sum
- Redis之——Spring基于注解整合Redis
- 【新收录】CSDN日报 —— Kotlin 专场
- 二、build.gradle的一些详解
- linux/unix命令详解之find
- 信息检索-搜索引擎的搭建(Lucene)
- linux socket阻塞recv
- linux/unix命令详解之sed
- Springframework.beans
- 在linux系统里修改tomcat内存的方法
- 如何在linux CentOS 上安装chrome 谷歌浏览器
- WPF 图像批量导出