这是我的dummy
项目的build.gradle
文件:
apply plugin: 'groovy'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.3'
compile 'org.slf4j:jcl-over-slf4j:1.7.7'
testCompile 'junit:junit:4.11'
testCompile 'org.mockito:mockito-all:1.10.8'
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
当我运行gradle clean build -Pversion=1.2.3
时,它将打包我的所有代码并为我创建build/libs/dummy-1.2.3.jar
。
我想知道最少量的Gradle代码,以便我可以将"dummy" JARs发布到本地Maven缓存(mavenLocal()
)。此外,这与版本控制有何关系?我可以为虚拟JAR指定具体版本,但在本地发布时,使用SNAPSHOT
版本更为合理(至少对我来说)。我可以只运行gradle clean build -Pversion=0.1.SNAPSHOT
,但我的担忧是其他本地项目是否会获取最新的SNAPSHOT
版本。
所以:
- 发布
dummy
的最少代码是什么? - 在本地发布时,是否有任何方法指定其他项目始终获取最新的
SNAPSHOT
版本? - 其他本地项目需要使用什么来获取这个
SNAPSHOT
?例如compile ':dummy:LATEST'
?