gpt4 book ai didi

java - Gradle 影子插件失败 : Error resolving plugin

转载 作者:搜寻专家 更新时间:2023-11-01 03:47:52 25 4
gpt4 key购买 nike

我正在将 JAVA maven 项目迁移到 gradle。我在 maven 中添加了一个 Shade 插件,但是当我试图在 gradle 中复制它时,它目前失败了。它在清理时失败,即当我发出以下命令时,

gradle clean

请在下面找到 pom.xml 文件和对应的 build.gradle 文件。

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myproj.integration</groupId>
<artifactId>Generic-Integration</artifactId>
<name>Generic-Integration</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<finalName>myproj-integration-${project.version}</finalName>

<shadedArtifactAttached>true</shadedArtifactAttached>
<createDependencyReducedPom>true</createDependencyReducedPom>

<relocations>
<relocation>
<pattern>jersey.repackaged</pattern>
<shadedPattern>myproj.repackaged</shadedPattern>
</relocation>
<relocation>
<pattern>javassist</pattern>
<shadedPattern>myproj.repackaged.javassist</shadedPattern>
</relocation>

<relocation>
<pattern>org.aopalliance</pattern>
<shadedPattern>myproj.repackaged.org.aopalliance</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.logging</pattern>
<shadedPattern>myproj.repackaged.org.apache.logging</shadedPattern>
</relocation>
<relocation>
<pattern>org.codehaus.jackson</pattern>
<shadedPattern>myproj.repackaged.org.codehaus.jackson</shadedPattern>
</relocation>
<relocation>
<pattern>org.glassfish.hk2</pattern>
<shadedPattern>myproj.repackaged.org.glassfish.hk2</shadedPattern>
</relocation>
<relocation>
<pattern>org.glassfish.jersey</pattern>
<shadedPattern>myproj.repackaged.org.glassfish.jersey</shadedPattern>
</relocation>
<relocation>
<pattern>org.json</pattern>
<shadedPattern>myproj.repackaged.org.json</shadedPattern>
</relocation>
<relocation>
<pattern>org.jvnet</pattern>
<shadedPattern>myproj.repackaged.org.jvnet</shadedPattern>
</relocation>

<relocation>
<pattern>javax.annotation</pattern>
<shadedPattern>myproj.repackaged.javax.annotation</shadedPattern>
</relocation>
<relocation>
<pattern>javax.inject</pattern>
<shadedPattern>myproj.repackaged.javax.inject</shadedPattern>
</relocation>
<relocation>
<pattern>javax.ws</pattern>
<shadedPattern>myproj.repackaged.javax.ws</shadedPattern>
</relocation>
</relocations>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.myproj.integration.ServiceExecuter</mainClass>
</transformer>
</transformers>

<artifactSet>
<includes>
<include>com.myproj:Util</include>
<include>org.glassfish.hk2:hk2-api</include>
<include>org.glassfish.hk2:hk2-utils</include>
<include>org.glassfish.hk2:hk2-locator</include>
<include>org.glassfish.hk2:osgi-resource-locator</include>
<include>org.glassfish.hk2.external:aopalliance-repackaged</include>
<include>org.codehaus.jackson:jackson-core-asl</include>
<include>org.codehaus.jackson:jackson-mapper-asl</include>
<include>org.codehaus.jackson:jackson-jaxrs</include>
<include>org.codehaus.jackson:jackson-xc</include>
<include>org.javassist:javassist</include>
<include>javax.annotation:javax.annotation-api</include>
<include>org.glassfish.hk2.external:javax.inject</include>
<include>javax.ws.rs:javax.ws.rs-api</include>
<include>org.glassfish.jersey.core:jersey-client</include>
<include>org.glassfish.jersey.core:jersey-common</include>
<include>org.glassfish.jersey.bundles.repackaged:jersey-guava</include>
<include>org.glassfish.jersey.media:jersey-media-json-jackson</include>
<include>org.json:json</include>
<include>com.myproj:JAXRS</include>
</includes>
</artifactSet>

</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.myproj</groupId>
<artifactId>JAXRS</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>8.1.16.v20140903</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.myproj</groupId>
<artifactId>Server</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
<scope>test</scope>
</dependency>
</dependencies>

build.gradle

    plugins {
id 'com.github.johnrengelman.shadow' version '1.2.3'
}

