0

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

KenK
  • 263
  • 2
  • 10
  • First question: Why do you like to skip that ? Simplest way is not to put something into the appropriate directories...? BTW: Why do those directories start with a `.` because that would mean they are hidden directories on linux and no valid packaged ? – khmarbaise May 17 '22 at 20:16
  • The project we are on requires us to use a variation management tool that requires these dotted directories. The way the tool works, those directories have Java code in them. For various reasons, we must not compile that code. That is a constraint that we have to work with. – KenK May 17 '22 at 20:42
  • If you don't need to compile that remove it from there .... if tools does that the tool is doing many things wrong... This should break every IDE... – khmarbaise May 17 '22 at 20:56
  • We cannot remove it. It is a constraint we have to live with. – KenK May 17 '22 at 21:35

1 Answers1

1

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>
khmarbaise
  • 92,914
  • 28
  • 189
  • 235