Gradle GitHub依赖插件找不到依赖项

y4ekin9u  于 2023-10-19  发布在  Git
关注(0)|答案(2)|浏览(191)

我配置了一个GitHub工作流来使用gradle-build-action收集和提交Gradle依赖项,而github-dependency-graph-gradle-plugin又使用github-dependency-graph-gradle-plugin。对于一些回购,这工作得很好,但对于一个回购,它什么也没找到。我希望看到javafx依赖项列表。如何对此进行故障排除?
此存储库正在运行Gradle v 8.2.1
以下是GitHub工作流的相关部分:

- name: Setup Gradle to generate and submit dependency graphs
        uses: gradle/gradle-build-action@v2
        with:
          dependency-graph: generate-and-submit

      - name: Run a build, generating the dependency graph from 'runtimeClasspath' configurations
        run: ./gradlew build --exclude-task test
        env:
          DEPENDENCY_GRAPH_INCLUDE_CONFIGURATIONS: runtimeClasspath

以下是.\gradlew touchtime:dependencies --configuration runtimeClasspath的输出:

------------------------------------------------------------
Project ':touchtime'
------------------------------------------------------------

runtimeClasspath - Runtime classpath of source set 'main'.
+--- org.openjfx:javafx-base:15
+--- org.openjfx:javafx-graphics:15
|    \--- org.openjfx:javafx-base:15
+--- org.openjfx:javafx-controls:15
|    \--- org.openjfx:javafx-graphics:15 (*)
+--- org.openjfx:javafx-fxml:15
|    \--- org.openjfx:javafx-controls:15 (*)
+--- org.openjfx:javafx-swing:15
|    \--- org.openjfx:javafx-graphics:15 (*)
+--- org.controlsfx:controlsfx:8.40.12
\--- org.openjfx:javafx:15.0.1

这是依赖插件生成的JSON文件:

{
  "version" : 0,
  "job" : {
    "id" : "5977018633",
    "correlator" : "dependencies-depend-submit"
  },
  "sha" : "7c7f4c854a2a5129ff0776b017b6838d20cd9c61",
  "ref" : "refs/heads/main",
  "detector" : {
    "name" : "GitHub Dependency Graph Gradle Plugin",
    "version" : "0.2.0",
    "url" : "https://github.com/gradle/github-dependency-graph-gradle-plugin"
  },
  "manifests" : {
    "dependencies-depend-submit" : {
      "name" : "dependencies-depend-submit",
      "resolved" : { },
      "file" : {
        "source_location" : "settings.gradle"
      }
    }
  },
  "scanned" : "2023-08-25T14:21:33Z"
}

如果有帮助,这里是build.gradle脚本:

import java.text.SimpleDateFormat

plugins {
    id 'java-library'
    id 'org.openjfx.javafxplugin' version '0.0.13'
}

javafx {
    version = '15'
    modules = ['javafx.base', 'javafx.fxml', 'javafx.controls',
               'javafx.graphics', 'javafx.swing'
    ]
}

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

configurations {
    extraLibs
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.controlsfx:controlsfx:8.40.12'
    implementation 'org.openjfx:javafx:15.0.1'
    implementation files('dist/Classes.jar')

    extraLibs group: 'org.controlsfx', name: 'controlsfx', version: '8.40.12'

    testImplementation 'org.junit.jupiter:junit-jupiter:5.9.3'
    testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.9.3")

    testImplementation 'org.mockito:mockito-core:5.4.0'
    testImplementation 'org.mockito:mockito-junit-jupiter:5.4.0'
}

tasks.withType(Jar).configureEach {
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE

    doLast {
        new File("$buildDir/baseVersion.txt").text = gradle.ext.baseVersion
        new File("$buildDir/deployVersion.txt").text = gradle.ext.deployVersion
    }
}

jar {
    compileJava.options.debugOptions.debugLevel = "source,lines,vars"

    //Build MANIFEST.MF
    manifest {
        attributes 'Built-By' : System.properties['user.name']
        attributes 'Build-Timestamp': new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date())
        attributes 'Created-By' : "Gradle ${gradle.gradleVersion}"
        attributes 'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})"
        attributes 'Manifest-Version': gradle.ext.baseVersion
        attributes 'Deploy-Package': gradle.ext.deployVersion
        attributes 'Main-Class': gradle.ext.mainClass
    }

    // Add controlsFX Source Files into JAR output
    from {
        configurations.extraLibs.collect{
            it.isDirectory() ? it: zipTree(it)
        }
    }

    // Set output to dist/App.jar
    archiveBaseName.set("App")
    destinationDirectory.set(file("$rootDir/touchtime/dist"))
}

test {
    useJUnitPlatform()
}
juud5qan

juud5qan1#

遵循@albciff方法,我发现删除选项DEPENDENCY_GRAPH_INCLUDE_CONFIGURATIONS: runtimeClasspath开始在JSON输出文件中产生结果。我无法解释为什么这个repo需要这个,而其他repo似乎可以工作,但现在它正在生成依赖项并将其提交给GitHub。

laximzn5

laximzn52#

只有当gradle调用中的--exclude-task test被删除时,它才开始工作。
TL;DR;
我尝试使用不同的gradle-build-action版本(v2,v2.8.0,v2.5.0等),尝试使用不同的dependency-graph:值(生成,生成并提交...),指定gradle-version,添加cache-disabled : true
尝试在gradle.wrapper中指定不同的gradle版本,而不是gradle-version参数,在run: gradlew中添加--no-configuration-cache --no-build-cache参数。
--exclude-task被删除之前,工作流Assert输出中没有任何变化,它不会生成依赖关系图(注意,-x参数排除任务会产生相同的效果)。我无法解释为什么会发生这种情况,但这对我来说很有效:

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Set up JDK 11
      uses: actions/setup-java@v3
      with:
        java-version: '11'
        distribution: 'temurin'
    - name: Run chmod to make gradlew executable
      run: chmod +x ./gradlew
    - name: Setup Gradle to generate and submit dependency graphs
      uses: gradle/[email protected]
      with:
        gradle-version: 8.2.1
        #cache-disabled: true
        dependency-graph: generate
    - run: ./gradlew build

相关问题