Quantcast
Channel: Gradle Forums - Latest posts
Viewing all articles
Browse latest Browse all 20335

SourceSet with name 'main' not found

$
0
0

I’ve made some improvements. Regarding sourcesJar I’ve moved that function to the module build.gradle.kts and changed it to from(android.sourceSets.getByName("main").java.srcDirs) so the build.gradle became:

plugins {
    id("com.android.library")
}

android {
    compileSdkVersion(AndroidConstants.compileSdkVersions)

    defaultConfig {
        minSdkVersion(AndroidConstants.minSdkVersion)
        targetSdkVersion(AndroidConstants.targetSdkVersion)
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}

dependencies {
    /** Package the given lint checks library into this AAR  */
    lintPublish(project(":checks"))
}

val sourcesJar by tasks.registering(Jar::class) {
    archiveClassifier.set("sources")
    from(android.sourceSets.getByName("main").java.srcDirs)
}

apply(from = rootProject.file("deploy-bintray.gradle.kts"))

This was the only way I found to avoid:

SourceSet with name 'main' not found.

Is it correct?

Next, I’ve updated deploy-bintray.gradle.kts to:

publications {
       create<MavenPublication>(bintrayRepo) {
           groupId = publishedGroupId
           artifactId = artifact
           version = libraryVersion

           from(components["java"])
//            artifact(sourcesJar.get())
           artifact(tasks.findByName("sourcesJar"))
           artifact(dokkaJar.get())

Unfortunately from(components["java"]) still fails…


Viewing all articles
Browse latest Browse all 20335

Trending Articles