Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle 7 and jitpack.io runs into error during publish

When I upgrade in an Android project to Gradle 7.0 and want to publish aar library in jitpack.io I run into

Script '/script/maven-plugin.gradle' line: 2

* What went wrong:
A problem occurred evaluating script.
> Failed to apply plugin 'com.github.dcendents.android-maven'.
   > Could not create plugin of type 'AndroidMavenPlugin'.
      > Could not generate a decorated class for type AndroidMavenPlugin.
         > org/gradle/api/publication/maven/internal/MavenPomMetaInfoProvider 

See full log https://jitpack.io/com/github/appdevnext/moka/0.7.1/build.log

like image 829
hannes ach Avatar asked May 19 '21 08:05

hannes ach


People also ask

How do I publish a Gradle project to GitHub?

Edit the build.gradle.kts file to allow this library to be published to GitHub Packages . Here are the high level steps. Add some plugins so that we can publish this project to GitHub Packages. Configure the maven publishing plugin. More info. To publish, you have to run the gradle task named publish.

What happened to the Maven plugin in Gradle 7?

The Maven plugin has been eliminated in Gradle 7.0, please use the maven-publish plugin instead.

How do I publish a library to jitpack?

Before you can publish this library, make sure that you can run the following commands, that ensure that JitPack can build this repo using gradle. In order to publish this repo to JitPack you have to do the following things. Make the changes that you want the repo, and commit and push it.

Why jitpack is not a standard Maven repository?

Because the JitPack is not a "standard" Maven repository, you have tell plugins DSL about it. To do this, add following block to your project's settings.gradle.kt file.


2 Answers

The Maven plugin has been eliminated in Gradle 7.0, please use the maven-publish plugin instead.

I made it work with

plugins {
    id 'maven-publish'
    ...
}

task androidSourcesJar(type: Jar) {
    classifier 'sources'
    from android.sourceSets.main.java.srcDirs 
}

project.afterEvaluate {
    publishing {
        publications {
            release(MavenPublication) {
                from components.release
                artifact androidSourcesJar // optional sources
            }
        }
    }
}

and you need an own jitpack.yml

jdk:
  - openjdk11
install:
  - ./gradlew build :lib:publishToMavenLocal

Here you see complete pull request https://github.com/AppDevNext/Moka/pull/77 now it works https://jitpack.io/#AppDevNext/moka/1.0

like image 185
hannes ach Avatar answered Oct 17 '22 17:10

hannes ach


DSL version

    publishing {
      publications {
        val mavenJava by creating(MavenPublication::class) {
            from(components["java"])
        }
    }
}
like image 1
Sharon Avatar answered Oct 17 '22 17:10

Sharon