shadowJar {
artifactSet {
include 'com.myproj:Util'
include 'org.glassfish.hk2:hk2-api'
include 'org.glassfish.hk2:hk2-utils'
include 'org.glassfish.hk2:hk2-locator'
include 'org.glassfish.hk2:osgi-resource-locator'
include 'org.glassfish.hk2.external:aopalliance-repackaged'
include 'org.codehaus.jackson:jackson-core-asl'
include 'org.codehaus.jackson:jackson-mapper-asl'
include 'org.codehaus.jackson:jackson-jaxrs'
include 'org.codehaus.jackson:jackson-xc'
include 'org.javassist:javassist'
include 'javax.annotation:javax.annotation-api'
include 'org.glassfish.hk2.external:javax.inject'
include 'javax.ws.rs:javax.ws.rs-api'
include 'org.glassfish.jersey.core:jersey-client'
include 'org.glassfish.jersey.core:jersey-common'
include 'org.glassfish.jersey.bundles.repackaged:jersey-guava'
include 'org.glassfish.jersey.media:jersey-media-json-jackson'
include 'org.json:json'
include 'com.myproj:JAXRS'
}
relocation {
pattern = 'jersey.repackaged'
shadedPattern = 'myproj.repackaged'
}
relocation {
pattern = 'javassist'
shadedPattern = 'myproj.repackaged.javassist'
}
relocation {
pattern = 'org.aopalliance'
shadedPattern = 'myproj.repackaged.org.aopalliance'
}
relocation {
pattern = 'org.apache.logging'
shadedPattern = 'myproj.repackaged.org.apache.logging'
}
relocation {
pattern = 'org.codehaus.jackson'
shadedPattern = 'myproj.repackaged.org.codehaus.jackson'
}
relocation {
pattern = 'org.glassfish.hk2'
shadedPattern = 'myproj.repackaged.org.glassfish.hk2'
}
relocation {
pattern = 'org.glassfish.jersey'
shadedPattern = 'myproj.repackaged.org.glassfish.jersey'
}
relocation {
pattern = 'org.json'
shadedPattern = 'myproj.repackaged.org.json'
}
relocation {
pattern = 'org.jvnet'
shadedPattern = 'myproj.repackaged.org.jvnet'
}
relocation {
pattern = 'javax.annotation'
shadedPattern = 'myproj.repackaged.javax.annotation'
}
relocation {
pattern = 'javax.inject'
shadedPattern = 'myproj.repackaged.javax.inject'
}
relocation {
pattern = 'javax.ws'
shadedPattern = 'myproj.repackaged.javax.ws'
}
}

dependencies {
compile project(':JAXRS')
compile project(':Server')
testCompile group: 'org.testng', name: 'testng', version:'6.8.8'
compile(group: 'org.eclipse.jetty', name: 'jetty-servlet', version:'8.1.16.v20140903') {
/* This dependency was originally in the Maven provided scope, but the project was not of type war.
This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency.
Please review and delete this closure when resolved. */
}
}

task genericIntegrationJar(type: Jar) {
baseName = 'myproj-integration-1.2'
from { configurations.external.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}

test.useTestNG()

当我进行清理时,出现以下异常

        FAILURE: Build failed with an exception.

* Where:
Build file '/Users/mac8/POS/MobilePosSolution/Generic-Integration/build.gradle' line: 2

* What went wrong:
Error resolving plugin [id: 'com.github.johnrengelman.shadow', version: '1.2.3']
> The response from https://plugins.gradle.org/api/gradle/2.14.1/plugin/use/com.github.johnrengelman.shadow/1.2.3 was not a valid response from a Gradle Plugin Resolution Service: content type is 'text/html;charset=iso-8859-1', expected 'application/json' (status code: 404)

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

BUILD FAILED

Total time: 4.903 secs

如果我需要在我的 build.gradle 文件中更改某些内容以复制 shade 插件,请告诉我。

最佳答案

我只是试着打它,看起来它工作正常:

curl -v https://plugins.gradle.org/api/gradle/2.14.1/plugin/use/com.github.johnrengelman.shadow/1.2.3
* Trying 104.25.173.23...
* Connected to plugins.gradle.org (104.25.173.23) port 443 (#0)
* found 173 certificates in /etc/ssl/certs/ca-certificates.crt
* found 704 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_ECDSA_AES_128_GCM_SHA256
* server certificate verification OK
* server certificate status verification SKIPPED
* common name: ssl277771.cloudflaressl.com (matched)
* server certificate expiration date OK
* server certificate activation date OK
* certificate public key: EC
* certificate version: #3
* subject: OU=Domain Control Validated,OU=PositiveSSL Multi-Domain,CN=ssl277771.cloudflaressl.com
* start date: Sat, 06 Aug 2016 00:00:00 GMT
* expire date: Sun, 05 Feb 2017 23:59:59 GMT
* issuer: C=GB,ST=Greater Manchester,L=Salford,O=COMODO CA Limited,CN=COMODO ECC Domain Validation Secure Server CA 2
* compression: NULL
* ALPN, server accepted to use http/1.1
> GET /api/gradle/2.14.1/plugin/use/com.github.johnrengelman.shadow/1.2.3 HTTP/1.1
> Host: plugins.gradle.org
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Wed, 24 Aug 2016 09:24:42 GMT
< Content-Type: application/json
< Transfer-Encoding: chunked
< Connection: keep-alive
< Set-Cookie: __cfduid=d0c64c916428b3abd24c29d0578251d2d1472030681; expires=Thu, 24-Aug-17 09:24:41 GMT; path=/; domain=.gradle.org; HttpOnly
< Via: 1.1 vegur
< Server: cloudflare-nginx
< CF-RAY: 2d75c0b211512378-FRA
<
{
"id" : "com.github.johnrengelman.shadow",
"version" : "1.2.3",
"implementation" : {
"gav" : "com.github.jengelman.gradle.plugins:shadow:1.2.3",
"repo" : "https://plugins.gradle.org/m2"
},
"implementationType" : "M2_JAR",
"legacy" : true
* Connection #0 to host plugins.gradle.org left intact

试试看会发生什么。

---编辑

只需将它添加到一个示例项目中,文件就可以正常下载。我还使用了 jcenter() 依赖库。

Download https://jcenter.bintray.com/com/github/jengelman/gradle/plugins/shadow/1.2.3/shadow-1.2.3.jar

将其添加到您的 build.gradle 文件中并尝试

buildscript {
repositories {
jcenter()
}
}

关于java - Gradle 影子插件失败 : Error resolving plugin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39118626/

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