maven-将丢失的工件发布到存储库

问题描述 投票:0回答:1

我正在尝试发布我的库,但我遇到了一些与其发布相关的问题。

我正在使用这个库https://github.com/vanniktech/gradle-maven-publish-plugin在maven central(oss)上发布我的项目,但是,这只是出于某种原因

-sources.jar
-javadoc.jar 
.module
被推送到存储库,但是
file-butler-0.1.4-SNAPSHOT.jar
不见了:(

有人知道吗?

build.gradle(模块)

plugins {
    id 'java-library'
    id 'kotlin'
    id 'kotlin-kapt'
}
dependencies {
    def gson = "com.google.code.gson:gson:2.8.6"
    def moshi = "com.squareup.moshi:moshi:1.11.0"
    def moshCodeGen = "com.squareup.moshi:moshi-kotlin-codegen:1.11.0"

    implementation(Deps.core.kotlin)
    implementation(gson)
    implementation(moshi)
    kapt(moshCodeGen)

    testImplementation(Deps.testing.truth)
    testImplementation(Deps.testing.jUnit)
    kaptTest(moshCodeGen)
}
sourceSets {
    main.kotlin.srcDirs += 'src/main/kotlin'
    main.java.srcDirs += 'src/main/java'
}
apply plugin: "com.vanniktech.maven.publish"

build.gradle.kts(项目)

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenCentral()
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.1.0")
        classpath(kotlin("gradle-plugin", "1.4.10"))
        classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.4.10")
        classpath("com.vanniktech:gradle-maven-publish-plugin:0.13.0")

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}



allprojects {
    repositories {
        mavenCentral()
        google()
        jcenter()
    }
}

task<Delete>("clean") {
    delete(rootProject.buildDir)
}

ps:

publishToMavenLocal
将预期的 jar 发布到我的本地存储库。

kotlin gradle maven-2 lib maven-publish
1个回答
0
投票

我遇到了同样的问题并用手动添加的工件而不是

from(components["java"])
解决了它。

这里是我修改的核心部分(Gradle Kotlin DSL):

// Set publish task dependency on primary jar file
tasks.publishToMavenLocal {
    dependsOn(tasks["jar"])
}

tasks.publish {
    dependsOn(tasks["jar"])
}


// Manually define sources and java-doc jar
val sourceJar by tasks.registering(Jar::class) {
    from(sourceSets["main"].allSource)
}

val javadocJar by tasks.registering(Jar::class) {
    dependsOn(tasks.javadoc)
    from(tasks.javadoc.get())
}

publishing {
    publications {
        create<MavenPublication>("Maven") {
            // Some other configurations
            artifact(tasks["jar"])
            artifact(sourceJar) {
                classifier = "sources"
            }
            artifact(javadocJar) {
                classifier = "javadoc"
            }
        }
    }
    // Some other configurations
}
© www.soinside.com 2019 - 2024. All rights reserved.