我有一个多模块项目。而且,我希望能够做 gradle 发布并发布所有模块的所有工件。问题之一是当我包含插件时,我得到了
Task with name 'build' not found in root project '
所以,按照互联网上的一些建议,我创建了一个构建任务并在其上添加了一堆依赖项:
plugins {
id "net.researchgate.release" version "2.6.0"
}
defaultTasks 'clean', 'assemble'
def repoUrl = System.env.REPO ?: "https://company.jfrog.io/company/maven"
allprojects {
repositories {
mavenCentral()
jcenter()
maven {
url 'https://dl.bintray.com/palantir/releases'
}
maven {
credentials {
username System.env.REPO_USER
password System.env.REPO_PASS
}
url repoUrl
name 'company'
}
}
}
task build{}
subprojects { thisProject ->
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'checkstyle'
apply plugin: 'maven-publish'
apply plugin: 'findbugs'
build.dependsOn "${thisProject}:build"
publishing {
repositories {
maven {
credentials {
username System.env.REPO_USER
password System.env.REPO_PASS
}
url repoUrl
name 'company'
}
}
publications {
"-$thisProject.name-"(MavenPublication) {
from components.java
}
}
}
sourceCompatibility = 1.8 // java 8
targetCompatibility = 1.8
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
}
tasks.each {println(it)}
afterReleaseBuild.dependsOn tasks.publish
当我跑步时,gradle tasks --all
我得到
task ':afterReleaseBuild'
task ':beforeReleaseBuild'
task ':build'
task ':checkCommitNeeded'
task ':checkSnapshotDependencies'
task ':checkUpdateNeeded'
task ':commitNewVersion'
task ':confirmReleaseVersion'
task ':createReleaseTag'
task ':createScmAdapter'
task ':initScmAdapter'
task ':preTagCommit'
task ':release'
task ':runBuildTasks'
task ':unSnapshotVersion'
task ':updateVersion'
“释放”有效。也就是说,它会影响版本、标签、剥离“-SNAPSHOT”等。但是,这里缺少一个步骤(这可能完全是我的无知),但是在从版本中剥离“-SNAPSHOT”时,我需要它来构建工件并发布它们。这就像 Maven 发布过程,但没有工件上传。我目前正在使用 gradle 发布而不是 Maven 上传。
警告:对 gradle 来说很新,但对 java 不是很新,有人能告诉我我缺少什么吗?_