CycloneDX / cyclonedx-gradle-plugin

Creates CycloneDX Software Bill of Materials (SBOM) from Gradle projects
https://cyclonedx.org/
Apache License 2.0
160 stars 76 forks source link

Hello, I have encountered such an error, I do not know how to solve it #359

Open wzd-hash opened 1 year ago

wzd-hash commented 1 year ago

image

glefloch commented 1 year ago

Could you run the command with the -S flag to show the full stack trace ?

wzd-hash commented 1 year ago

Do you need this kind of information

E:\Data\project\file\code\KanJing-Android-Research>.\gradlew --init-script .\init.gradle cyclonedxBom -info -S Initialized native services in: E:\AppData\java\gradle\repository\native Found daemon DaemonInfo{pid=31984, address=[418e0c28-3ab6-45ee-8234-a554f9552547 port:53547, addresses:[/127.0.0.1]], state=Idle, lastBusy=1698905972834, context=DefaultDaemonContext[uid=00c73fee-3fdd-4a6e-8027-92861e162f7c,javaHome=D:\java\software\jdk\JDK8,daemonRegistryDir=E:\AppData\java\gradle\repository\daemon,pid=31984,idleTimeout=10800000,priority=NORMAL,daemonOpts=-Xmx1536m,-Dfile.encoding=GBK,-Duser.country=CN,-Duser.language=zh,-Duser.variant]} however its context does not match the desired criteria. At least one daemon option is different. Wanted: DefaultDaemonContext[uid=null,javaHome=D:\java\software\jdk\JDK8,daemonRegistryDir=E:\AppData\java\gradle\repository\daemon,pid=19524,idleTimeout=null,priority=NORMAL,daemonOpts=-Xmx2048m,-Dfile.encoding=GBK,-Duser.country=CN,-Duser.language=zh,-Duser.variant] Actual: DefaultDaemonContext[uid=00c73fee-3fdd-4a6e-8027-92861e162f7c,javaHome=D:\java\software\jdk\JDK8,daemonRegistryDir=E:\AppData\java\gradle\repository\daemon,pid=31984,idleTimeout=10800000,priority=NORMAL,daemonOpts=-Xmx1536m,-Dfile.encoding=GBK,-Duser.country=CN,-Duser.language=zh,-Duser.variant]

Looking for a different daemon... Removing 0 daemon stop events from registry Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details Starting process 'Gradle build daemon'. Working directory: E:\AppData\java\gradle\repository\daemon\6.1.1 Command: D:\java\software\jdk\JDK8\bin\java.exe -Xmx2048m -Dfile.encoding=GBK -Duser.country=CN -Duser.language=zh -Duser.variant -cp E:\AppData\java\gradle\repository\wrapper\dists\gradle-6.1.1-all\cfmwm155h49vnt3hynmlrsdst\gradle-6.1.1\lib\gradle-launcher-6.1.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.1.1 Successfully started process 'Gradle build daemon' An attempt to start the daemon took 8.315 secs. The client will now receive all logging from the daemon (pid: 31992). The daemon log file: E:\AppData\java\gradle\repository\daemon\6.1.1\daemon-31992.out.log Starting build in new daemon [memory: 1.9 GB] Using 8 worker leases. Starting Build Settings evaluated using settings file 'E:\Data\project\file\code\KanJing-Android-Research\settings.gradle'. Projects loaded. Root project using build file 'E:\Data\project\file\code\KanJing-Android-Research\build.gradle'. Included projects: [root project 'smart-marketing-resource', project ':app', project ':library-aop', project ':library-base', project ':library-common', project ':library-db', project ':library-network', project ':library-widget', project ':md360vrlib', project ':module_live', project ':moudle_config']

Configure project : Evaluating root project 'smart-marketing-resource' using build file 'E:\Data\project\file\code\KanJing-Android-Research\build.gradle'.

Configure project :app Evaluating project ':app' using build file 'E:\Data\project\file\code\KanJing-Android-Research\app\build.gradle'. Creating configuration androidTestUtil Warning: The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin. Configuring Java sources compilation with source level 1.8 and target level 1.8. project.aspectjx=AJXExtension{includes=[[]], excludes=[[androidx, com.google, org.jetbrains.kotlin, com.squareup, android.support, versions.9]], ajcArgs=[[]], enabled=true}

