Gradle多项目配置的一个demo
ParentProject
├─build.gradle
├─settings.gradle
├─libs
├─subProject1
├────────────build.gradle
├────────────src/java
├────────────conf
├─subProject2
├────────────build.gradle
├────────────src/java
├────────────conf
├─subProject3
├────────────build.gradle
├────────────src/java
├────────────conf
ParentProject
目录下的build.gradle
//所有项目公用资源:IDE和库
allprojects {
repositories {
mavenLocal()
}
} //所有子项目公用:源码和单元测试代码定义
subprojects {
println "======================================"
println "${rootProject.projectDir}/libs"
println "======================================"
apply plugin: 'java'
sourceSets {
main {
java {
srcDir 'src/java'
}
}
test {
java {
srcDir 'src/test'
}
}
} dependencies {
compile fileTree(dir: "${rootProject.projectDir}/liblicense",include: '**/*.jar')
}
}
目录下的settings.gradle
include 'subProject1'
include 'subProject2'
include 'subProject3'
//或include 'subProject1','subProject2','subProject3'
subProject1下的build.gradle
project(':subProject1') {
dependencies {
}
}
subProject2下的build.gradle
project(':subProject2') {
dependencies {
compile project(':subProject1')
}
}
subProject3下的build.gradle
project(':subProject3') {
dependencies {
compile project(':subProject1')
}
}
graadle中的一个copy操作:
目录结构:
│ build.gradle
│ gradlew
│ gradlew.bat
│ list.txt
│ settings.gradle
│
├─.gradle
│ └─2.8
│ └─taskArtifacts
│ cache.properties
│ cache.properties.lock
│ fileHashes.bin
│ fileSnapshots.bin
│ outputFileStates.bin
│ taskArtifacts.bin
│
├─build
│ ├─libs
│ │ gradle.jar
│ │
│ └─tmp
│ └─jar
│ MANIFEST.MF
│
└─graldeCopyConfig
├─build
│ ├─classes
│ │ ├─main
│ │ │ EqualDemo.class
│ │ │
│ │ └─test
│ │ │ EqualDemoTest.class
│ │ │
│ │ └─config
│ │ test.xml
│ │
│ ├─dependency-cache
│ ├─libs
│ │ graldeCopyConfig.jar
│ │
│ ├─reports
│ │ └─tests
│ │ │ index.html
│ │ │
│ │ ├─classes
│ │ │ EqualDemoTest.html
│ │ │
│ │ ├─css
│ │ │ base-style.css
│ │ │ style.css
│ │ │
│ │ ├─js
│ │ │ report.js
│ │ │
│ │ └─packages
│ │ default-package.html
│ │
│ ├─test-results
│ │ │ TEST-EqualDemoTest.xml
│ │ │
│ │ └─binary
│ │ └─test
│ │ output.bin
│ │ output.bin.idx
│ │ results.bin
│ │
│ └─tmp
│ ├─compileJava
│ │ └─emptySourcePathRef
│ ├─compileTestJava
│ │ └─emptySourcePathRef
│ └─jar
│ MANIFEST.MF
│
└─src
├─main
│ ├─java
│ │ EqualDemo.java
│ │
│ └─resources
└─test
├─java
│ │ EqualDemoTest.java
│ │
│ └─config
│ test.xml
│
└─sources
build.gradle
/*
* This build file was auto generated by running the Gradle 'init' task
* by 'MyWorld' at '16-2-22 下午11:33' with Gradle 2.8
*
* This generated file contains a commented-out sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* user guide available at https://docs.gradle.org/2.8/userguide/tutorial_java_projects.html
*/
subprojects {
// Apply the java plugin to add support for Java
apply plugin: 'java'
sourceCompatibility = 1.6
targetCompatibility = 1.6 tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
} sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
}
test {
java {
srcDirs = ['src/test/java']
}
}
} // In this section you declare where to find the dependencies of your project
repositories {
// Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
} dependencies {
// The production code uses the SLF4J logging API at compile time
compile 'org.slf4j:slf4j-api:1.7.12' // Declare the dependency for your favourite test framework you want to use in your tests.
// TestNG is also supported by the Gradle Test task. Just change the
// testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add
// 'test.useTestNG()' to your build script.
testCompile 'junit:junit:4.12'
} task copyConfig(type: Copy) {
from 'src/test/java'
into 'build/classes/test'
include '**/*.xml'
println fileTree('src/test/java').files
println fileTree('build/classes/test').files
}
test.dependsOn copyConfig
} project(':graldeCopyConfig') {
// In this section you declare the dependencies for your production and test code
dependencies {
}
}
settings.gradle
/*
* This settings file was auto generated by the Gradle buildInit task
* by 'MyWorld' at '16-2-22 下午11:33' with Gradle 2.8
*
* The settings file is used to specify which projects to include in your build.
* In a single project build this file can be empty or even removed.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user guide at https://docs.gradle.org/2.8/userguide/multi_project_builds.html
*/
include 'graldeCopyConfig'
gradle build的执行结果
[G:\java\gradle\graldeCopyConfig\src\test\java\EqualDemoTest.java, G:\java\gradle\graldeCopyConfig\src\test\java\config\test.xml]
[G:\java\gradle\graldeCopyConfig\build\classes\test\EqualDemoTest.class, G:\java\gradle\graldeCopyConfig\build\classes\test\config\test.xml]
:graldeCopyConfig:compileJava UP-TO-DATE
:graldeCopyConfig:processResources UP-TO-DATE
:graldeCopyConfig:classes UP-TO-DATE
:graldeCopyConfig:jar UP-TO-DATE
:graldeCopyConfig:assemble UP-TO-DATE
:graldeCopyConfig:copyConfig UP-TO-DATE
:graldeCopyConfig:compileTestJava UP-TO-DATE
:graldeCopyConfig:processTestResources UP-TO-DATE
:graldeCopyConfig:testClasses UP-TO-DATE
:graldeCopyConfig:test UP-TO-DATE
:graldeCopyConfig:check UP-TO-DATE
:graldeCopyConfig:build UP-TO-DATE BUILD SUCCESSFUL Total time: 5.196 secs
8.3. Dependency configurations
In Gradle dependencies are grouped into configurations. A configuration is simply a named set of dependencies. We will refer to them as dependency configurations. You can use them to declare the external dependencies of your project. As we will see later, they are also used to declare the publications of your project.
The Java plugin defines a number of standard configurations. These configurations represent the classpaths that the Java plugin uses. Some are listed below, and you can find more details inTable 23.5, “Java plugin - dependency configurations”.
- compile
-
The dependencies required to compile the production source of the project.
- runtime
-
The dependencies required by the production classes at runtime. By default, also includes the compile time dependencies.
- testCompile
-
The dependencies required to compile the test source of the project. By default, also includes the compiled production classes and the compile time dependencies.
- testRuntime
-
The dependencies required to run the tests. By default, also includes the compile, runtime and test compile dependencies.
Various plugins add further standard configurations. You can also define your own custom configurations to use in your build. Please see Section 52.3, “Dependency configurations” for the details of defining and customizing dependency configurations.
Gradle多项目配置的一个demo的更多相关文章
- Android Gradle Plugin指南(三)——依赖关系、android库和多项目配置
原文地址:http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Dependencies-Android-Librari ...
- Log4net - 项目使用的一个简单Demo
参考页面: http://www.yuanjiaocheng.net/entity/entitytypes.html http://www.yuanjiaocheng.net/entity/entit ...
- vsCode怎么为一个前端项目配置ts的运行环境
vsCode为一个前端项目配置ts的运行环境,ts文件保存的时候自动编译成js文件: 假设此前端项目名称为Web:文件结构如图 1. 在根目录中新建一个“.vscode”文件夹,里面建一个“tasks ...
- 下载,配置环境变量,第一个demo
一.在 http://www.oracle.com 下载java JDK 安装到自定义的地方. 二.配置环境变量:在我的电脑→高级系统设置→环境变量 ① 找到Path新增一个路径(该路径为JDK存放的 ...
- Spring boot - 梳理 - 根本上说,Spring Boot项目只不过是一个普通的Spring项目,只是使用了Spring Boot的起步依赖和自动配置
根本上说,Spring Boot项目只不过是一个普通的Spring项目,只是使用了Spring Boot的起步依赖和自动配置
- 如何在Android Studio中使用Gradle发布项目至Jcenter仓库
简述 目前非常流行将开源库上传至Jcenter仓库中,使用起来非常方便且易于维护,特别是在Android Studio环境中,只需几步配置就可以轻松实现上传和发布. Library的转换和引用 博主的 ...
- 模块化之Spring3.0 web fragment和gradle构建项目
1.背景 模块化开发很久以前就开始普及的概念.但是到了企业实际情况中,真正把模块化作为系统架构的核心的不多.或者说对模块化有这个意识,但是具体到底该如何实现,有些模糊,同时也许因为项目紧.任务中. ...
- 初识nginx之第一个demo
商城项目做了一个多月了,想到必须用到负载均衡,简单了解了一下nginx,首先分享第一个demo,五月份上线后,会继续分享一系列相关知识. 在nginx根目录下,用了一个园友的批处理文件nginx.ba ...
- Android studio下gradle Robolectric单元测试配置
android studio下gradle Robolectric单元测试配置 1.Robolectric Robolectric是一个基于junit之上的单元测试框架.它并不依赖于Android提供 ...
随机推荐
- 怎样在C++中获得完整的类型名称
Wrote by mutouyun. (http://darkc.at/cxx-get-the-name-of-the-given-type/) 地球人都知道C++里有一个typeid操作符能够用来获 ...
- Java命令参数说明
Java在运行已编译完成的类时,是通过java虚拟机来装载和执行的,java虚拟机通过操作系统命令 JAVA_HOME"bin"java –option 来启动,-option为虚 ...
- Swing界面刷新问题(转)
在Java Swing编程中,往往会遇到需要动态刷新界面的时候,例如动态刷新JLabel的文本,JTextField里的文本等等.但是往往却没有达到我们预期的效果,我相信很多朋友都遇到过本文将要说的这 ...
- Java4Android之BlockingQueue
在研究Smack的源码的时候,我对它的连接Connection以及派生类XMPPConnection的关注是最多的,由于一个即时通信程序,它的网络模块必是它的核心. 而我非常在乎它是怎样实现的. 在收 ...
- 掌握Java字节码(转)
Java是一门设计为运行于虚拟机之上的编程语言,因此它需要一次编译,处处运行(当然也是一次编写,处处测试).因此,安装到你系统上的JVM是原生的程序,而运行在它之上的代码是平台无关的.Java字节码就 ...
- 足球和oracle列(4):巴西惨败于德国,认为,差额RAC拓扑控制!
足球与oracle系列(4):从巴西慘败于德国,想到,差异的RAC拓扑对照! 前期回想: 本来想说今晚,回头一想,应该是今早第二场半决赛就要开战了!先来回味一下之前的比赛,本届8支小组赛第一名已经所有 ...
- python基础课程_学习笔记15:标准库:有些收藏夹——fileinput
标准库:有些收藏夹 fileinput 重要功能 性能 叙述性说明 input([files[,inplace[,backup]]) 便于遍历多个输入流中的行 filename() 返回当前文件的名称 ...
- UVA11100- The Trip, 2007
option=com_onlinejudge&Itemid=8&category=512&page=show_problem&problem=2041"> ...
- Windows 8 应用开发 - 本地数据存储
原文:Windows 8 应用开发 - 本地数据存储 在应用中通常会遇到用户主动或被动存储信息的情况,当应用关闭后这些数据仍然会存储在本地设备上,用户下次重新激活应用时会自动加载这些数据.下 ...
- C# Windows Phone App 开发,修改【锁定画面】,从【Assets】、【UI】、【网路图片】,并解决失灵问题。
原文:C# Windows Phone App 开发,修改[锁定画面],从[Assets].[UI].[网路图片],并解决失灵问题. 一般我们在开发Windows Phone App,有时会希望透过应 ...