"mavenBom file: 'pom.xml'" causes error "Module may not be null"
Steps to reproduce:
create build.gradle:
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'com.netflix.nebula:nebula-dependency-recommender:4.0.2'
}
}
repositories {
mavenCentral()
}
apply plugin: 'java'
apply plugin: 'nebula.dependency-recommender'
dependencyRecommendations {
mavenBom file: 'pom.xml'
}
create pom.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/maven-v4_0_0.xsd">
<groupId>org.example</groupId>
<artifactId>example</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<dependencyManagement>
</dependencyManagement>
</project>
execute gradle build:
FAILURE: Build failed with an exception.
* Where:
Build file '/tmp/example/build.gradle' line: 19
* What went wrong:
A problem occurred evaluating root project 'example'.
> Module may not be null
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 0.719 secs
using gradle --version:
------------------------------------------------------------
Gradle 3.4
------------------------------------------------------------
Build time: 2017-02-20 14:49:26 UTC
Revision: 73f32d68824582945f5ac1810600e8d87794c3d4
Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_121 (Oracle Corporation 25.121-b13)
OS: Linux 4.1.15-gentoo-r1 amd64
still active in 4.3.0
Any chance this will be fixed, or is there any workaround? We have to stay on version 3.6.3 (latest without a bug) which prevents us from upgrading to Gradle 4.x Thanks
I am getting the same problem, in version 4.3.0 and 5.0.0. I want to reference a local bom file, but when I run it errors with the message, "Module may not be null."
I notice that mavenBom file: file("${rootProject.projectDir}/pom.xml") successfully works in version 3.6.2. Therefor, this error was introduced after that.
Would be nice to get at least some response from the maintainers whenever that's a bug or desired regression
/cc @sghill @chali
The regression happened here: https://github.com/nebula-plugins/nebula-dependency-recommender-plugin/pull/30
@bsideup have you tried the BOM Import in Gradle 4.6? If possible it should be preferred to use the core gradle feature rather than this plugin.
For legacy projects already using this plugin, it was recently updated to delegate to the core feature by adding:
-
systemProp.nebula.features.coreBomSupport=trueto gradle.properties -
enableFeaturePreview('IMPROVED_POM_SUPPORT')to settings.gradle. This step will not be necessary after Gradle 5.0 is released.
cc @minmay @eprst @Godin
@sghill yep, AFAIK it doesn't work with files :)
@bsideup it works with a file repo defined. Here's a working example using the original posted empty-bom and a second bom that includes a junit dependency
settings.gradle:
enableFeaturePreview('IMPROVED_POM_SUPPORT')
build.gradle:
plugins { id 'java' }
repositories {
maven { url 'bom-repo' } // repo in the project
mavenCentral()
}
dependencies {
implementation 'org.example:empty-bom:1.0'
implementation 'org.example:testing-bom:1.0'
testImplementation 'junit:junit' // comes from testing-bom
}
dependencies task output:
$ ./gradlew dependencies --configuration testRuntimeClasspath --console=plain
> Task :dependencies
------------------------------------------------------------
Root project
------------------------------------------------------------
testRuntimeClasspath - Runtime classpath of source set 'test'.
+--- org.example:empty-bom:1.0
+--- org.example:testing-bom:1.0
| \--- junit:junit:4.10
| \--- org.hamcrest:hamcrest-core:1.1
\--- junit:junit -> 4.10 (*)
(*) - dependencies omitted (listed previously)
repo structure:
$ tree .
.
├── bom-repo
│ └── org
│ └── example
│ ├── empty-bom
│ │ └── 1.0
│ │ └── empty-bom-1.0.pom
│ └── testing-bom
│ └── 1.0
│ └── testing-bom-1.0.pom
├── build.gradle
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
└── main
└── java