我要求在运行Maven构建时排除某些Java源文件作为最终构建的一部分进行编译 .
我在基于Spring Boot的项目中使用Spring Boot Maven插件 .
我正在寻找一种方法来排除Java源文件被编译,并且相应的Junit测试类也需要在构建时从最终构建中排除 .
有没有办法使用Spring Boot Maven插件实现相同的功能?
我通过配置maven-compiler-plugin实现了这个目的:
的pom.xml
... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <excludes> <exclude>com/example/compileexclude/ExcludedJavaClass.java</exclude> </excludes> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> ...
作为参考,您可以看到所有可用的配置选项here .
1 回答
我通过配置maven-compiler-plugin实现了这个目的:
的pom.xml
作为参考,您可以看到所有可用的配置选项here .