Skip to content

Commit

Permalink
GBLD-1309: new ElementHandling: "extended_interpolate"
Browse files Browse the repository at this point in the history
Take the element from the interpolated POM, but resolve the variables with the properties from the effective POM.
Don't resolve the following variables "project.basedir", "project.baseUri", "project.build.directory", "project.build.outputDirectory", "project.build.sourceDirectory", "project.build.scriptSourceDirectory", "project.build.testSourceDirectory", "project.reporting.outputDirectory"
Interpolate the parent version
Optimization (only the used models are created)
  • Loading branch information
SergeDemoulinGebit committed Nov 21, 2023
1 parent 632d94d commit 0822b50
Show file tree
Hide file tree
Showing 78 changed files with 3,768 additions and 2,384 deletions.
Empty file modified .mvn/wrapper/maven-wrapper.properties
100755 → 100644
Empty file.
21 changes: 19 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
</parent>

<artifactId>flatten-maven-plugin</artifactId>
<version>1.5.0</version>
<version>3.7.2-GBLD-1309-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>Maven Flatten Plugin</name>

<description>Plugin to generate flattened POM (reduced and resolved information required for consumers of maven repositories)
and to use (install, sign, deploy) it instead of original pom.xml.</description>
and to use (install, sign, deploy) it instead of original pom.xml.</description>

<url>https://www.mojohaus.org/flatten-maven-plugin/</url>

Expand Down Expand Up @@ -129,6 +129,8 @@
<properties>
<mavenVersion>3.5.4</mavenVersion>
<recommendedJavaBuildVersion>11</recommendedJavaBuildVersion>
<maven.compiler.target>${recommendedJavaBuildVersion}</maven.compiler.target>
<maven.compiler.source>${recommendedJavaBuildVersion}</maven.compiler.source>
<project.build.outputTimestamp>2023-05-09T19:54:01Z</project.build.outputTimestamp>
</properties>

Expand All @@ -144,6 +146,18 @@
</dependencyManagement>

<dependencies>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.2-jre</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.0</version>
</dependency>
<!-- plugin tools -->
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
Expand Down Expand Up @@ -281,8 +295,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<debug>true</debug>
<failIfNoProjects>true</failIfNoProjects>
<showErrors>true</showErrors>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<settingsFile>src/it/mrm/settings.xml</settingsFile>
Expand Down
146 changes: 73 additions & 73 deletions src/it/projects/bom-flattenMode/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
import groovy.xml.XmlSlurper

File originalPom = new File( basedir, 'bom/pom.xml' )
assert originalPom.exists()

def originalProject = new XmlSlurper().parse( originalPom )
// required and maven-plugin specific elements
assert '4.0.0' == originalProject.modelVersion.text()
assert 'org.codehaus.mojo.flatten.its' == originalProject.parent.groupId.text()
assert 'bom' == originalProject.artifactId.text()
assert '${bom.project.version}' == originalProject.version.text()
assert 'pom' == originalProject.packaging.text()
// banned elements for artifact
assert 1 == originalProject.parent.size()
assert 1 == originalProject.dependencyManagement.size()
assert 1 == originalProject.dependencyManagement.dependencies.size()
assert 11 == originalProject.dependencyManagement.dependencies.dependency.size()

File flattendPom = new File( basedir, 'bom/.flattened-pom.xml' )
assert flattendPom.exists()

def flattendProject = new XmlSlurper().parse( flattendPom )
// required elements
assert '4.0.0' == flattendProject.modelVersion.text()
assert 'org.codehaus.mojo.flatten.its' == flattendProject.groupId.text()
assert 'bom' == flattendProject.artifactId.text()
assert '0.9.1-beta1' == flattendProject.version.text()
assert 'pom' == originalProject.packaging.text()
// banned elements for artifact
assert 0 == flattendProject.build.size()
assert 1 == flattendProject.ciManagement.size()
assert 1 == flattendProject.contributors.size()
assert 1 == flattendProject.description.size()
assert 1 == flattendProject.developers.size()
assert 1 == flattendProject.distributionManagement.size()
assert 1 == flattendProject.issueManagement.size()
assert 1 == flattendProject.mailingLists.size()
assert 0 == flattendProject.modules.size()
assert 0 == flattendProject.name.size()
assert 1 == flattendProject.organization.size()
assert 0 == flattendProject.pluginRepositories.size()
assert 0 == flattendProject.prerequisites.size()
assert 1 == flattendProject.properties.size()
assert 0 == flattendProject.reporting.size()
assert 0 == flattendProject.reports.size()
assert 1 == flattendProject.scm.size()
assert 1 == flattendProject.url.size()

