android - Gradle 'publishToMavenLocal' 任务未找到。请添加 'maven-publish' 或 'maven' 插件

标签 android maven gradle jcenter jitpack

当我在 jitpack eoor 上部署我的库时出现错误,如下所示。我用过 项目完整错误在这里--->

构建开始... 开始时间:UTC 2022 年 5 月 27 日星期五 13:31:41 67cf7f81daef git : edb3881 提交 edb38816aca77f5b11d1a2be6fbe604d3e1e088c 添加一名作者 日期:2022 年 5 月 27 日星期五 19:00:52 +0530

这是我的提交:-->全部添加

    Init SDKMan
    Found Android manifest
    Android SDK version: . Build tools: 
    Found gradle
    Gradle build script
    Found gradle version: 7.0.2.
    Using gradle wrapper
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
    Downloading https://services.gradle.org/distributions/gradle-7.0.2-bin.zip
   .10%.20%.30%.40%.50%.60%.70%.80%.90%.100%

   ------------------------------------------------------------
   Gradle 7.0.2
    ------------------------------------------------------------

   Build time:   2021-05-14 12:02:31 UTC
   Revision:     1ef1b260d39daacbf9357f9d8594a8a743e2152e

   Kotlin:       1.4.31
   Groovy:       3.0.7
   Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
    JVM:          1.8.0_292 (Private Build 25.292-b10)
   OS:           Linux 4.14.63-xxxx-std-ipv6-64 amd64

   0m3.269s
   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
   openjdk version "1.8.0_292"
   OpenJDK Runtime Environment (build 1.8.0_292-8u292-b10-0ubuntu1~16.04.1-b10)
   OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)
   Getting tasks: ./gradlew tasks --all
   WARNING:  > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
   Please specify Java version in jitpack.yml
   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
   JVM:          11.0.2 (Oracle Corporation 11.0.2+9)
   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
   Tasks: 

  ⚠️   WARNING:
   Gradle 'publishToMavenLocal' task not found. Please add the 'maven-publish' or 'maven' plugin.
   See the documentation and examples: https://docs.jitpack.io

   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
   Running: ./gradlew clean -Pgroup=com.github.codewith-fun -Pversion=edb38816ac -xtest -xlint 
   publishToMavenLocal

   Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
   Use '--warning-mode all' to show the individual deprecation warnings.
   See 
   https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings
   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2

   FAILURE: Build failed with an exception.

   * Where:
   Build file '/home/jitpack/build/app/build.gradle' line: 2

   * What went wrong:
   An exception occurred applying plugin request [id: 'com.android.application']
   > Failed to apply plugin 'com.android.internal.application'.
   > Your project contains 2 or more modules with the same identification com.github.codewith- 
  fun:investwell
     at ":" and ":investwell".
     You must use different identification (either name or group) for each modules.

  * 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.

   * Get more help at https://help.gradle.org

   BUILD FAILED in 1s
   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
   Build tool exit code: 0
   Looking for artifacts...
   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
   Looking for pom.xml in build directory and ~/.m2
   2022-05-27T13:32:53.067115286Z
   Exit code: 0

   ⚠️ ERROR: No build artifacts found

最佳答案

  1. 打开项目的 build.gradle 文件。

  2. 添加对 Maven 插件的引用: 应用插件:'maven-publish'

  3. 在发布部分,指定包属性(生成的包名称将为 groupId:artifactId)。比如我们要发布一个.jar文件(为了篇幅,减少了章节内容):

publishing {
    publications {
        maven(MavenPublication) {
            groupId = 'org.company'
            artifactId = 'sample'
            version = "0.9-SNAPSHOT"
            from components.java

            pom {
                description = 'A description of my library'
                ...
            }
        }
    }
}

关于android - Gradle 'publishToMavenLocal' 任务未找到。请添加 'maven-publish' 或 'maven' 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72429685/

相关文章:

scala - 无法将Spark数据帧发送到Kafka(java.lang.ClassNotFoundException:无法找到数据源:kafka。)

android - Google Cloud Vision在android studio中产生重复文件

android - 统计远端电话响铃次数

android - VolleyError : java. lang.IllegalArgumentException: 超时 < 0

java - 无法执行目标 org.apache.maven.plugins :maven-surefire-plugin:2. 12.4:测试(默认测试)

java - Scala、Maven 和 Java 集成的构建失败

java - 注入(inject)构造函数时出错,java.lang.NoClassDefFoundError : com/thoughtworks/xstream/io/HierarchicalStreamDriver in Spring MVC

android - 使用 Gradle 添加 Tensorflow AAR 不起作用。我得到一个错误

gradle - 如何在控制台显示gradle当前可以执行的任务列表

java - Gradle 运行 bat 文件作为依赖项