0

I'm kinda new to maven and have encountered a problem that I can't solve on my own.

I've written a simple module to a big project that tracks git revision number, adds a timestamp and dumps these properties to a .properties file. This project is just a pom.xml file, no java classes, and one project.properties file. I wanted to add this module as a dependency to the main project pom.xml file, but it is rebuild only once (since Maven doesn't detect any changes it doesn't rebuild it again).

How do I force rebuild of this module everytime any module of the project is rebuilt? Can I do this in the project pom.xml file, or do I somehow set this in Jenkins? Or maybe I've approached this problem in a completely wrong way?

Here's the fragment of my pom.xml file:

<build>
  <plugins>
    <!-- enable ${timestamp} variable -->
    <plugin>
      <groupId>com.keyboardsamurais.maven</groupId>
      <artifactId>maven-timestamp-plugin</artifactId>
      <version>1.0</version>
      <configuration>
        <propertyName>timestamp</propertyName>
        <timestampPattern>dd.MM.yyyy HH:mm</timestampPattern>
      </configuration>
      <executions>
        <execution>
          <goals>
            <goal>create</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    <!-- enable JGit plugin -->
    <plugin>
      <groupId>ru.concerteza.buildnumber</groupId>
      <artifactId>maven-jgit-buildnumber-plugin</artifactId>
      <version>1.2.7</version>
      <executions>
        <execution>
          <id>git-buildnumber</id>
          <goals>
            <goal>extract-buildnumber</goal>
          </goals>
          <phase>initialize</phase>
        </execution>
      </executions>
    </plugin>
    <!--  write project properties to file  -->
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>properties-maven-plugin</artifactId>
      <version>1.0-alpha-2</version>
      <executions>
        <execution>
          <phase>prepare-package</phase>
          <goals>
            <goal>write-project-properties</goal>
          </goals>
          <configuration>
            <outputFile>${basedir}/target/classes/project.properties</outputFile>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

Cheers, Jony

Jan Siekierski
  • 409
  • 6
  • 14

1 Answers1

0

Okay, problem solved (thanks to deng from #maven on irc.codehaus.org). Right now i have the main pom and two modules: version-tracker and common. In the main pom I make a dependency on version-tracker, and in the common module's pom I add main pom as a parent (therefore common inherits dependency on version-tracker).

At this stage I run mvn clean package -pl :common -am and my project.properties file is updated every time. Thanks, deng :)

I still have some other problems, but this one is solved :)

Jan Siekierski
  • 409
  • 6
  • 14