Question

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...

Was it helpful?

Solution

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top