Question

Given this complete Maven POM file that is meant to be used as a root POM for packaged (JAR, WAR, etc) projects or non packaged projects (for example web pages) that still should be tagged with a new release tag ...

<?xml version="1.0" encoding="ISO-8859-1"?>
<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>
  <name>Common Maven parent POM</name>
  <description>Maven parent POM for common POM properties for any type of project</description>
  <url>http://my.site.com</url>
  <groupId>com.my.site</groupId>
  <artifactId>mvn-common</artifactId>
  <version>0.12-SNAPSHOT</version>
  <packaging>pom</packaging>

  <properties>
    <eclipse.projectName>${project.name} ${project.version}</eclipse.projectName>
    <mvn.local.repo.root>file:///C:/.m2</mvn.local.repo.root>
    <scm.url.root>https://localhost/svn</scm.url.root>
    <scm.url.project>workspace/tools/maven/pom/mvn-common</scm.url.project>
    <scm.url.trunk>scm:svn:${scm.url.root}/${scm.url.project}/trunk</scm.url.trunk>
    <scm.url.tag>${scm.url.root}/${scm.url.project}/tags</scm.url.tag>
    <!-- Deploy makes only sense to packaged artifacts -->
    <skip.deploy>true</skip.deploy>
  </properties>

  <scm><developerConnection>${scm.url.trunk}</developerConnection></scm>

  <distributionManagement>
    <repository>
      <id>mvn.repo.releases</id>
      <url>${mvn.local.repo.root}/releases</url>
    </repository>
    <snapshotRepository>
      <id>mvn.repo.snapshots</id>
      <url>${mvn.local.repo.root}/snapshots</url>
    </snapshotRepository>
  </distributionManagement>

  <repositories>
    <!-- These must also be defined in the local settings as <servers> -->
    <repository>
      <id>mvn.repo</id>
      <url>${mvn.local.repo.root}/repo</url>
    </repository>
    <repository>
      <id>mvn.repo.releases</id>
      <url>${mvn.local.repo.root}/releases</url>
    </repository>
    <repository>
      <id>mvn.repo.snapshots</id>
      <url>${mvn.local.repo.root}/snapshots</url>
    </repository>
  </repositories>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>2.2.1</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>2.9</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.1</version>
          <configuration>
            <skip>${skip.deploy}</skip>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-eclipse-plugin</artifactId>
          <version>2.9</version>
          <configuration>
            <projectNameTemplate>${eclipse.projectName}</projectNameTemplate>
            <downloadSources>true</downloadSources>
            <downloadJavadocs>true</downloadJavadocs>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>2.4.2</version>
        <configuration>
          <tagBase>${scm.url.tag}</tagBase>
        </configuration>
      </plugin>
    </plugins>
    <extensions>
      <extension>
        <groupId>org.apache.maven.wagon</groupId>
         <artifactId>wagon-ftp</artifactId>
         <version>2.5</version>
      </extension>
    </extensions>
  </build>

</project>

... can I not get the property true overridden on the command line when I execute

mvn release:prepare && mvn -Dskip.deploy=false release:perform

The property is used to set the configuration value for the maven-deploy-plugin to skip deploy as default (which should be overridden in a sub POM for packaged projects) and I believe that it should be possible to override a user defined property like this but not a Maven property which would be maven.deploy.skip in this case.

The release works fine in that it properly creates a new tagged version of the POM in the SVN repository but I can't get the maven-deploy-plugin to recognise the value for the property set on the command line

[INFO] [INFO] --- maven-deploy-plugin:2.8.1:deploy (default-deploy) @ mvn-common ---
[INFO] [INFO] Skipping artifact deployment
[INFO] [INFO] ------------------------------------------------------------------------

Am I overlooking something here? A bug somewhere here could be an explanation but I have not found any reported that applies when I have searched around. It would be great if someone could see anything that looks incorrect or give me at tip on what to try next.

Was it helpful?

Solution

I eventually found the answer myself in Properties lost during Maven release:perform where the answer explained that there is a forked process for release so to get the command line property recognised and have it to override the property set in the POM must it be passed through as

-Darguments=-D...

and the command I must use then looks like this

mvn release:prepare && mvn release:perform -Darguments=-Dskip.deploy=false

Thanks to myself for answering this question and thanks Stephen Connolly that answered the other thread. It is just sad that I didn't find that answer until know in all the noise that come up when I try to google for it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top