gpt4 book ai didi

java - Gradle : Failed to notify build listener

转载 作者:行者123 更新时间:2023-12-03 05:23:13 24 4
gpt4 key购买 nike

当我们使用 gradle 构建我们的应用程序时,它会抛出下面的异常。以下是 build.gradle 代码:

buildscript {
repositories{
jcenter()
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.8.1"
classpath "io.spring.gradle:dependency-management-plugin:1.0.9.RELEASE"
}
}

apply plugin: "idea"
apply plugin: "java-library"
apply plugin: "maven-publish"
apply plugin: "com.jfrog.artifactory"
apply plugin: "io.spring.dependency-management"

group = "com.xx.ff"
version = "2.1.5-SNAPSHOT"

wrapper {
gradleVersion = "6.5"
distributionType = Wrapper.DistributionType.ALL
}

repositories {
jcenter()
if (System.getenv('ARTIFACTORY_USER') == null || System.getenv('ARTIFACTORY_PASSWORD') == null) {
logger.warn("Please set environment variables ARTIFACTORY_USER and ARTIFACTORY_PASSWORD")
}
maven {
name "libs-snapshot"
url "https://vvvvvvvvvvvvvvvv/artifactory/libs-snapshot/"
credentials {
username = System.getenv('ARTIFACTORY_USER')
password = System.getenv('ARTIFACTORY_PASSWORD')
}
}
maven {
name "libs-release"
url "https://vvvvvvvvvvvvvvvvvvvvvvvvvv/artifactory/libs-release/"
credentials {
username = System.getenv('ARTIFACTORY_USER')
password = System.getenv('ARTIFACTORY_PASSWORD')
}
}
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

idea.module {
outputDir file("build/classes/java/main")
testOutputDir file("build/classes/java/test")
}

dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
}
}

dependencies {
api("org.springframework.boot:spring-boot-starter-security:${springBootVersion}")
api("org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:${springBootVersion}")
implementation("javax.validation:validation-api:${validationVersion}")
}

artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = "libs-snapshot-local"
username = System.getenv('ARTIFACTORY_USER')
password = System.getenv('ARTIFACTORY_PASSWORD')
maven = true

}
defaults {
publications("mavenJava")
}
}
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
我收到以下错误:
构建文件,行:81
未能通知构建监听器。

'org.gradle.api.file.FileCollection org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal.getPublishableFiles()'


谁能帮帮我?

最佳答案

对于偶然发现此错误的 future 读者。
我一直在拼凑一个工作 jfrog 从这里发布:
Gradle Artifactory Plugin - How to publish artifacts from multiple modules in a project?
我得到了错误,然后意识到我没有使用android。
当我遇到这个错误时,我得到了这个错误:

publishing {
publications {
Android(MavenPublication) {
groupId "${projectGroupName}"
artifactId 'MyFirstArtifactId'
version "${projectVersionName}"
artifact "$buildDir/blah/blah/mything-1.0-SNAPSHOT.jar"
}
}
}
并将“Android”更改为“mavenJava”,如下所示。
publishing {
publications {
mavenJava(MavenPublication) {
groupId "${projectGroupName}"
artifactId 'MyFirstArtifactId'
version "${projectVersionName}"
artifact "$buildDir/blah/blah/mything-1.0-SNAPSHOT.jar"
}
}
}
我唯一的另一个提示是我有这个。请记住,我有一个多模块 gradle 项目,我不想人工发布根模块。
subprojects {
apply plugin: 'java-library'
apply plugin: "maven-publish"
}
所以我的总体想法是:您是否缺少应用插件?
文档:
https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven:complete_example
=========
另一个提示项目:
https://github.com/foragerr/SO-35851251-Multiproject-Artifactory-Publish
=========
我发布的另一个更长的答案:
How do I generate maven-metata.xml with maven-publish and the artifactory-gradle-plugin?
=========
只是对新手的提醒。
https://docs.gradle.org/current/dsl/org.gradle.api.publish.maven.MavenPublication.html
下面是来自上面 url 的示例代码:
publishing {
publications {
myPublicationName(MavenPublication) {
// Configure the publication here
}
}
}
这就是为什么对“myPublicationName”使用“关键字”会使其难以辨别的原因之一。
=========
https://gradle.github.io/gradle-script-kotlin-docs/userguide/publishing_maven.html
发布{
出版物{
mavenJava(MavenPublication) {
从(组件.java)
}
}
}
我仍在试图弄清楚 mavenJava 是否只是另一个名称(例如“myPublishingName”而“from”是更重要的部分。或者它是一个特殊的名称/保留关键字。

关于java - Gradle : Failed to notify build listener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62715288/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com