assert 0 == flattendProject.parent.size()
assert 1 == flattendProject.dependencyManagement.size()
assert 1 == flattendProject.dependencyManagement.dependencies.size()
assert 11 == flattendProject.dependencyManagement.dependencies.dependency.size()
assert 'spring-boot-dependencies' == flattendProject.dependencyManagement.dependencies.dependency[0].artifactId.text()
assert '1.1.0.RELEASE' == flattendProject.dependencyManagement.dependencies.dependency[0].version.text()

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
import groovy.xml.XmlSlurper

File originalPom = new File( basedir, 'bom/pom.xml' )
assert originalPom.exists()

def originalProject = new XmlSlurper().parse( originalPom )
// required and maven-plugin specific elements
assert '4.0.0' == originalProject.modelVersion.text()
assert 'org.codehaus.mojo.flatten.its' == originalProject.parent.groupId.text()
assert 'bom' == originalProject.artifactId.text()
assert '${bom.project.version}' == originalProject.version.text()
assert 'pom' == originalProject.packaging.text()
// banned elements for artifact
assert 1 == originalProject.parent.size()
assert 1 == originalProject.dependencyManagement.size()
assert 1 == originalProject.dependencyManagement.dependencies.size()
assert 11 == originalProject.dependencyManagement.dependencies.dependency.size()

File flattendPom = new File( basedir, 'bom/.flattened-pom.xml' )
assert flattendPom.exists()

def flattendProject = new XmlSlurper().parse( flattendPom )
// required elements
assert '4.0.0' == flattendProject.modelVersion.text()
assert 'org.codehaus.mojo.flatten.its' == flattendProject.groupId.text()
assert 'bom' == flattendProject.artifactId.text()
assert '0.9.1-beta1' == flattendProject.version.text()
assert 'pom' == originalProject.packaging.text()
// banned elements for artifact
assert 0 == flattendProject.build.size()
assert 1 == flattendProject.ciManagement.size()
assert 1 == flattendProject.contributors.size()
assert 1 == flattendProject.description.size()
assert 1 == flattendProject.developers.size()
assert 1 == flattendProject.distributionManagement.size()
assert 1 == flattendProject.issueManagement.size()
assert 1 == flattendProject.mailingLists.size()
assert 0 == flattendProject.modules.size()
assert 0 == flattendProject.name.size()
assert 1 == flattendProject.organization.size()
assert 0 == flattendProject.pluginRepositories.size()
assert 0 == flattendProject.prerequisites.size()
assert 1 == flattendProject.properties.size()
assert 0 == flattendProject.reporting.size()
assert 0 == flattendProject.reports.size()
assert 1 == flattendProject.scm.size()
assert 1 == flattendProject.url.size()

assert 0 == flattendProject.parent.size()
assert 1 == flattendProject.dependencyManagement.size()
assert 1 == flattendProject.dependencyManagement.dependencies.size()
assert 11 == flattendProject.dependencyManagement.dependencies.dependency.size()
assert 'spring-boot-dependencies' == flattendProject.dependencyManagement.dependencies.dependency[0].artifactId.text()
assert '1.1.0.RELEASE' == flattendProject.dependencyManagement.dependencies.dependency[0].version.text()

148 changes: 74 additions & 74 deletions src/it/projects/bom-pomElements/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,74 +1,74 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
import groovy.xml.XmlSlurper

File originalPom = new File( basedir, 'bom/pom.xml' )
assert originalPom.exists()

def originalProject = new XmlSlurper().parse( originalPom )
// required and maven-plugin specific elements
assert '4.0.0' == originalProject.modelVersion.text()
assert 'org.codehaus.mojo.flatten.its' == originalProject.parent.groupId.text()
assert 'bom' == originalProject.artifactId.text()
assert '${bom.project.version}' == originalProject.version.text()
assert 'pom' == originalProject.packaging.text()
// banned elements for artifact
assert 1 == originalProject.parent.size()
assert 1 == originalProject.dependencyManagement.size()
assert 1 == originalProject.dependencyManagement.dependencies.size()
assert 11 == originalProject.dependencyManagement.dependencies.dependency.size()

File flattendPom = new File( basedir, 'bom/.flattened-pom.xml' )
assert flattendPom.exists()

