Gradle 部署到 Nexus 存储库时出错

Gradle error when deploying to Nexus Repository

今天,我一直在使用 Maven 将一些 Java 插件迁移到 gradle。插件确实成功构建,但是,我无法自动将它们部署到我们的关系。我想做的是通过成绩的发布功能将我的 Java jar 文件自动上传到 nexus。 [![Gradle 发布][1]][1] [1]: https://i.stack.imgur.com/eYj3k.png

以下是我通过 IntelliJ 尝试此操作时遇到的错误

Execution failed for task ':publishMavenPublicationToMavenRepository'.
> Failed to publish publication 'maven' to repository 'maven'
   > Could not write to resource 'http://nexus.grandtheftmc.net/content/repositories/releases/net/grandtheftmc/wastedguns/1.2.8/wastedguns-1.2.8.jar'.
      > Connection reset

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

以下是 gradle 调试模式开启时的相关错误片段:

    2021-07-13T18:06:40.978-0400 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection released: [id: 13][route: {}->http://nexus.grandtheftmc.net:80][total available: 0; route allocated: 0 of 20; total allocated: 0 of 20]
2021-07-13T18:06:40.978-0400 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Upload http://nexus.grandtheftmc.net/content/repositories/releases/net/grandtheftmc/wastedguns/1.2.8/wastedguns-1.2.8.jar' completed
2021-07-13T18:06:40.978-0400 [INFO] [org.gradle.api.internal.artifacts.repositories.transport.NetworkOperationBackOffAndRetry] Error in 'PUT http://nexus.grandtheftmc.net/content/repositories/releases/net/grandtheftmc/wastedguns/1.2.8/wastedguns-1.2.8.jar'. Waiting 2000ms before next retry, 1 retries left
2021-07-13T18:06:40.979-0400 [DEBUG] [org.gradle.api.internal.artifacts.repositories.transport.NetworkOperationBackOffAndRetry] Network operation failed
org.gradle.api.resources.ResourceException: Could not write to resource 'http://nexus.grandtheftmc.net/content/repositories/releases/net/grandtheftmc/wastedguns/1.2.8/wastedguns-1.2.8.jar'.
    at org.gradle.internal.resource.ResourceExceptions.failure(ResourceExceptions.java:74)
    at org.gradle.internal.resource.ResourceExceptions.putFailed(ResourceExceptions.java:61)
    at org.gradle.internal.resource.transfer.AccessorBackedExternalResource.put(AccessorBackedExternalResource.java:185)
    at org.gradle.internal.resource.BuildOperationFiringExternalResourceDecorator.call(BuildOperationFiringExternalResourceDecorator.java:100)
    at org.gradle.internal.resource.BuildOperationFiringExternalResourceDecorator.call(BuildOperationFiringExternalResourceDecorator.java:97)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:75)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call(DefaultBuildOperationExecutor.java:79)
    at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:79)
    at org.gradle.internal.resource.BuildOperationFiringExternalResourceDecorator.put(BuildOperationFiringExternalResourceDecorator.java:97)
    at org.gradle.api.publish.maven.internal.publisher.AbstractMavenPublisher$ModuleArtifactPublisher.run(AbstractMavenPublisher.java:272)
    at org.gradle.api.internal.artifacts.repositories.transport.NetworkOperationBackOffAndRetry.withBackoffAndRetry(NetworkOperationBackOffAndRetry.java:50)
    at org.gradle.api.publish.maven.internal.publisher.AbstractMavenPublisher$ModuleArtifactPublisher.putResource(AbstractMavenPublisher.java:269)
    at org.gradle.api.publish.maven.internal.publisher.AbstractMavenPublisher$ModuleArtifactPublisher.publish(AbstractMavenPublisher.java:230)
    at org.gradle.api.publish.maven.internal.publisher.AbstractMavenPublisher$ModuleArtifactPublisher.publish(AbstractMavenPublisher.java:223)
    at org.gradle.api.publish.maven.internal.publisher.AbstractMavenPublisher.publish(AbstractMavenPublisher.java:81)
    at org.gradle.api.publish.maven.internal.publisher.MavenRemotePublisher.publish(MavenRemotePublisher.java:61)
    at org.gradle.api.publish.maven.internal.publisher.ValidatingMavenPublisher.publish(ValidatingMavenPublisher.java:50)
    at org.gradle.api.publish.maven.tasks.PublishToMavenRepository.publish(PublishToMavenRepository.java:109)
    at org.gradle.api.publish.internal.PublishOperation.run(PublishOperation.java:43)
    at org.gradle.api.publish.maven.tasks.PublishToMavenRepository.doPublish(PublishToMavenRepository.java:111)
    at org.gradle.api.publish.maven.tasks.PublishToMavenRepository.publish(PublishToMavenRepository.java:83)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:58)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:29)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.run(ExecuteActionsTaskExecuter.java:506)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:29)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:26)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:75)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:56)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$run(DefaultBuildOperationExecutor.java:74)
    at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.runWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:45)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:74)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:491)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:474)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access0(ExecuteActionsTaskExecuter.java:106)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.executeWithPreviousOutputFiles(ExecuteActionsTaskExecuter.java:271)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:249)
    at org.gradle.internal.execution.steps.ExecuteStep.executeInternal(ExecuteStep.java:83)
    at org.gradle.internal.execution.steps.ExecuteStep.access[=12=]0(ExecuteStep.java:37)
    at org.gradle.internal.execution.steps.ExecuteStep.call(ExecuteStep.java:50)
    at org.gradle.internal.execution.steps.ExecuteStep.call(ExecuteStep.java:47)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:75)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call(DefaultBuildOperationExecutor.java:79)
    at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:79)
    at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:47)
    at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:37)
    at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:68)
    at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:38)
    at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:50)
    at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:36)
    at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:41)
    at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:74)
    at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:55)
    at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
    at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:29)
    at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:54)
    at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:35)
    at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:60)
    at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:27)
    at org.gradle.internal.execution.steps.BuildCacheStep.executeWithoutCache(BuildCacheStep.java:174)
    at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:74)
    at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:45)
    at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:40)
    at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:29)
    at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:36)
    at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:22)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:99)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute[=12=](SkipUpToDateStep.java:92)
    at java.util.Optional.map(Optional.java:215)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:52)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:36)
    at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:85)
    at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:42)
    at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:37)
    at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:27)
    at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:91)
    at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:49)
    at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:106)
    at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:51)
    at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:72)
    at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:46)
    at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute(SkipEmptyWorkStep.java:86)
    at java.util.Optional.orElseGet(Optional.java:267)
    at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:86)
    at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:32)
    at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:38)
    at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:43)
    at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:31)
    at org.gradle.internal.execution.steps.AssignWorkspaceStep.lambda$execute[=12=](AssignWorkspaceStep.java:40)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.withWorkspace(ExecuteActionsTaskExecuter.java:284)
    at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:40)
    at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:30)
    at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:37)
    at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:27)
    at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:44)
    at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:33)
    at org.gradle.internal.execution.impl.DefaultExecutionEngine.execute(DefaultExecutionEngine.java:76)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:185)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:174)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:109)
    at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.executeTask(EventFiringTaskExecuter.java:77)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.call(EventFiringTaskExecuter.java:55)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.call(EventFiringTaskExecuter.java:52)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:75)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call(DefaultBuildOperationExecutor.java:79)
    at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:79)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
    at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:74)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:408)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:395)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:388)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:374)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run[=12=](DefaultPlanExecutor.java:127)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl.run(ManagedExecutorImpl.java:48)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:210)
    at java.net.SocketInputStream.read(SocketInputStream.java:141)
    at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
    at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)
    at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
    at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
    at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
    at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157)
    at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
    at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.gradle.internal.resource.transport.http.HttpClientHelper.performHttpRequest(HttpClientHelper.java:170)
    at org.gradle.internal.resource.transport.http.HttpClientHelper.performHttpRequest(HttpClientHelper.java:150)
    at org.gradle.internal.resource.transport.http.HttpResourceUploader.upload(HttpResourceUploader.java:40)
    at org.gradle.internal.resource.transfer.DefaultExternalResourceConnector.upload(DefaultExternalResourceConnector.java:76)
    at org.gradle.internal.resource.transfer.ProgressLoggingExternalResourceUploader.upload(ProgressLoggingExternalResourceUploader.java:39)
    at org.gradle.internal.resource.transfer.AccessorBackedExternalResource.put(AccessorBackedExternalResource.java:182)
    ... 153 more
