Dean
Dean

Reputation: 887

Ignoring Test Source from Maven Compile

I've configured my maven build to disregard my test directory but, my maven build process compile is still compiling the test directory source:

 [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>

Upvotes: 3

Views: 2020

Answers (2)

soru
soru

Reputation: 5526

If you want to not compile the tests on an ongoing basis, delete them. You can always bring them back from version control at a later date.

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

There's no doubt some simple way to edit the Pom to do either of those things, but given you are already using ant-run-plugin to do some non-standard test-related stuff, by the time you get that working you probably could have deleted and rewritten the tests.

And even if not, you would be cursed by every maintenance programmer who has to spend 30 minutes working out why the tests aren't running...

Upvotes: 2

meskobalazs
meskobalazs

Reputation: 16041

You should not add your src folder as a resource, only your actual resource directory, which is by convention src/main/resources (or if you have resources in src/main/java, add it too).

Upvotes: 0

Related Questions