首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在.gradlew命令行构建中找不到dokka?

在.gradlew命令行构建中找不到dokka?
EN

Stack Overflow用户
提问于 2020-09-03 12:41:06
回答 1查看 187关注 0票数 0

我正在尝试构建一个项目,它使用:https://github.com/Arasthel/SpannedGridLayoutManager

当我运行./gradlew --assemble时,我得到:

代码语言:javascript
复制
1: Task failed with an exception.
-----------
* Where:
Build file '/path/to/SpannedGridLayoutManager/spannedgridlayoutmanager/build.gradle' line: 3

* What went wrong:
A problem occurred evaluating project ':spannedlm'.
> Plugin with id 'org.jetbrains.dokka-android' not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.

这是SpannedGridLayoutManager/spannedgridlayoutmanager/build.gradle

代码语言:javascript
复制
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'org.jetbrains.dokka-android'

task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaAndroidTask) {
    delete "$rootDir/docs"

    outputFormat = 'html'
    outputDirectory = "$rootDir/docs"

    externalDocumentationLink {
        url = new URL("https://developer.android.com/reference/")
    }

    includeNonPublic = false

    // Always recreate documentation
    outputs.upToDateWhen { return false }
}

afterEvaluate {
    if (project.hasProperty("javadocJar")) {
        tasks.javadocJar.dependsOn dokkaJavadoc
    }
}

ext {
    bintrayRepo = 'maven'
    bintrayName = 'spannedgridlayoutmanager'

    publishedGroupId = 'com.arasthel'
    libraryName = 'SpannedGridLayoutManager'
    artifact = 'spannedgridlayoutmanager'

    libraryDescription = 'A layout manager that will resize and reorder views based on a provided SpanSize.'

    siteUrl = 'https://github.com/Arasthel/SpannedGridLayoutManager'
    gitUrl = 'https://github.com/Arasthel/SpannedGridLayoutManager.git'

    libraryVersion = '3.0.2'

    developerId = 'Arasthel'
    developerName = 'Jorge Martín Epsinosa'
    developerEmail = 'jorgemartinespinosa@gmail.com'

    licenseName = 'MIT'
    licenseUrl = 'https://opensource.org/licenses/MIT'
    allLicenses = ["MIT"]
}

android {
    //compileSdkVersion 28
    compileSdkVersion 29
    buildToolsVersion buildtools_version

    defaultConfig {
        minSdkVersion 14
        //targetSdkVersion 28
        targetSdkVersion 28
        versionCode 1
        versionName libraryVersion
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

tasks.withType(Javadoc) {
    excludes = ['**/*.kt']
}

dependencies {
    implementation "com.android.support:recyclerview-v7:$support_library_version"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

// Bintray Upload
apply from: '../gradle/tools/bintrayv1.gradle'
apply from: '../gradle/tools/installv1.gradle'

这是SpannedGridLayoutManager/build.gradle

代码语言:javascript
复制
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    //ext.kotlin_version = '1.3.10'
    ext.kotlin_version = '1.3.61'
    ext.support_library_version = '28.0.0'
    //ext.dokka_version = '0.9.17'
    ext.dokka_version = '0.9.18'
    ext.buildtools_version = '28.0.3'
    repositories {
        jcenter()
        google()
    }
    dependencies {
        //classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.android.tools.build:gradle:4.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$dokka_version"

        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

我需要做些什么才能让它正常工作?

旁白-这看起来像是某个插件,gradlew不能从它的存储库中在线检索。

对于给定的配置,是否有一个命令可以查看gradlew可见的所有可用插件?像apt-show-versions -R -a这样的东西会列出apt在Debian中可用的所有包吗?

EN

回答 1

Stack Overflow用户

发布于 2020-09-05 18:24:11

嗯,在读了一点Custom Gradle Plugin ID not found之后,我想我已经弄明白了。

问题是-我可以用./gradlew assemble构建SpannedGridLayoutManager;但我得到的错误消息是在我将其构建为依赖项目时特别出现的。

问题是:当我独立构建SpannedGridLayoutManager时,首先会调用SpannedGridLayoutManager/build.gradle,并在buildscriptdependencies中定义classpath-然后在SpannedGridLayoutManager/spannedgridlayoutmanager/build.gradle时,插件ids会根据前面定义的classpath进行解析。

当我构建我的项目时,当然首先运行MyProject/build.gradle --但是它没有相同的classpath集;所以当MyProject/../SpannedGridLayoutManager/spannedgridlayoutmanager/build.gradle作为依赖项目被处理时,类路径没有被定义,插件查找失败。

所以在我的项目中,我基本上必须在build.gradle中添加这两行-这里显示为diff:

代码语言:javascript
复制
$ git diff build.gradle
diff --git a/build.gradle b/build.gradle
index b730fda..6a696c9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,6 @@
 buildscript {
     ext.kotlin_version = "1.4.0"
+    ext.dokka_version = '0.9.18'
     repositories {
         google()
         jcenter()
@@ -10,6 +11,7 @@ buildscript {
         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
         classpath "com.android.tools.build:gradle:4.0.1"
         classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4"
+        classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$dokka_version"
     }
 }

当然,这两行代码是从原始构建文件SpannedGridLayoutManager/build.gradle完全复制过来的。

嗯,很高兴解决了这个问题--但如果有更好的错误消息,那就更好了(或者甚至,如果./gradlew --debug会说一些像searching classpaths for ...这样的话,然后把它看起来和找到的所有东西都倒掉)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63716972

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档