Skip to content

requireFilesContent

Wisen edited this page Jan 26, 2014 · 4 revisions

Enforces that the specified list of files exist and are containing the specified content. The rule checks the file line by line by verifying the content using the method: line.contains(content).

Supported parameters:

  • message - an optional message to the user if the rule fails.
  • files - a list of files to check.
  • content - the content that must exist in the list of files.
  • allowNulls - if null files should be allowed. If allowed, they will be treated as if they do exist. Default is false.

Sample plugin configuration:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>1.0</version>
        <executions>
          <execution>
            <id>enforce</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <!-- Checks that the String "AutoUpdate:true" is in src/foo/bar and src/foo/baz -->
                <requireFilesContent>
                  <files>
                    <file>src/foo/bar</file>
                    <file>src/foo/baz</file>
                  </files>
                  <content>AutoUpdate:true</content>
                </requireFilesContent>
              </rules>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>com.ceilfors.maven.plugin</groupId>
            <artifactId>enforcer-rules</artifactId>
            <version>1.0</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
  [...]
</project>