Are you not using a flattened chest?

This is a multi-module maven project. I have included flatten-maven-plugin in my parent pom

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>flatten-maven-plugin</artifactId>
    <version>1.0.0-beta-2</version>
    <configuration>
    </configuration>

      

defined scl_version property in parent pom and used $ {scl_version} in child pom. The value is 0.0.1 .

when i run mvn flatten: flatten

It generates a warning: [WARNING] 'version' contains an expression, but must be constant.

The compact pom is created in all modules including parent and all children.

The compressed pom has a property value in the version tag of the child pom. But when I give, mvn install, it still warns that the version should be persistent, but that's an expression.

http://mojo.codehaus.org/flatten-maven-plugin/plugin-info.html

But the documentation says:

This MOJO implements an anti-aliasing target that generates a flattened POM and potentially updates the POM file so that the current MavenProject file points to the flattened POM instead of the original pom.xml file. The compressed POM is a scaled-down version of the original POM with an emphasis on containing only important information for its consumption. Therefore, information that is only required for maintenance by developers and the creation of project artifact (s) section.

so when I install mvn it shouldn't generate a warning.

mvn install and mvn flatten: flatten both generate this warning:

[WARNING] 'version' contains an expression, but must be constant.

I'm missing something, isn't this used by flattened-pom.xml. I need to indicate something.

PARENT POM:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.a.b</groupId>
<artifactId>ABC</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<name>ABC</name>
<modules>
    <module>Resources</module>
    <module>ResourceTree</module>
    <module>Service</module>
    <module>Transport</module>
<module>Branding</module>

      

property tag starts

<scl_version>0.0.1</scl_version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
<karaf.deploy.build.folder>${env.KARAF_BASE}/deploy</karaf.deploy.build.folder>

      

ends here property tag

<profiles>
    <profile>
        <id>code_coverage</id>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.7.0.201403182114</version>
                    <executions>
                        <execution>
                            <id>default-instrument</id>
                            <goals>
                                <goal>instrument</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.12.2</version>
                    <configuration>
                        <systemPropertyVariables>
                            <jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
                        </systemPropertyVariables>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

<build>
    <plugins>
    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>flatten-maven-plugin</artifactId>
    <version>1.0.0-beta-2</version>
    <configuration>
    <flattenMode>ossrh</flattenMode>
    <updatePomFile>true</updatePomFile>
    </configuration>
    <executions>
      <!-- enable flattening -->
      <execution>
        <id>flatten</id>
        <phase>process-resources</phase>
        <goals>
          <goal>flatten</goal>
        </goals>
      </execution>
      <!-- ensure proper cleanup -->
      <execution>
        <id>flatten.clean</id>
        <phase>clean</phase>
        <goals>
          <goal>clean</goal>
        </goals>
      </execution>
    </executions>
  </plugin>


        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler-plugin.version}</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
    </dependency>
    <dependency>
        <groupId>org.jacoco</groupId>
        <artifactId>org.jacoco.agent</artifactId>
        <classifier>runtime</classifier>
        <version>0.7.0.201403182114</version>
        <scope>test</scope>
    </dependency>
</dependencies>
</project>

      

generated flattened pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.a.b</groupId>
  <artifactId>ABC</artifactId>
  <version>0.0.1</version>
  <packaging>pom</packaging>
  <name>ABC</name>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Maven Repository Switchboard</name>
      <url>http://repo1.maven.org/maven2</url>
    </repository>
  </repositories>
</project>

      

the property is used in the grand grand child pom (for a trail, if it succeeds, no warning, I can have it all over the place):

<groupId>org.a.b</groupId>
<artifactId>CD<artifactId>
<version>${scl_version}</version>
<packaging>bundle</packaging>

<name>CD</name>
<description>OSGi bundle project.</description>

      

Also, it has a plugin dependencies plugin and some dependencies. In this child's squished pom, this version is allowed 0.0.1

+3


source to share


1 answer


I sent the developer of this plugin to the developer and his answer:

The warning comes from Maven based on the original pom.xml Before Maven starts executing, a buildplan will be generated and the pom.xml parsed, triggering this warning. Planetary plugin is later in the process of creating a flattened pom.xml and making sure the file is installed / deployed. Your problem cannot be fixed by plugin-maven-plugin and will not be fixed in Maven Core (warning exists for good reason).



So he answers the question very well.

+5


source







All Articles