0

Anyone know how to filter text outside of quotes in a java file via the resource plugin?

I have a resource filter set with a delimiter of @ but I only see the version.designator replaced. This makes me think there's a trick to filtering text outside of quotes in a java file.

Thanks for the help

Peter

Pom

  <plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <executions>
      <execution>
        <id>update Version file from pom</id>
        <phase>generate-resources</phase>
        <goals><goal>copy-resources</goal></goals>
        <configuration>
          <overwrite>true</overwrite>
          <delimiters>
            <delimiter>@</delimiter>
          </delimiters>
          <outputDirectory>${project.build.sourceDirectory}/</outputDirectory>
          <resources>
            <resource>
              <directory>${project.basedir}/resources</directory>
              <filtering>true</filtering>
            </resource>
          </resources>
        </configuration>
      </execution>
    </executions>
  </plugin>

Source

public final class Version {
  public static final int MAJOR_VERSION = @version.major@;
  public static final String DESIGNATOR_VERSION = "@version.designator@";

Result

public final class Version {
  public static final int MAJOR_VERSION = @version.major@;
  public static final String DESIGNATOR_VERSION = "BETA";
Peter Kahn
  • 12,364
  • 20
  • 77
  • 135
  • You don't want to do that, and filtering parts of a file isn't even possible. What you want is typically solved by filtering a resources file, _not_ the Java sources themselves, like a properties file, that the Java code would read at start-up. – Tunaki Sep 21 '16 at 23:18
  • That makes sense. – Peter Kahn Sep 22 '16 at 00:09

0 Answers0