Maven resource filtering works... every other build?

In my POM I have [1]:

<version>1.0-${build.number}</version>

[...]

<build>
  <resources>
    <resource>
    <filtering>true</filtering>
    <directory>src/main/resources/</directory>
    <includes>
      <include>*</include>
    </includes>
    </resource>
    <resource>
    <filtering>false</filtering>
    <directory>src/main/resources/</directory>
    <includes>
      <include>**/*</include>
    </includes>
    </resource>
  </resources>
</build>

Then in src/main/resources/version.properties I have:

my.project.version = ${project.version}

This works perfectly under mvn/teamcity.  I have teamcity configured with build number as "{0}-r{build.vcs.number}" and it invokes mvn with -Dbuild.number=<build.number>.  Great!

However, in IDEA things don't fare so well.

1) IDEA seems to only do resource filtering every other build.  That is: the first time I build, the keyword is not filtered (I look in target directory to check); if I build again, and it is.  The third time, it is not, etc...   I've tried resetting caches, reloading poms, etc.

2) I can't figure out how to tell idea to define build.number.  I've tried in Settings > Maven > Runner > Properties but this doesn't seem to affect filtering?

3) Finally, resource filtering doesn't seem to recognize that files haven't changed.  I have a lot of data files in my resources dir, and copying is by far the longest step of the build, and they don't change very often.  Perhaps there can be an option to check the timestamp or something and not copy unmodified files?



Thanks!

-c


[1] yes, I know this is somewhat unorthodox; we use this in order to have teamcity do automatic deployment to our web environment.  If anyone has a better way to do this, I'd be happy to hear it.

4 comments
Comment actions Permalink

Hi, Christopher,

What IDEA version do you use? This problem houlw have been fixed in 8.1.2.
Please try it and let me know if it helpsю

Thanks,
Anton Makeev

0
Comment actions Permalink

We're still seeing this problem in 8.1.2, namely: resource filtering happens only every second build.

How can I help debug?

Thanks,

-c

0
Comment actions Permalink

Hi, Christopher,

Could you please firtly try 8.1.3? If the problem remains please try to create a sample project.

Thanks,
Anton Makeev

0
Comment actions Permalink

Hi Anton.

I still can reproduce it on IDEA 9.0.2
Is there some workaround for this issue?
Could you please provide some information about steps for fixing this issue?

0

Please sign in to leave a comment.