def flattendProject = new XmlSlurper().parse( flattendPom )
// required elements
assert '4.0.0' == flattendProject.modelVersion.text()
assert 'org.codehaus.mojo.flatten.its' == flattendProject.groupId.text()
assert 'bom' == flattendProject.artifactId.text()
assert '0.9.1-beta1' == flattendProject.version.text()
assert 'pom' == originalProject.packaging.text()
// banned elements for artifact
assert 0 == flattendProject.build.size()
assert 0 == flattendProject.ciManagement.size()
assert 0 == flattendProject.contributors.size()
assert 0 == flattendProject.description.size()
assert 0 == flattendProject.developers.size()
assert 0 == flattendProject.distributionManagement.size()
assert 0 == flattendProject.issueManagement.size()
assert 0 == flattendProject.mailingLists.size()
assert 0 == flattendProject.modules.size()
assert 0 == flattendProject.name.size()
assert 0 == flattendProject.organization.size()
assert 0 == flattendProject.pluginRepositories.size()
assert 0 == flattendProject.prerequisites.size()
assert 0 == flattendProject.properties.size()
assert 0 == flattendProject.reporting.size()
assert 0 == flattendProject.reports.size()
assert 0 == flattendProject.scm.size()
assert 0 == flattendProject.url.size()

assert 0 == flattendProject.parent.size()
assert 1 == flattendProject.dependencyManagement.size()
assert 1 == flattendProject.dependencyManagement.dependencies.size()
// 259 = 11 - 1 + 249 (from expanded spring boot BOM)
assert 259 == flattendProject.dependencyManagement.dependencies.dependency.size()
assert 'spring-context' == flattendProject.dependencyManagement.dependencies.dependency[0].artifactId.text()
assert '4.0.8.RELEASE' == flattendProject.dependencyManagement.dependencies.dependency[0].version.text()

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
import groovy.xml.XmlSlurper

File originalPom = new File( basedir, 'bom/pom.xml' )
assert originalPom.exists()

def originalProject = new XmlSlurper().parse( originalPom )
// required and maven-plugin specific elements
assert '4.0.0' == originalProject.modelVersion.text()
assert 'org.codehaus.mojo.flatten.its' == originalProject.parent.groupId.text()
assert 'bom' == originalProject.artifactId.text()
assert '${bom.project.version}' == originalProject.version.text()
assert 'pom' == originalProject.packaging.text()
// banned elements for artifact
assert 1 == originalProject.parent.size()
assert 1 == originalProject.dependencyManagement.size()
assert 1 == originalProject.dependencyManagement.dependencies.size()
assert 11 == originalProject.dependencyManagement.dependencies.dependency.size()

File flattendPom = new File( basedir, 'bom/.flattened-pom.xml' )
assert flattendPom.exists()

def flattendProject = new XmlSlurper().parse( flattendPom )
// required elements
assert '4.0.0' == flattendProject.modelVersion.text()
assert 'org.codehaus.mojo.flatten.its' == flattendProject.groupId.text()
assert 'bom' == flattendProject.artifactId.text()
assert '0.9.1-beta1' == flattendProject.version.text()
assert 'pom' == originalProject.packaging.text()
// banned elements for artifact
assert 0 == flattendProject.build.size()
assert 0 == flattendProject.ciManagement.size()
assert 0 == flattendProject.contributors.size()
assert 0 == flattendProject.description.size()
assert 0 == flattendProject.developers.size()
assert 0 == flattendProject.distributionManagement.size()
assert 0 == flattendProject.issueManagement.size()
assert 0 == flattendProject.mailingLists.size()
assert 0 == flattendProject.modules.size()
assert 0 == flattendProject.name.size()
assert 0 == flattendProject.organization.size()
assert 0 == flattendProject.pluginRepositories.size()
assert 0 == flattendProject.prerequisites.size()
assert 0 == flattendProject.properties.size()
assert 0 == flattendProject.reporting.size()
assert 0 == flattendProject.reports.size()
assert 0 == flattendProject.scm.size()
assert 0 == flattendProject.url.size()

assert 0 == flattendProject.parent.size()
assert 1 == flattendProject.dependencyManagement.size()
assert 1 == flattendProject.dependencyManagement.dependencies.size()
// 259 = 11 - 1 + 249 (from expanded spring boot BOM)
assert 259 == flattendProject.dependencyManagement.dependencies.dependency.size()
assert 'spring-context' == flattendProject.dependencyManagement.dependencies.dependency[0].artifactId.text()
assert '4.0.8.RELEASE' == flattendProject.dependencyManagement.dependencies.dependency[0].version.text()

Loading

0 comments on commit 0822b50

Please sign in to comment.