Ignoring test source from Maven Compile

I configured my maven build to ignore my directory test

, but my maven compile build process still compiles the directory source test

:

 [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @   WEBSITE-frontend ---
 [debug] execute contextualize
 [INFO] Using 'UTF-8' encoding to copy filtered resources.
 [INFO] Copying 17411 resources
 [INFO] 
 [INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ WEBSITE-  frontend ---
 [INFO] Changes detected - recompiling the module!
 [INFO] Compiling 16 source files to C:\Users\XXXX XXXXX\git\WEBSITE\WEBSITE-web\web_web\target\classes
 [WARNING] bootstrap class path not set in conjunction with -source 1.6
 [WARNING] /C:/Users/XXXX XXXXX/git/WEBSITE/WEBSITE- web/web_web/src/main/java/com/WEBSITE/site/controllers/CurrencyController.java:   [34,41] found raw type: java.util.ArrayList
 missing type arguments for generic class java.util.ArrayList<E>
 [WARNING] /C:/Users/XXXX XXXXX/git/WEBSITE/WEBSITE-web/web_web/src/main/java/com/WEBSITE/site/controllers/CurrencyController.java: [36,24] found raw type: java.util.ArrayList
 missing type arguments for generic class java.util.ArrayList<E>
  [WARNING] /C:/Users/XXXX XXXXX/git/WEBSITE/WEBSITE-web/web_web/src/main/java/com/WEBSITE/site/overrides/QRCodeServletContext.java:[21,31] redundant cast to java.lang.String
 [INFO] 
 [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources)  @ WEBSITE-frontend ---
 [debug] execute contextualize
 [INFO] Using 'UTF-8' encoding to copy filtered resources.
 [INFO] Copying 1 resource
 [INFO] 
 [INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ WEBSITE-frontend ---
 [INFO] Changes detected - recompiling the module!
 [INFO] Compiling 2 source files to C:\Users\XXXX XXXXX\git\WEBSITE\WEBSITE-web\web_web\target\test-classes
 [INFO] -------------------------------------------------------------
 [WARNING] COMPILATION WARNING : 
 [INFO] -------------------------------------------------------------
 [WARNING] bootstrap class path not set in conjunction with -source 1.6
 [INFO] 1 warning
 [INFO] -------------------------------------------------------------
 [INFO] -------------------------------------------------------------
 [ERROR] COMPILATION ERROR : 
 [INFO] -------------------------------------------------------------
 [ERROR] /C:/Users/XXXX XXXXX/git/WEBSITE/WEBSITE-web/web_web/src/test/java/com/WEBSITE/site/integration/RegistrationControllerIntegrationTest.java:[5,41] package com.fatboyindustrial.gsonjodatime does not exist
 [ERROR] /C:/Users/XXXX XXXXX/git/WEBSITE/WEBSITE-web/web_web/src/test/java/com/WEBSITE/site/integration/RegistrationControllerIntegrationTest.java:[6,23] package com.google.gson does not exist
 [ERROR] /C:/Users/XXXX XXXXX/git/WEBSITE/WEBSITE-web/web_web/src/test/java/com/WEBSITE/site/integration/RegistrationControllerIntegrationTest.java:[7,23] package com.google.gson does not exist

      

This is my POM.xml:

 <profile>
        <id>qa</id>
        <build>
            <resources>
                <resource>
                    <directory>src</directory>
                    <excludes>
                        <exclude>test/**</exclude>
                    </excludes>
                </resource>
            </resources>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.1</version>
                    <executions>
                        <execution>
                            <id>echo</id>
                            <phase>test</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <configuration>
                                <tasks>
                                    <echo>Using QA environment</echo>
                                </tasks>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>com.github.eirslett</groupId>
                    <artifactId>frontend-maven-plugin</artifactId>
                    <version>0.0.20</version>
                    <configuration>
                        <workingDirectory>src/main/webapp/resources/js</workingDirectory>
                    </configuration>
                    <executions>
                        <execution>
                            <id>install node and npm</id>
                            <phase>generate-resources</phase>
                            <goals>
                                <goal>install-node-and-npm</goal>
                            </goals>
                            <configuration>
                                <nodeVersion>v0.12.2</nodeVersion>
                                <npmVersion>1.4.6</npmVersion>
                            </configuration>
                        </execution>
                        <execution>
                            <id>npm install</id>
                            <goals>
                                <goal>npm</goal>
                            </goals>
                            <configuration>
                                <arguments>install --production</arguments>
                            </configuration>
                        </execution>
                        <execution>
                            <id>bower install</id>
                            <goals>
                                <goal>bower</goal>
                            </goals>
                            <configuration>
                                <arguments>install --production</arguments>
                            </configuration>
                        </execution>
                        <execution>
                            <id>grunt build</id>
                            <goals>
                                <goal>grunt</goal>
                            </goals>
                            <phase>generate-resources</phase>
                            <configuration>
                                <arguments>qa</arguments>
                                <srcdir>src/main/webapp/resources/js</srcdir>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.5</version>
                    <configuration>
                        <warSourceExcludes>**/node/,**/node_modules/, **/AdminLTE-master.zip, **/template_46918_iGoLso5E7rLw7cZ6WGfG.zip</warSourceExcludes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.0</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                        <compilerArgument>-Xlint:all</compilerArgument>
                        <showWarnings>true</showWarnings>
                        <showDeprecation>true</showDeprecation>
                        <excludes>
                            <exclude>src/test/**</exclude>
                            <exclude>target/test-classes/**</exclude>
                        </excludes>
                        <testExcludes>
                            <testExclude>src/test/**</testExclude>
                            <testExclude>target/test-classes/**</testExclude>
                        </testExcludes>
                    </configuration>
                </plugin>
            </plugins>
            <plugins>
        <plugin>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <additionalProjectnatures>
                    <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                </additionalProjectnatures>
                <additionalBuildcommands>
                    <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                </additionalBuildcommands>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>true</downloadJavadocs>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.3</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals><goal>copy</goal></goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.mortbay.jetty</groupId>
                                <artifactId>jetty-runner</artifactId>
                                <version>7.4.5.v20110725</version>
                                <destFileName>jetty-runner.jar</destFileName>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
        </plugin>
       </build>
    </profile>

      

+3


source to share


2 answers


If you don't want to collect tests on a consistent basis, delete them. You can always bring them back from version control later.

If you just want not to compile tests right now, use "mvn compile" instead of mvn or "mvn -DskipTests".



There is no doubt about some easy Pom editing way to do any of these things, but if you are already using ant -run-plugin to do some custom tests, by the time you get this you could probably delete and rewrite the tests ...

And even if it doesn't, you'll be damned by all programmers who have to spend 30 minutes figuring out why tests don't work ...

+2


source


You don't have to add your folder src

as a resource, just your actual resource directory, which is by convention src/main/resources

(or if you have resources in src/main/java

, add it too).



0


source







All Articles