Home > Blockchain >  Maven: How to exclude a directory pattern?
Maven: How to exclude a directory pattern?

Time:05-19

I have a Maven Java project. I want to tell Maven to ignore compiling any directories whose name starts with ".", e.g., given this directory structure:

src/main/java/com/stuff
   |
   .skipThisDirectory1
      |
      anotherDirectory1
   |
   useThisDirectory1
   |
   .skipThisDirectory2
      |
      anotherDirectory2
   |
   useThisDirectory2

...I would only want Maven to compile what is in useThisDirectory1, useThisDirectory2, and their subdirectories.

I see all over the internet how to skip compiling a specific directory, but I can't find a way to skip a directory name pattern (like all directories starting with a dot).

CodePudding user response:

I would suggest to try something like this:

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.10.1</version>
      <configuration>
        <excludes>
          <exclude>**/.*/**</exclude>
        </excludes>
      </configuration>
    </plugin>
  • Related