Skip to content

Commit

Permalink
Feature/extended interpolate (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeDemoulinGebit authored Sep 13, 2024
1 parent 575eb6e commit e386ef7
Show file tree
Hide file tree
Showing 31 changed files with 1,414 additions and 66 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.codehaus.mojo.flatten.its</groupId>
<artifactId>issue-382-project-version-from-parent-is-not-interpolated</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>bom</artifactId>

<packaging>pom</packaging>

<properties>
<interpolated-project-version>${project.version}</interpolated-project-version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.codehaus.mojo.flatten.its</groupId>
<artifactId>issue-382-project-version-from-parent-is-not-interpolated</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
<interpolated-project-version>${project.version}</interpolated-project-version>
</properties>

<modules>
<module>bom</module>
</modules>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>${project.version}</version>
</dependency>

</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<pomElements>
<parent>remove</parent>
<properties>interpolate</properties>
<dependencyManagement>interpolate</dependencyManagement>
</pomElements>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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

{
final File parentOriginalFile = new File(basedir, 'pom.xml')
assert parentOriginalFile.exists()

final parentOriginal = new XmlSlurper().parse(parentOriginalFile)
assert '${project.version}' == parentOriginal.dependencyManagement.dependencies.dependency[0].version.text()

}

{
final File flattenedParentPomFile = new File(basedir, '.flattened-pom.xml')
assert flattenedParentPomFile.exists()

final flattenedParent = new XmlSlurper().parse(flattenedParentPomFile)
assert 0 == flattenedParent.parent.size()
assert '0.0.1-SNAPSHOT' == flattenedParent.properties.'interpolated-project-version'.text()
assert '0.0.1-SNAPSHOT' == flattenedParent.dependencyManagement.dependencies.dependency[0].version.text()
}


{
final File bomOriginalFile = new File(basedir, 'bom/pom.xml')
assert bomOriginalFile.exists()

final bomOriginal = new XmlSlurper().parse(bomOriginalFile)
assert '0.0.1-SNAPSHOT' == bomOriginal.parent.version.text()
assert 1 == bomOriginal.parent.size()
assert 1 == bomOriginal.dependencyManagement.size()
assert 1 == bomOriginal.dependencyManagement.dependencies.size()
assert 1 == bomOriginal.dependencyManagement.dependencies.dependency.size()
assert '${project.version}' == bomOriginal.properties.'interpolated-project-version'.text()
assert '${project.version}' == bomOriginal.dependencyManagement.dependencies.dependency[0].version.text()
}

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

final flattenedBom = new XmlSlurper().parse(flattenedBomPomFile)
assert 0 == flattenedBom.parent.size()
assert '${project.version}' == flattenedBom.properties.'interpolated-project-version'.text()
assert '${project.version}' == flattenedBom.dependencyManagement.dependencies.dependency[0].version.text()
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.codehaus.mojo.flatten.its</groupId>
<artifactId>issue-382-properties-from-parent-are-not-interpolated</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>bom</artifactId>

<packaging>pom</packaging>

<properties>
<version.grpc>1.57.1</version.grpc>
<interpolated-version-springboot>${version.springboot}</interpolated-version-springboot>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${version.springboot}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<!-- gRPC/protobuf -->
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>${version.grpc}</version>
</dependency>

</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<pomElements>
<parent>remove</parent>
<properties>interpolate</properties>
<dependencyManagement>interpolate</dependencyManagement>
</pomElements>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.codehaus.mojo.flatten.its</groupId>
<artifactId>issue-382-properties-from-parent-are-not-interpolated</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
<version.springboot>3.1.2</version.springboot>
</properties>


<modules>
<module>bom</module>
</modules>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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

{
final File bomOriginalFile = new File(basedir, 'bom/pom.xml')
assert bomOriginalFile.exists()

final bomOriginal = new XmlSlurper().parse(bomOriginalFile)
assert 1 == bomOriginal.parent.size()
assert 1 == bomOriginal.dependencyManagement.size()
assert 1 == bomOriginal.dependencyManagement.dependencies.size()
assert 2 == bomOriginal.dependencyManagement.dependencies.dependency.size()
assert 'grpc-netty' == bomOriginal.dependencyManagement.dependencies.dependency[1].artifactId.text()
assert '${version.grpc}' == bomOriginal.dependencyManagement.dependencies.dependency[1].version.text()
assert 'spring-boot-dependencies' == bomOriginal.dependencyManagement.dependencies.dependency[0].artifactId.text()
assert '${version.springboot}' == bomOriginal.dependencyManagement.dependencies.dependency[0].version.text()
assert '${version.springboot}' == bomOriginal.properties.'interpolated-version-springboot'.text()
}
{
final File flattenedBomPomFile = new File(basedir, 'bom/.flattened-pom.xml')
assert flattenedBomPomFile.exists()

final flattenedBom = new XmlSlurper().parse(flattenedBomPomFile)

assert 1 == flattenedBom.dependencyManagement.size()
assert 1 == flattenedBom.dependencyManagement.dependencies.size()
assert 2 == flattenedBom.dependencyManagement.dependencies.dependency.size()
assert 'grpc-netty' == flattenedBom.dependencyManagement.dependencies.dependency[1].artifactId.text()
assert '1.57.1' == flattenedBom.dependencyManagement.dependencies.dependency[1].version.text()
assert 'spring-boot-dependencies' == flattenedBom.dependencyManagement.dependencies.dependency[0].artifactId.text()
assert '${version.springboot}' == flattenedBom.properties.'interpolated-version-springboot'.text()
assert '${version.springboot}' == flattenedBom.dependencyManagement.dependencies.dependency[0].version.text()

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.codehaus.mojo.flatten.its</groupId>
<artifactId>issue-382-with-extended_interpolate-project-version-from-parent-is-interpolated</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>bom</artifactId>

<packaging>pom</packaging>

<properties>
<interpolated-project-version>${project.version}</interpolated-project-version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.codehaus.mojo.flatten.its</groupId>
<artifactId>issue-382-with-extended_interpolate-project-version-from-parent-is-interpolated</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
<version.flatten-maven-plugin>1.0.0-gebit15</version.flatten-maven-plugin>
<interpolated-project-version>${project.version}</interpolated-project-version>
</properties>

<modules>
<module>bom</module>
</modules>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>${project.version}</version>
</dependency>

</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<pomElements>
<parent>remove</parent>
<properties>extended_interpolate</properties>
<dependencyManagement>extended_interpolate</dependencyManagement>
</pomElements>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit e386ef7

Please sign in to comment.