Skip to content

Commit

Permalink
Merge pull request #39 from ragnarruutel/dependency-source
Browse files Browse the repository at this point in the history
Added option to choose dependency source for BOM
  • Loading branch information
emmartins authored Nov 12, 2024
2 parents 92fb2c7 + 445b416 commit f05a55e
Show file tree
Hide file tree
Showing 15 changed files with 650 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ Example usage:
<newScope>runtime</newScope>
</scopeOverride>
</scopeOverrides>
<!-- Choose dependency source DEPENDENCY_MANAGEMENT (default) or PROJECT_DEPENDENCIES for the bom -->
<dependencySource>DEPENDENCY_MANAGEMENT</dependencySource>
</configuration>
</execution>
</executions>
Expand Down
25 changes: 25 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,31 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<debug>true</debug>
<settingsFile>src/it/settings.xml</settingsFile>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<pomIncludes>
<pomInclude>*/pom.xml</pomInclude>
</pomIncludes>
<projectsDirectory>src/it</projectsDirectory>
<postBuildHookScript>verify</postBuildHookScript>
</configuration>
<executions>
<execution>
<id>run-invoker</id>
<goals>
<goal>run</goal>
</goals>
<phase>integration-test</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down
72 changes: 72 additions & 0 deletions src/it/dependencies-pom/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2013 Red Hat, Inc
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<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">
<modelVersion>4.0.0</modelVersion>

<groupId>org.wildfly.plugins.test</groupId>
<artifactId>dependencies-pom</artifactId>
<version>@pom.version@</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-bom-builder-plugin</artifactId>
<version>@pom.version@</version>
<executions>
<execution>
<id>build-bom</id>
<goals>
<goal>build-bom</goal>
</goals>
</execution>
</executions>
<configuration>
<bomGroupId>org.wildfly.plugins.test</bomGroupId>
<bomArtifactId>dependencies-pom</bomArtifactId>
<bomVersion>[email protected]@</bomVersion>
</configuration>
</plugin>
</plugins>
</build>

</project>
33 changes: 33 additions & 0 deletions src/it/dependencies-pom/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
~ Copyright (C) 2013 Red Hat, Inc
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
*/

File file = new File(basedir, "target/bom-pom.xml")
def line
def foundDependency = false
file.withReader { reader ->
while ((line = reader.readLine())!=null) {
if (line.contains("<artifactId>commons-lang3</artifactId>")) {
foundDependency = true
break
}
}
}
if (!foundDependency) {
println("VERIFY ERROR: bom-pom.xml does not contain commons-lang3 dependency!")
return false
}


88 changes: 88 additions & 0 deletions src/it/dependency-management-pom/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2013 Red Hat, Inc
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<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">
<modelVersion>4.0.0</modelVersion>

<groupId>@pom.groupId@</groupId>
<artifactId>dependency-management-pom</artifactId>
<version>@pom.version@</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.12.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- should be excluded -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-bom-builder-plugin</artifactId>
<version>@pom.version@</version>
<executions>
<execution>
<id>build-bom</id>
<goals>
<goal>build-bom</goal>
</goals>
</execution>
</executions>
<configuration>
<bomGroupId>@pom.groupId@</bomGroupId>
<bomArtifactId>dependency-management-pom</bomArtifactId>
<bomVersion>[email protected]@</bomVersion>
<excludeDependencies>
<dependency>
<groupId>*</groupId>
<artifactId>*</artifactId>
<scope>provided</scope>
</dependency>
</excludeDependencies>
</configuration>
</plugin>
</plugins>
</build>
</project>
38 changes: 38 additions & 0 deletions src/it/dependency-management-pom/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
~ Copyright (C) 2013 Red Hat, Inc
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
*/

File file = new File(basedir, "target/bom-pom.xml")
def line
def foundDependency1 = false
def foundDependency2 = false
file.withReader { reader ->
while ((line = reader.readLine())!=null) {
if (line.contains("<artifactId>commons-lang3</artifactId>")) {
foundDependency1 = true
}
if (line.contains("<artifactId>commons-text</artifactId>")) {
foundDependency2 = true
}
}
}
if (!foundDependency1) {
println("VERIFY ERROR: bom-pom.xml does not contain commons-lang3 dependency!")
return false
}
if (foundDependency2) {
println("VERIFY ERROR: bom-pom.xml should not contain commons-text dependency!")
return false
}
1 change: 1 addition & 0 deletions src/it/multi-module-pom/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.project = module1
72 changes: 72 additions & 0 deletions src/it/multi-module-pom/module1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2013 Red Hat, Inc
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>@pom.groupId@</groupId>
<artifactId>multi-module-pom</artifactId>
<version>@pom.version@</version>
</parent>
<artifactId>module1</artifactId>
<version>@pom.version@</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>

<!-- included -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>

<!-- included -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>

<!-- excluded because of provided scope -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.16.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.12.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>


</project>
41 changes: 41 additions & 0 deletions src/it/multi-module-pom/module2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2013 Red Hat, Inc
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>@pom.groupId@</groupId>
<artifactId>multi-module-pom</artifactId>
<version>@pom.version@</version>
</parent>
<artifactId>module2</artifactId>
<version>@pom.version@</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
</dependencies>

</project>
Loading

0 comments on commit f05a55e

Please sign in to comment.