gradle
Author : Janloong Do_O
jar配置
jar {
//清单文件配置
manifest {
attributes 'Manifest-Version': '1.0'
attributes 'Implementation-Title': '这是程序主程序'
// attributes 'JavaFX-Preloader-Class': 'com.janloong.fxpreloader.MainPreloader'
attributes 'Implementation-Version': ''
attributes 'Permissions': 'sandbox'
attributes 'JavaFX-Version': '8.0'
attributes 'Class-Path': 'lib/core-8.0.1.jar '+'lib/datafx-8.0.1.jar '+'lib/flow-8.0.1.jar ' +
''+'lib/fontawesomefx-commons-8.15.jar '+'lib/fontawesomefx-commons-8.15.jar '
// attributes 'Class-Path': 'FXpreloader.jar'
attributes 'Created-By': 'JavaFX Packager'
attributes 'Implementation-Vendor': ''
attributes 'Main-Class': 'com.janloong.fxworld.MainApp'
}
<!-- 把所有运行时的jar都打入jar中-->
into('lib') {
from configurations.runtime
}
}
项目目录结构
sourceSets {
//设置源代码所在目录
main {
java {
srcDirs = ['src']
}
}
//设置测试代码所在目录
test {
java {
srcDirs = ['test']
}
}
}
buildDir = ‘out’
增量构建机制
task combineFileContentIncremental {
def sources = fileTree('sourceDir')
def destination = file('destination.txt')
inputs.dir sources
outputs.file destination
doLast {
destination.withPrintWriter { writer ->
sources.each {source ->
writer.println source.text
}
}
}
}
默认property
Gradle在默认情况下已经为Project定义了很多Property,其中比较常用的有:
project:Project本身
name:Project的名字
path:Project的绝对路径
description:Project的描述信息 (project.description) 若在task里面则是task本身的描述信息
buildDir:Project构建结果存放目录
version:Project的版本号
jar
dependencies {
compile files('spring-core.jar', 'spring-aap.jar')
compile fileTree(dir: 'deps', include: '*.jar')
}