2021-07-13T18:06:42.986-0400 [LIFECYCLE] [org.gradle.internal.operations.DefaultBuildOperationRunner] 
2021-07-13T18:06:42.986-0400 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Upload http://nexus.grandtheftmc.net/content/repositories/releases/net/grandtheftmc/wastedguns/1.2.8/wastedguns-1.2.8.jar' started
2021-07-13T18:06:43.102-0400 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Upload http://nexus.grandtheftmc.net/content/repositories/releases/net/grandtheftmc/wastedguns/1.2.8/wastedguns-1.2.8.jar'
2021-07-13T18:06:43.102-0400 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Execute publish for :publishMavenPublicationToMavenRepository'
2021-07-13T18:06:43.102-0400 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Executing task ':publishMavenPublicationToMavenRepository''
2021-07-13T18:06:43.102-0400 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Snapshot outputs after executing task ':publishMavenPublicationToMavenRepository'' started
2021-07-13T18:06:43.102-0400 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Snapshot outputs after executing task ':publishMavenPublicationToMavenRepository''
2021-07-13T18:06:41.774-0400 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] 
2021-07-13T18:06:41.774-0400 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] > Task :publishMavenPublicationToMavenRepository FAILED
2021-07-13T18:06:42.986-0400 [DEBUG] [org.gradle.internal.resource.transport.http.HttpClientHelper] Performing HTTP PUT: http://nexus.grandtheftmc.net/content/repositories/releases/net/grandtheftmc/wastedguns/1.2.8/wastedguns-1.2.8.jar
2021-07-13T18:06:42.987-0400 [DEBUG] [org.apache.http.client.protocol.RequestAddCookies] CookieSpec selected: default
2021-07-13T18:06:42.987-0400 [DEBUG] [org.apache.http.client.protocol.RequestAuthCache] Auth cache not set in the context
2021-07-13T18:06:42.987-0400 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection request: [route: {}->http://nexus.grandtheftmc.net:80][total available: 0; route allocated: 0 of 20; total allocated: 0 of 20]
2021-07-13T18:06:42.987-0400 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection leased: [id: 14][route: {}->http://nexus.grandtheftmc.net:80][total available: 0; route allocated: 1 of 20; total allocated: 1 of 20]
2021-07-13T18:06:42.987-0400 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Opening connection {}->http://nexus.grandtheftmc.net:80
2021-07-13T18:06:42.987-0400 [DEBUG] [org.apache.http.impl.conn.DefaultHttpClientConnectionOperator] Connecting to nexus.grandtheftmc.net/104.26.10.9:80
2021-07-13T18:06:43.017-0400 [DEBUG] [org.apache.http.impl.conn.DefaultHttpClientConnectionOperator] Connection established 172.27.235.237:60680<->104.26.10.9:80
2021-07-13T18:06:43.017-0400 [DEBUG] [org.apache.http.impl.conn.DefaultManagedHttpClientConnection] http-outgoing-14: set socket timeout to 30000
2021-07-13T18:06:43.017-0400 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Executing request PUT /content/repositories/releases/net/grandtheftmc/wastedguns/1.2.8/wastedguns-1.2.8.jar HTTP/1.1

基于此错误,似乎出于某种原因,连接在上传中途被重置。 jar 文件自身已成功构建。事实上,如果我手动将工件上传到 nexus,它就可以正常工作。所以这让我相信问题出在 gradle?

上传过程中的某个地方

存储库是受密码保护的存储库,但是我不认为这是密码问题因为该项目的一个具有几乎相同配置的单独模块已成功上传到 nexus(不相同的部分是依赖项)。这个问题也不太可能是权限问题,因为我对要上传到的存储库拥有完全的管理员权限。

供您参考,这是我的 build.grade:

plugins {
    id "java"
    id "com.github.johnrengelman.shadow" version "6.1.0"
    id 'maven-publish'
}

group 'net.grandtheftmc'
version '2.6.1'

sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"

repositories {
    maven {
        url 'http://repo.destroystokyo.com/repository/maven-public/'
        allowInsecureProtocol = true
    }
    maven {
        url 'http://nexus.grandtheftmc.net/content/repositories/releases/'
        allowInsecureProtocol = true
        credentials {
            username mavenUser
            password mavenPassword
        }
    }
    maven {
        url 'http://jitpack.io'
        allowInsecureProtocol = true
    }
    maven {
        url 'http://maven.sk89q.com/repo/'
        allowInsecureProtocol = true
    }
    maven {
        url 'http://repo.viaversion.com'
        allowInsecureProtocol = true
    }
    maven {
        url 'http://repo.citizensnpcs.co/'
        allowInsecureProtocol = true
    }
}

dependencies {
    compileOnly 'com.sk89q.worldedit:worldedit-bukkit:6.1.4-SNAPSHOT'
    compileOnly 'net.citizensnpcs:citizensapi:2.0.22'
    compileOnly 'us.myles:viaversion:3.1.0'
    compileOnly 'com.destroystokyo.paper:paper-api:1.12.2-R0.1-SNAPSHOT'
    compileOnly 'org.spigotmc:spigot:1.12.2-R0.1'
    compileOnly 'net.buycraft:BuycraftX:10.3.0'
    compileOnly 'com.comphenix.protocol:ProtocolLib:4.6.0'
    compileOnly 'com.github.j0ach1mmall3:JLib:1.10.0'
    compileOnly 'net.grandtheftmc:wastedguns:1.2.6'
    compileOnly 'net.grandtheftmc:wastedvehicles:1.1.0'
    compileOnly 'net.grandtheftmc:wastedcops:1.1.0'
    compileOnly 'net.grandtheftmc:core:2.6.1'
    compileOnly 'net.grandtheftmc:houses:1.1.2'
    compileOnly 'com.gmail.filoghost.holographicdisplays:HolographicDisplays:1.0.0'
    implementation 'net.grandtheftmc:common:1.1.6'
    compileOnly 'com.earth2me:Essentials:2.0.0'
}

shadowJar {
    archiveFileName = project.name + ".jar"
    exclude 'META-INF', 'META-INF/**'
    destinationDirectory = file("build")
}

// Force character encoding in case the workspace was not set up correctly
tasks.withType(Javadoc) {
    options.encoding = 'UTF-8'
}

publishing {
    publications {
        maven(MavenPublication) {
            artifactId = 'gtm'
            from components.java
        }
    }
    repositories {
        maven {
            url 'http://nexus.grandtheftmc.net/content/repositories/releases/'
            allowInsecureProtocol = true
            credentials {
                username mavenUser
                password mavenPassword
            }
        }
    }
}

我完全不知道问题可能是什么。有人有什么想法吗?

虽然我仍然不明白为什么这个 build.grade 实际上能够为我的 2 个项目模块工​​作,但我确实找出了问题所在。

Nexus 似乎拒绝通过 HTTP 上传的构建。事实上,为了将构建成功上传到 Nexus,您必须使用 HTTPS。因此,只需将发布块修改为以下内容就可以解决问题:

publishing {
    publications {
        maven(MavenPublication) {
            artifactId = 'gtm'
            from components.java
        }
    }
    repositories {
        maven {
            url 'https://nexus.grandtheftmc.net/content/repositories/releases/'
            credentials {
                username mavenUser
                password mavenPassword
            }
        }
    }
}