1

I have a mock java class, by default I would like to exclude it from the mvn install command. But when I'm working on my local machine I would like to include it in my .war launching by command line something like: mvn clean install -DsomeProperty=true

I added this plugin to my profile:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <excludes>
                        <exclude>**/filter/MockFilter.java</exclude>
                    </excludes>
                        <skip>${someProperty}</skip>
                </configuration>
            </plugin>

But the class is always skipped. How can I include it? I give a try to this and this, but nothing worked.

Accollativo
  • 1,537
  • 4
  • 32
  • 56
  • 1
    Did you look at this https://stackoverflow.com/questions/166895/different-dependencies-for-different-build-profiles I think it could help you – T.K Jan 18 '23 at 09:30
  • And what if you get rid of the and you add an and based on your propertie you include or exlude your MockFilter.java? – T.K Jan 18 '23 at 09:45
  • @T.K by default with mvn install I would like to exclude MockFilter.java – Accollativo Jan 18 '23 at 09:47
  • the profile is a solution, but I already have 2 different profiles, and in this way I have to duplicate a very long profile to add to the new profile only this plugin, it looks too verbose. – Accollativo Jan 18 '23 at 11:05
  • Maybe this : https://stackoverflow.com/questions/14430122/how-to-define-conditional-properties-in-maven but I'm not sure if what you ask is really possible – T.K Jan 18 '23 at 12:42

0 Answers0