1

Our company has its own maven repository and we download maven dependencies from there. When i run maven clean test on command line, it does not generate target classes and test classes from java file.

Questions:

  1. The target > test-classes does not have the .class file generated when running mvn clean test.

Please help. Thanks.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>Automation-Framework</groupId>
  <artifactId>Automation-Framework</artifactId>
  <version>1.0.0-SNAPSHOT</version>


  <properties>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
  </properties>

  <build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M3</version>
                <configuration>
                    <includes>
                        <include>ChromeTestManager.java</include>

                    </includes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
        </plugin>

        </plugins>


    </pluginManagement>
  </build>

Commandline Output:

    [INFO] Scanning for projects [INFO] Deleting target folder 
    [INFO] --- maven-clean-plugin:2.6:resources (Default resources) @ Automation Framework 
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent 
    [INFO] --- maven-compiler-plugin:3.1:compile 
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent 
    [INFO] --- maven-resources-plugin:2.6:testResources [INFO] Copying 0 resource [INFO] --- maven-compiler-plugin:3.1testCompile [INFO] Nothing to compile - all classess up to date 
    [INFO] --- maven-surefire-plugin:3.0.0.-M3:test (default-test) @ Automation-Framework 
    [Info] Build Success
nicholas
  • 2,581
  • 14
  • 66
  • 104

2 Answers2

0

You could see in the Commandline Output you have pasted which says

[INFO] --- maven-resources-plugin:2.6:testResources [INFO] Copying 0 resource [INFO] --- maven-compiler-plugin:3.1testCompile [INFO] Nothing to compile - all classess up to date

You are missing the maven-resources-plugin in your build conifguration.

Add following to your <build><plguins> </plugins></build>

        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>copy-resources</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}</outputDirectory>
                        <resources>
                            <resource>
                                <directory>src/main/resources</directory>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

The resources files are copied from src/main/resources to target/classes.

EDIT: It doesnot help. There is 0 resources copying. The target - classess is generated but not target - test-classes.

nicholas
  • 2,581
  • 14
  • 66
  • 104
Manoj Kengudelu
  • 647
  • 1
  • 8
  • 21
  • 2
    The resources plugin is by default bound to the life cycle which means no need to add it manually...and the log shows that it is called only that no resources exist to copy... – khmarbaise Oct 09 '19 at 09:33
  • @khmarbaise you are right. I misunderstood it. Thank you! – Manoj Kengudelu Oct 09 '19 at 09:44
  • It doesn't help. No resource is copying after added the plugin. The target->classes is generated but not the target-test-classes. – nicholas Oct 09 '19 at 09:49
  • @nicholas hope you have already checked this https://stackoverflow.com/questions/6087690/eclipse-maven-junit-tests-not-compiled-when-running-them – Manoj Kengudelu Oct 09 '19 at 13:03
0

Rebuilding project fixed this issue for me.

Rsaleh
  • 77
  • 1
  • 10