Plugin with id ‘maven‘ not foundAndroid Studio | Gradle | 插件开发

Posted guangdeshishe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Plugin with id ‘maven‘ not foundAndroid Studio | Gradle | 插件开发相关的知识,希望对你有一定的参考价值。

问题:

A problem occurred evaluating project ':javassist'.
> Plugin with id 'maven' not found.
Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with id 'maven' not found.

原因:

android Studio 升级到Arctic Fox版本后,Gradle及其插件的版本默认是7.0及以上了;在Gradle 7.0以及以后的版本中maven插件已经被移除了,改为使用"maven-publish"

解决办法:

  • apply plugin: 'maven' 改为 apply plugin: 'maven-publish'

  • uploadArchives 需要改为新的写法publishing
    旧:

    uploadArchives
        repositories.mavenDeployer 
            pom.groupId = 'com.test'
            pom.artifactId = 'test'
            pom.version = '1.0.0'
            repository(url: uri('../repo'))
        
    
    

    新:

    publishing 
        publications 
            maven(MavenPublication) 
                groupId = 'com.test'
                artifactId = 'test'
                version = '1.0.0'
                from components.java
            
        
    
        repositories 
            maven 
                // change to point to your repo, e.g. http://my.org/repo
                url = '../repo'
            
        
    
    
  • 修改后完整build.gradle参考:

    apply plugin: 'groovy'
    apply plugin: 'maven-publish'
    repositories 
        mavenCentral()
    
    dependencies 
        implementation gradleApi()
        implementation localGroovy()
        implementation 'com.android.tools.build:gradle:3.1.3'
        implementation 'org.javassist:javassist:3.20.0-GA'
    
    publishing 
        publications 
            maven(MavenPublication) 
                groupId = 'com.javassist'
                artifactId = 'modify'
                version = '1.0.0'
                from components.java
            
        
        repositories 
            maven 
                // change to point to your repo, e.g. http://my.org/repo
                url = '../repo'
            
        
    
    sourceCompatibility = "7"
    targetCompatibility = "7"
    
    

参考文档

https://docs.gradle.org/7.0/userguide/publishing_maven.html

其他相关

Gradle命令中找到publish命令即可发布插件

以上是关于Plugin with id ‘maven‘ not foundAndroid Studio | Gradle | 插件开发的主要内容,如果未能解决你的问题,请参考以下文章

Plugin with id ‘maven‘ not foundAndroid Studio | Gradle | 插件开发

解决 Plugin with id 'com.github.dcendents.android-maven' not found.

Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not found解决办法

运行Maven是报错:No goals have been specified for this build

docker部署报错no main manifest attribute

运行Maven工程总是报错:No goals have been specified for this build