Configure project :library-aop Evaluating project ':library-aop' using build file 'E:\Data\project\file\code\KanJing-Android-Research\library-aop\build.gradle'. Creating configuration androidTestUtil

Configure project :library-base Evaluating project ':library-base' using build file 'E:\Data\project\file\code\KanJing-Android-Research\library-base\build.gradle'. Creating configuration androidTestUtil Warning: The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.

Configure project :library-common Evaluating project ':library-common' using build file 'E:\Data\project\file\code\KanJing-Android-Research\library-common\build.gradle'. Creating configuration androidTestUtil

Configure project :library-db Evaluating project ':library-db' using build file 'E:\Data\project\file\code\KanJing-Android-Research\library-db\build.gradle'. Creating configuration androidTestUtil

Configure project :library-network Evaluating project ':library-network' using build file 'E:\Data\project\file\code\KanJing-Android-Research\library-network\build.gradle'. Creating configuration androidTestUtil

Configure project :library-widget Evaluating project ':library-widget' using build file 'E:\Data\project\file\code\KanJing-Android-Research\library-widget\build.gradle'. Creating configuration androidTestUtil

Configure project :md360vrlib Evaluating project ':md360vrlib' using build file 'E:\Data\project\file\code\KanJing-Android-Research\md360vrlib\build.gradle'. Creating configuration androidTestUtil

Configure project :module_live Evaluating project ':module_live' using build file 'E:\Data\project\file\code\KanJing-Android-Research\module_live\build.gradle'. Creating configuration androidTestUtil

Configure project :moudle_config Evaluating project ':moudle_config' using build file 'E:\Data\project\file\code\KanJing-Android-Research\moudle_config\build.gradle'. Creating configuration androidTestUtil All projects evaluated. Analytics other plugin to proto: Unknown plugin type org.cyclonedx.gradle.CycloneDxPlugin expected enum ORG_CYCLONEDX_GRADLE_CYCLONEDXPLUGIN Analytics other plugin to proto: Unknown plugin type org.cyclonedx.gradle.CycloneDxPlugin expected enum ORG_CYCLONEDX_GRADLE_CYCLONEDXPLUGIN Analytics other plugin to proto: Unknown plugin type com.hujiang.gradle.plugin.android.aspectjx.AJXPlugin expected enum COM_HUJIANG_GRADLE_PLUGIN_ANDROID_ASPECTJX_AJXPLUGIN Analytics other plugin to proto: Unknown plugin type org.jetbrains.kotlin.gradle.internal.AndroidSubplugin expected enum ORG_JETBRAINS_KOTLIN_GRADLE_INTERNAL_ANDROIDSUBPLUGIN Analytics other plugin to proto: Unknown plugin type org.cyclonedx.gradle.CycloneDxPlugin expected enum ORG_CYCLONEDX_GRADLE_CYCLONEDXPLUGIN Analytics other plugin to proto: Unknown plugin type org.cyclonedx.gradle.CycloneDxPlugin expected enum ORG_CYCLONEDX_GRADLE_CYCLONEDXPLUGIN Analytics other plugin to proto: Unknown plugin type org.jetbrains.kotlin.gradle.internal.AndroidSubplugin expected enum ORG_JETBRAINS_KOTLIN_GRADLE_INTERNAL_ANDROIDSUBPLUGIN Analytics other plugin to proto: Unknown plugin type org.cyclonedx.gradle.CycloneDxPlugin expected enum ORG_CYCLONEDX_GRADLE_CYCLONEDXPLUGIN Analytics other plugin to proto: Unknown plugin type org.cyclonedx.gradle.CycloneDxPlugin expected enum ORG_CYCLONEDX_GRADLE_CYCLONEDXPLUGIN Analytics other plugin to proto: Unknown plugin type org.cyclonedx.gradle.CycloneDxPlugin expected enum ORG_CYCLONEDX_GRADLE_CYCLONEDXPLUGIN Analytics other plugin to proto: Unknown plugin type org.cyclonedx.gradle.CycloneDxPlugin expected enum ORG_CYCLONEDX_GRADLE_CYCLONEDXPLUGIN Analytics other plugin to proto: Unknown plugin type org.cyclonedx.gradle.CycloneDxPlugin expected enum ORG_CYCLONEDX_GRADLE_CYCLONEDXPLUGIN Analytics other plugin to proto: Unknown plugin type org.cyclonedx.gradle.CycloneDxPlugin expected enum ORG_CYCLONEDX_GRADLE_CYCLONEDXPLUGIN Analytics other plugin to proto: Unknown plugin type org.cyclonedx.gradle.CycloneDxPlugin expected enum ORG_CYCLONEDX_GRADLE_CYCLONEDXPLUGIN Selected primary task 'cyclonedxBom' from project : Tasks to be executed: [task ':cyclonedxBom', task ':app:cyclonedxBom', task ':library-aop:cyclonedxBom', task ':library-base:cyclonedxBom', task ':library-common:cyclonedxBom', task ':library-db:cyclonedxBom', task ':library-network:cyclonedxBom', task ':library-widget:cyclonedxBom', task ':md360vrlib:cyclonedxBom', task ':module_live:cyclonedxBom', task ':moudle_config:cyclonedxBom'] :cyclonedxBom (Thread[Execution worker for ':' Thread 2,5,main]) started.

