gpt4 book ai didi

java - 任务 ':signMavenJavaPublication' 执行失败。 > java.lang.NullPointerException(无错误消息)

转载 作者:太空宇宙 更新时间:2023-11-04 10:05:32 26 4
gpt4 key购买 nike

我正在尝试使用 Gradle 签名插件对我的 Java Artifact 进行签名。在修复“未配置签名者”错误后遇到了很多困难,我遇到了另一个问题。任务 signMavenJavaPublication 失败并出现 NullPointerException,我不确定原因。我已删除项目文件夹内的 .gradle 文件夹、清理并重复重建项目,但没有成功。

这是 build.gradle 文件:

buildscript {
repositories {
jcenter()
maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1'
}
}

plugins {
id 'java'
id 'signing'
}

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'maven-publish'
apply plugin: 'signing'

group = 'com.example'
version = '1.1.0'

description = "example"

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
maven { url "http://repo.maven.apache.org/maven2" }
}

dependencies {
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version:'2.9.6'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version:'2.9.6'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version:'2.9.6'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version:'4.5.5'
compile group: 'org.apache.httpcomponents', name: 'httpcore', version:'4.4.9'
compile group: 'commons-io', name: 'commons-io', version:'2.6'
compile group: 'org.apache.tika', name: 'tika-core', version:'1.18'
testCompile group: 'junit', name: 'junit', version:'4.12'
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc
}

publishing {
artifacts {
archives sourcesJar
archives javadocJar
}

publications
{
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
}
}
repositories {
maven {
url "${project.version.endsWith('-SNAPSHOT') ? 'https://oss.sonatype.org/content/repositories/snapshots' : 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' }"
credentials {
username sonatypeUsername
password sonatypePassword
}
}
}
}

signing
{
sign publishing.publications.mavenJava
}

这是堆栈跟踪:

> Task :signMavenJavaPublication FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':signMavenJavaPublication'.
> java.lang.NullPointerException (no error message)

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':signMavenJavaPublication'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:277)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:262)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.NullPointerException
at org.bouncycastle.openpgp.operator.bc.BcPGPKeyConverter.getPrivateKey(Unknown Source)
at org.bouncycastle.openpgp.operator.bc.BcPGPContentSignerBuilder.build(Unknown Source)
at org.bouncycastle.openpgp.PGPSignatureGenerator.init(Unknown Source)
at org.gradle.plugins.signing.signatory.pgp.PgpSignatory.createSignatureGenerator(PgpSignatory.java:108)
at org.gradle.plugins.signing.signatory.pgp.PgpSignatory.sign(PgpSignatory.java:70)
at org.gradle.plugins.signing.type.AbstractSignatureType.sign(AbstractSignatureType.java:65)
at org.gradle.plugins.signing.type.pgp.ArmoredSignatureType.sign(ArmoredSignatureType.java:41)
at org.gradle.plugins.signing.type.AbstractSignatureType$1$1.execute(AbstractSignatureType.java:49)
at org.gradle.plugins.signing.type.AbstractSignatureType$1$1.execute(AbstractSignatureType.java:46)
at org.gradle.internal.IoActions.withResource(IoActions.java:77)
at org.gradle.plugins.signing.type.AbstractSignatureType$1.execute(AbstractSignatureType.java:46)
at org.gradle.plugins.signing.type.AbstractSignatureType$1.execute(AbstractSignatureType.java:42)
at org.gradle.internal.IoActions.withResource(IoActions.java:77)
at org.gradle.plugins.signing.type.AbstractSignatureType.sign(AbstractSignatureType.java:42)
at org.gradle.plugins.signing.Signature.generate(Signature.java:422)
at org.gradle.plugins.signing.Sign.generate(Sign.java:324)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:801)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:768)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99)

最佳答案

你看到了吗:

Caused by: java.lang.NullPointerException
at org.bouncycastle.openpgp.operator.bc.BcPGPKeyConverter.getPrivateKey

getPrivateKey() converts a private key from one type to another 。如果没有 PrivKey,则 NPE 是可以理解的。

您是否按照 The Signing Plugin 中的描述定义它? ?参见那里:

Note that the presence of a null value for any these three properties will cause an exception.

关于java - 任务 ':signMavenJavaPublication' 执行失败。 > java.lang.NullPointerException(无错误消息),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52977923/

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