This worked in
$ ./gradlew -version
------------------------------------------------------------
Gradle 5.2.1
------------------------------------------------------------
Build time: 2019-02-08 19:00:10 UTC
Revision: f02764e074c32ee8851a4e1877dd1fea8ffb7183
Kotlin DSL: 1.1.3
Kotlin: 1.3.20
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 1.8.0_181 (Oracle Corporation 25.181-b13)
OS: Mac OS X 10.15.7 x86_64
...but not in...
$ ./gradlew -version
------------------------------------------------------------
Gradle 6.5
------------------------------------------------------------
Build time: 2020-06-02 20:46:21 UTC
Revision: a27f41e4ae5e8a41ab9b19f8dd6d86d7b384dad4
Kotlin: 1.3.72
Groovy: 2.5.11
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 1.8.0_181 (Oracle Corporation 25.181-b13)
OS: Mac OS X 10.15.7 x86_64
Directory strucure is
/some_path/build.gradle
/some_path/mySubProject
/some_path/mySubProject/build.gradle
This is my top-level build.gradle
file
import com.company.utilities.VersionPlugin
import org.gradle.api.credentials.AwsCredentials
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url 's3://' + s3_bucket
authentication {
awsIm(AwsImAuthentication)
}
}
}
dependencies {
classpath "com.company.utilities:version-plugin:3.3.+"
}
}
plugins {
id "com.company.microservice.root.java" version "2.0.24"
id "java"
}
allprojects {
apply plugin: 'jacoco'
apply plugin: VersionPlugin
}
// These are needed for awsIm(AwsImAuthentication)
dependencies {
testCompileClasspath 'com.amazonaws:aws-java-sdk-iam:1.11.78'
testCompileClasspath 'com.amazonaws:aws-java-sdk-ec2:1.11.78'
}
This is the sub-project's build.gradle
file
plugins {
id 'java'
id "com.company.microservice"
}
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
compileOnly {
extendsFrom annotationProcessor
}
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
all*.exclude group: 'com.vaadin.external.google', module: 'android-json'
}
microservice {
additionalSpringBootDependencies = ["data-jpa"]
clientProjectName = "my-client"
includeLombok = true
}
dependencies {
compile project(':my-client')
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.flywaydb:flyway-core'
implementation group: 'org.modelmapper', name: 'modelmapper', version: '2.3.6'
implementation "org.apache.commons:commons-lang3:3.5"
implementation "org.apache.commons:commons-collections4:4.0"
compile group: 'com.google.guava', name: 'guava', version: '23.0'
implementation group: 'org.togglz', name: 'togglz-core', version: '2.5.0.Final'
integrationTestCompileOnly 'org.projectlombok:lombok'
integrationTestAnnotationProcessor 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'mysql:mysql-connector-java'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'org.springframework.security:spring-security-test'
testImplementation ('com.github.javafaker:javafaker:0.12')
}
idea {
module {
testSourceDirs += sourceSets."integration-test".allSource.srcDirs
}
}
I'm able to build the sub project, and it produces a *.jar
file
$ ./gradlew clean build -x test -p mySubProject
$ ls mySubProject/build/libs
mySubProject-2.0.0.jar
But when I try to publish it, it says the artifact is not produced by the build?
$ ./gradlew publish -p mySubProject
* What went wrong:
Execution failed for task ':mySubProject:publishMySubProjectPublicationToMavenRepository'.
> Failed to publish publication 'mySubProject' to repository 'maven'
> Artifact mySubProject-2.0.0.jar wasn't produced by this build.
What am I missing?
question from:
https://stackoverflow.com/questions/65851968/gradle-v6-5-can-not-publish-artifact-it-built 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…