Skip to content

Commit

Permalink
[MNG-8312] Generate the BOM automatically (#1797)
Browse files Browse the repository at this point in the history
Generate both skinny and fat BOMs BOM automatically
Add support for import a BOM w/ classifier in Model 4.1.0+
---------

Co-authored-by: Tamas Cservenak <tamas@cservenak.net>
  • Loading branch information
gnodet and cstamas authored Oct 17, 2024
1 parent 989f798 commit d5c8280
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 213 deletions.
40 changes: 40 additions & 0 deletions apache-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,46 @@ under the License.
</execution>
</executions>
</plugin>
<plugin>
<groupId>eu.maveniverse.maven.plugins</groupId>
<artifactId>bom-builder3</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>skinny-bom</id>
<goals>
<goal>build-bom</goal>
</goals>
<configuration>
<bomGroupId>org.apache.maven</bomGroupId>
<bomArtifactId>maven-bom</bomArtifactId>
<bomVersion>${project.version}</bomVersion>
<bomClassifier>skinny</bomClassifier>
<bomName>Maven Dependencies Skinny BOM</bomName>
<bomDescription>Bill Of Materials for Apache Maven - Maven JARS only</bomDescription>
<outputFilename>maven-skinny-bom.xml</outputFilename>
<attach>true</attach>
</configuration>
</execution>
<execution>
<id>fat-bom</id>
<goals>
<goal>build-bom</goal>
</goals>
<configuration>
<bomGroupId>org.apache.maven</bomGroupId>
<bomArtifactId>maven-bom</bomArtifactId>
<bomVersion>${project.version}</bomVersion>
<bomClassifier>fat</bomClassifier>
<bomName>Maven Dependencies Fat BOM</bomName>
<bomDescription>Bill Of Materials for Apache Maven - All dependencies</bomDescription>
<outputFilename>maven-fat-bom.xml</outputFilename>
<useDependencies>true</useDependencies>
<attach>true</attach>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,13 @@ public void validateFileModel(
}

validate20RawDependencies(
problems, m.getDependencies(), "dependencies.dependency.", EMPTY, validationLevel, request);
problems,
m.getDependencies(),
"dependencies.dependency.",
EMPTY,
isModelVersion41OrMore,
validationLevel,
request);

validate20RawDependenciesSelfReferencing(
problems, m, m.getDependencies(), "dependencies.dependency", request);
Expand All @@ -482,6 +488,7 @@ public void validateFileModel(
m.getDependencyManagement().getDependencies(),
"dependencyManagement.dependencies.dependency.",
EMPTY,
isModelVersion41OrMore,
validationLevel,
request);
}
Expand Down Expand Up @@ -539,6 +546,7 @@ public void validateFileModel(
profile.getDependencies(),
prefix,
"dependencies.dependency.",
isModelVersion41OrMore,
validationLevel,
request);

Expand All @@ -548,6 +556,7 @@ public void validateFileModel(
profile.getDependencyManagement().getDependencies(),
prefix,
"dependencyManagement.dependencies.dependency.",
isModelVersion41OrMore,
validationLevel,
request);
}
Expand Down Expand Up @@ -982,6 +991,7 @@ private void validate20RawDependencies(
List<Dependency> dependencies,
String prefix,
String prefix2,
boolean is41OrBeyond,
int validationLevel,
ModelBuilderRequest request) {
Severity errOn30 = getSeverity(validationLevel, ModelValidator.VALIDATION_LEVEL_MAVEN_3_0);
Expand All @@ -1002,7 +1012,8 @@ private void validate20RawDependencies(
key,
"must be 'pom' to import the managed dependencies.",
dependency);
} else if (dependency.getClassifier() != null
} else if (!is41OrBeyond
&& dependency.getClassifier() != null
&& !dependency.getClassifier().isEmpty()) {
addViolation(
problems,
Expand Down
209 changes: 0 additions & 209 deletions maven-bom/pom.xml

This file was deleted.

2 changes: 0 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven-parent</artifactId>
<!-- when upgrading parent, also upgrade maven-bom's parent -->
<version>43</version>
<relativePath />
</parent>
Expand Down Expand Up @@ -122,7 +121,6 @@ under the License.
<module>apache-maven</module>
<module>maven-toolchain-model</module>
<module>maven-toolchain-builder</module>
<module>maven-bom</module>
<module>maven-docgen</module>
</modules>

Expand Down

0 comments on commit d5c8280

Please sign in to comment.