类路径中已存在的插件的插件请求不得包含版本 [英] plugin request for plugin already on the classpath must not include a version

查看:966
本文介绍了类路径中已存在的插件的插件请求不得包含版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在网络上搜索了类路径上已经存在的插件的插件请求,不能包含版本site:stackoverflow.com",但没有发现任何特别的地方.搜索到在类路径中已存在的插件的插件请求,插件中不能包含版本"(没有SO): https: //discuss.gradle.org/t/error-plugin-already-on-the-classpath-must-not-include-a-version/31814 我在其中读过的答案例如:

I've done web search for "plugin request for plugin already on the classpath must not include a version site:stackoverflow.com" and found nothing that particular. Search for "plugin request for plugin already on the classpath must not include a version" (w/out SO) found: https://discuss.gradle.org/t/error-plugin-already-on-the-classpath-must-not-include-a-version/31814 where I've read in answers e.g.:

我没有在Grade插件中找到对此用例的任何引用 文档.

I didn’t find any reference to this use case in Grade plugins documentation.

错误

构建文件'/Users/username/github/OpCon/app/build.gradle' 行:4错误解析插件[id:'com.android.application', 版本:"3.4.1"]

Build file '/Users/username/github/OpCon/app/build.gradle' line: 4 Error resolving plugin [id: 'com.android.application', version: '3.4.1']

已在类路径中插入插件的插件请求不得包含版本

Plugin request for plugin already on the classpath must not include a version

出现在IntelliJ IDEA的build.gradle(OpCon)中:

appears in IntelliJ IDEA, build.gradle (OpCon):

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    }
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

app/build.gradle:

plugins {
    id 'com.android.application' version '3.4.1' apply true
}

... and then other stuff

我不明白,类路径'com.android.tools.build:gradle:3.5.2'似乎不包含'com.android.application'... 如果在项目中搜索"classpath",则只会出现一次.

I don't understand, classpath 'com.android.tools.build:gradle:3.5.2' does not seem to include 'com.android.application'... "classpath" has only one occurrence if searched in the project.

已添加:

有趣地在 https://maven.google.com/web/index.html我可以找到"com.android.tools.build:gradle:3.5.2",但找不到"com.android.application"分支.

Interestingly on https://maven.google.com/web/index.html I can find 'com.android.tools.build:gradle:3.5.2' but no 'com.android.application' branch.

添加2: 我已经从此处下载的命令下载了(实际上由于某种原因下载了很多文件),

ADDED 2: I've downloaded (quite many files actually was downloaded for some reason) by command taken from here How can I download a specific Maven artifact in one command line?:

mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -DrepoUrl='https://maven.google.com/' -Dartifact='com.android.tools.build:gradle:3.4.1'

在文件管理器中找到路径com.android.tools.build:gradle,并仅在其中的jar中查看:

found path com.android.tools.build:gradle in file manager and looked inside only jar there:

username$ jar tvf /Users/username/.m2/repository/com/android/tools/build/gradle/3.4.1/gradle-3.4.1.jar | grep application
  1115 Wed May 01 20:30:18 MSK 2019 com/android/build/gradle/internal/tasks/ApplicationIdWriterTask$applicationIdSupplier$1.class
    55 Wed May 01 20:29:18 MSK 2019 META-INF/gradle-plugins/com.android.application.properties

因此在jar META-INF中提到了gradle plugin com.android.application.

So there is a mention gradle plugin com.android.application in jar META-INF.

文件com.android.application.properties是一种衬纸:implementation-class=com.android.build.gradle.AppPlugin.

对实现类java"的Web搜索可找到有关接口的信息.在Wiki https://en.wikipedia.org/wiki/Interface_(Java):

Web search for "implementation class java" finds info on interfaces. In wiki https://en.wikipedia.org/wiki/Interface_(Java):

Java编程语言中的接口是一种抽象类型,它 用于指定类必须实现的行为.

An interface in the Java programming language is an abstract type that is used to specify a behavior that classes must implement.

那么gradle插件可能是一个接口?我该如何进一步挖掘?

So gradle plugin could be an interface? How can I dig in further?

推荐答案

我遇到了同样的问题,我在使用Spring Boot和插件,​​如下所示

I was facing same problem, I was using spring boot with plugins as follows

plugins {
    id 'org.springframework.boot' version '2.2.0.RELEASE'
    id 'io.spring.dependency-management' version '1.0.8.RELEASE'
    id 'java'
    id 'war'
}

由于此插件存在于一个依赖项中,因此gradle对此有所抱怨.我只是删除了那些依赖项,它就起作用了:

Since this plugin was present in one dependency gradle was complaining about it. I simply removed those dependencies and it worked:

plugins {
    id 'java'
    id 'war'
}

这篇关于类路径中已存在的插件的插件请求不得包含版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