Task :cyclonedxBom FAILED Task :cyclonedxBom in app Starting Caching disabled for task ':cyclonedxBom' because: Build cache is disabled Task ':cyclonedxBom' is not up-to-date because: Task has failed previously. CycloneDX: Parameters

schemaVersion : 1.5 includeLicenseText : true includeBomSerialNumber : false includeConfigs : [runtimeClasspath] skipConfigs : [compileClasspath, testCompileClasspath] skipProjects : [smart-marketing-resource, yourTestSubProject] destination : E:\Data\project\file\code\KanJing-Android-Research\build\reports outputName : bom

CycloneDX: Resolving Dependencies An unexpected issue occurred attempting to create a PackageURL for :smart-marketing-resource:unspecified An unexpected issue occurred attempting to create a PackageURL for :smart-marketing-resource:unspecified An unexpected issue occurred attempting to create a PackageURL for :smart-marketing-resource:unspecified CycloneDX: Creating BOM CycloneDX: Writing BOM JSON CycloneDX: Validating BOM Task :cyclonedxBom in app Finished :cyclonedxBom spend 593ms :cyclonedxBom (Thread[Execution worker for ':' Thread 2,5,main]) completed. Took 0.642 secs. 00:00.59 :cyclonedxBom

FAILURE: Build failed with an exception.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/6.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 27s 1 actionable task: 1 executed

ankursharma180 commented 10 months ago

I have just applied plugin, facing similar issue:

* What went wrong:
A problem occurred configuring root project 'library'.
> Could not create task ':cyclonedxBom'.
   > Could not create task of type 'CycloneDxTask'.
      > org.gradle.api.provider.Property.convention(Ljava/lang/Object;)Lorg/gradle/api/provider/Property;

I have a multi module gradle project, so, I've applied below in my root build.gradle plugins { id 'org.cyclonedx.bom' version '1.8.1' } So, I am facing the error above, can't figure out anything, any solution ?

skhokhlov commented 3 months ago

The problem can be related to the charset you're using by default. Please make sure that the gradle files are encoded using UTF-8 and run the plugin with -Dfile.encoding=UTF-8 command line option to verify it.

ThomGeG commented 3 months ago

@wzd-hash I'm going to take a stab in the dark here and guess you don't have a group ID defined for your project.

If you open the BOM being produced you'll probably see something this:

  "dependencies" : [
    {
      "ref" : null,
      "dependsOn" : [
        "pkg:maven/org.springframework.boot/spring-boot-starter-artemis@3.3.2?type=jar",
        "pkg:maven/org.apache.commons/commons-lang3@3.14.0?type=jar"
      ]
    },

That null is your problem and it stems from the thing you're building a BOM for not having a group id defined in its build.gradle.

It's been nearly a year since you raised this so maybe you've figured it out already but I thought I'd leave something for any other people having the same problem.

The plugin itself should maybe be smarter about what to do when people haven't defined a group id.

EDIT: Tagged the wrong person, sorry.