flatten-maven-plugin icon indicating copy to clipboard operation
flatten-maven-plugin copied to clipboard

Lost package property when use inherited=true

Open rj-hwang opened this issue 6 years ago • 4 comments

Parent module:

<groupId>tech.simter</groupId>
<artifactId>simter-kv-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
  ...
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>flatten-maven-plugin</artifactId>
      <inherited>true</inherited>
      <executions>
        <execution>
          <id>flatten</id>
          <phase>process-resources</phase>
          <goals>
            <goal>flatten</goal>
          </goals>
          <configuration>
            <outputDirectory>${project.build.directory}</outputDirectory>
            <flattenedPomFilename>flattened-pom.xml</flattenedPomFilename>
            <updatePomFile>true</updatePomFile>
            <flattenMode>clean</flattenMode>
            <pomElements>
              <parent>resolve</parent>
              <properties>interpolate</properties>
              <dependencyManagement>keep</dependencyManagement>
              <dependencies>keep</dependencies>
              <pluginManagement>keep</pluginManagement>
              <name>resolve</name>
              <description>resolve</description>
              <profiles>remove</profiles>
            </pomElements>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

Childmodule:

<parent>
  <groupId>tech.simter</groupId>
  <artifactId>simter-kv-parent</artifactId>
  <version>1.0-SNAPSHOT</version>
</parent>
<artifactId>simter-kv-data</artifactId>
<packaging>jar</packaging>

After mvn install the child module, the flattened-pom.xml is:

<parent>
  <groupId>tech.simter</groupId>
  <artifactId>simter-kv-parent</artifactId>
  <version>0.2.0-SNAPSHOT</version>
  <relativePath>../simter-kv-parent</relativePath>
</parent>
<groupId>tech.simter</groupId>
<artifactId>simter-kv-data</artifactId>
<version>0.2.0-SNAPSHOT</version>

It losts packaging property.

rj-hwang avatar Jun 25 '18 02:06 rj-hwang

You know that omitting the packaging mean jar? So usually can omit the <packaging>..</packaging> tag if you like to have jar packaging which is the default...

khmarbaise avatar Jun 25 '18 05:06 khmarbaise

Yes, I know that. But keep <packaging>..</packaging> tag is more clear. When deploy my child module to bintray, bintray recognize it as a pom package if no <packaging>..</packaging> tag. May be that is bintray bug. But keep it is a good idea.

rj-hwang avatar Jun 25 '18 06:06 rj-hwang

The behavior comes from org.apache.maven.model.io.xpp3.MavenXpp3Writer (maven-model-3.2.5) which has

        if ( ( model.getPackaging() != null ) && !model.getPackaging().equals( "jar" ) )
        {
            serializer.startTag( NAMESPACE, "packaging" ).text( model.getPackaging() ).endTag( NAMESPACE, "packaging" );
        }

so I doubt this has any chance of being changed here.

lasselindqvist avatar Oct 28 '18 19:10 lasselindqvist

Considered as nice to have. But no priority. If someone considers this as important please provide a PR.

hohwille avatar Jan 14 '19 17:01 hohwille