Jitpack 构建成功,但没有 jar 文件或 jar 不包含 .class 文件

Jitpack builds successfully, but there is no jar file or jar doesn't contain .class files

提问人:crylent 提问时间:8/27/2023 最后编辑:crylent 更新时间:8/27/2023 访问量:60

问:

我正在尝试使用 Jitpack 构建我的 Android 库,但它没有制作任何 jar 文件,因此我可以插入到另一个项目的 gradle 文件中并成功同步它,但无法从库中导入任何类,甚至在外部库列表中看不到该库。implementation 'com.github.crylent:midilib:fbcf4f6c1e'

在构建日志中:

✅ Build artifacts:
com.github.crylent:midilib:b848154487

Files: 
com/github/crylent/midilib/b848154487
com/github/crylent/midilib/b848154487/build.log
com/github/crylent/midilib/b848154487/midilib-b848154487-sources.jar
com/github/crylent/midilib/b848154487/midilib-b848154487.pom
com/github/crylent/midilib/b848154487/midilib-b848154487.pom.md5
com/github/crylent/midilib/b848154487/midilib-b848154487.pom.sha1

完整日志

jitpack.yml:

before_install:
  - yes | sdkmanager "cmake;3.22.1"
  - sdk update
  - sdk install java 17.0.1-zulu
  - sdk use java 17.0.1-zulu

绒球.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.crylent</groupId>
    <artifactId>midilib</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>http://www.opensource.org/licenses/mit-license.php</url>
        </license>
    </licenses>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>

    <build>

        <plugins>

            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.3.1</version>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.3.1</version>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.11.0</version>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.1.0</version>
            </plugin>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <classesDirectory>src</classesDirectory>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-install-plugin</artifactId>
                <version>3.1.1</version>
            </plugin>
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>3.1.1</version>
            </plugin>
            <plugin>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.12.1</version>
            </plugin>
            <plugin>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>3.4.4</version>
            </plugin>
        </plugins>
    </build>

</project>

build.gradle

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.1.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
    }
}

plugins {
    id 'com.android.library' version '7.3.0' apply true
    id 'org.jetbrains.kotlin.android' version '1.8.21' apply true
    id 'maven-publish' apply true
}

android {
    publishing {
        singleVariant('release') {
            withSourcesJar()
            withJavadocJar()
        }
    }
}

afterEvaluate {
    publishing {
        publications {
            release(MavenPublication) {
                components.getByName('release')

                groupId = 'com.crylent'
                artifactId = 'midilib'
                version = 'v1.0'
            }
        }
    }
}

android {
    namespace 'com.crylent.midilib'
    compileSdkVersion 33

    defaultConfig {
        minSdk 24
        targetSdk 33

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++20 -fexceptions"
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            jniDebuggable true
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = '17'
    }
    externalNativeBuild {
        cmake {
            path file('src/main/cpp/CMakeLists.txt')
            version '3.22.1'
        }
    }
    ndkVersion '25.2.9519653'
}

dependencies {

    api 'androidx.core:core-ktx:1.10.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

    api 'com.google.oboe:oboe:1.7.0'

}
install:
  - mvn install

当我将其添加到jitpack.yml时,我会得到另一个构建日志。Jar 存在,但我仍然无法将库中的类导入到另一个项目中。当我下载 jar 并反编译时,我看到的是未编译的 .kt 文件,而不是我期望看到的 .class,因为它们在其他库中。

gradle android-gradle-plugin android-library jitpack maven-jar-plugin

评论


答: 暂无答案