3

I'm porting a project form Maven 2 to Maven 3. I've taken the opportunity to also update the version of some plugins, namely maven-compiler-plugin, from 2.1 to 3.0, and maven-resources-plugin, to 2.6.

I have an interface under resources as such:

public interface Version {
  public static final String VERSION = "${project.version}";
}

And in my pom.xml, under build, I have:

<resources>
  <resource>
    <directory>src/main/resources</directory>
    <filtering>true</filtering>
  </resource>
</resources>

This was previously working. But since the upgrade to Maven 3, compilation fails with not being able to find Version.

It seems obvious that it's not compiling Version or not including it in the classpath.

Is there some change with Maven 3 or latest versions of maven-compiler-plugin that might affect this? From reading the documentation nothing changed...

halfwarp
  • 1,780
  • 5
  • 24
  • 41
  • 4
    How did that work in Maven 2? How did you pom look like? Cause usually no java file will be compiled which is in src/main/resources. The question is why do you need such things? You have a verison which is part of the artifact coordinates? – khmarbaise Jan 04 '13 at 16:46
  • As posted, you don't give enough information. You're doing some form of code generation, but it's unclear how you're doing it (because simply copying a resource with transform won't do it). I suggest running both old and new versions with `-X` to see where they differ. – parsifal Jan 04 '13 at 17:33
  • Actually the issue here is with maven-compiler-plugin 3.0. It works fine with 2.1. – halfwarp Jan 04 '13 at 17:35

1 Answers1

3

You have to specify the target folder to something like below. Currently if you look in your target folder you probably have a Version.java file in there. By adding the targetPath it will put the filtered .java file into your src/java folder and will compile it to your target folder.

<resource>
    <directory>src/main/resources</directory>
    <filtering>true</filtering>
     <includes>
       <include>**/*.java</include>
    </includes>
    <targetPath>${basedir}/src/main/java/</targetPath>
</resource>
Manuel Quinones
  • 4,196
  • 1
  • 19
  • 19