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

Lax*_*ant 4 android gradle maven jcenter jitpack

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

\n

构建开始...\n开始: 5 月 27 日星期五 13:31:41 UTC 2022 67cf7f81daef\nGit:\nedb3881\ncommit edb38816aca77f5b11d1a2be6fbe604d3e1e088c\n作者: Laxmi kant\n日期: 5 月 27 日星期五 19:00:52 202 2 +0530

\n

这是我的提交:--> 添加了所有

\n
    Init SDKMan\n    Found Android manifest\n    Android SDK version: . Build tools: \n    Found gradle\n    Gradle build script\n    Found gradle version: 7.0.2.\n    Using gradle wrapper\n    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2\n    Downloading https://services.gradle.org/distributions/gradle-7.0.2-bin.zip\n   .10%.20%.30%.40%.50%.60%.70%.80%.90%.100%\n\n   ------------------------------------------------------------\n   Gradle 7.0.2\n    ------------------------------------------------------------\n\n   Build time:   2021-05-14 12:02:31 UTC\n   Revision:     1ef1b260d39daacbf9357f9d8594a8a743e2152e\n\n   Kotlin:       1.4.31\n   Groovy:       3.0.7\n   Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020\n    JVM:          1.8.0_292 (Private Build 25.292-b10)\n   OS:           Linux 4.14.63-xxxx-std-ipv6-64 amd64\n\n   0m3.269s\n   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2\n   openjdk version "1.8.0_292"\n   OpenJDK Runtime Environment (build 1.8.0_292-8u292-b10-0ubuntu1~16.04.1-b10)\n   OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)\n   Getting tasks: ./gradlew tasks --all\n   WARNING:  > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.\n   Please specify Java version in jitpack.yml\n   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2\n   JVM:          11.0.2 (Oracle Corporation 11.0.2+9)\n   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2\n   Tasks: \n\n  \xe2\x9a\xa0\xef\xb8\x8f   WARNING:\n   Gradle 'publishToMavenLocal' task not found. Please add the 'maven-publish' or 'maven' plugin.\n   See the documentation and examples: https://docs.jitpack.io\n\n   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2\n   Running: ./gradlew clean -Pgroup=com.github.codewith-fun -Pversion=edb38816ac -xtest -xlint \n   publishToMavenLocal\n\n   Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.\n   Use '--warning-mode all' to show the individual deprecation warnings.\n   See \n   https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings\n   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2\n\n   FAILURE: Build failed with an exception.\n\n   * Where:\n   Build file '/home/jitpack/build/app/build.gradle' line: 2\n\n   * What went wrong:\n   An exception occurred applying plugin request [id: 'com.android.application']\n   > Failed to apply plugin 'com.android.internal.application'.\n   > Your project contains 2 or more modules with the same identification com.github.codewith- \n  fun:investwell\n     at ":" and ":investwell".\n     You must use different identification (either name or group) for each modules.\n\n  * Try:\n   Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get \n   more log output. Run with --scan to get full insights.\n\n   * Get more help at https://help.gradle.org\n\n   BUILD FAILED in 1s\n   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2\n   Build tool exit code: 0\n   Looking for artifacts...\n   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2\n   Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2\n   Looking for pom.xml in build directory and ~/.m2\n   2022-05-27T13:32:53.067115286Z\n   Exit code: 0\n\n   \xe2\x9a\xa0\xef\xb8\x8f ERROR: No build artifacts found\n
Run Code Online (Sandbox Code Playgroud)\n

mic*_*cle 11

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

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

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

afterEvaluate {
    publishing {
        publications {
            release(MavenPublication) {
                from components.release
                groupId = 'com.github.mint'
                artifactId = 'mint-android-app'
                version = '0.0.4'
            }
        }
    }
}

Run Code Online (Sandbox Code Playgroud)