You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Inred <in...@gmail.com> on 2013/06/19 10:14:01 UTC

mvn test can't find the resource but mvn exec:exec running is ok

my pom.xml

   <groupId>org.codehaus.mojo</groupId>
   <artifactId>exec-maven-plugin</artifactId>
   <version>1.2.1</version>
   <configuration>
      <executable>java</executable>
      <arguments>
    <argument>-classpath</argument>

    <classpath/>
    <argument>helper.BaseCheckerTest</argument>
      </arguments>
</configuration>

</plugin>

            <plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>exec-maven-plugin</artifactId>
   <version>1.2.1</version>
   <executions>
<execution>
 <phase>process-test-classes</phase>
 <goals>
  <goal>java</goal>
 </goals>
 </execution>
   </executions>
 <configuration>
  <mainClass>helper.BaseCheckerTest</mainClass>
  <classpathScope>runtime</classpathScope>

  <args>
     <arg>-classpath</arg>
            <classpath/>

  </args>
 </configuration>

</plugin>



it's ok when
c:\>mvn  exec:exec

but it report that can't find the resouce file config.properties when i do
c:\>mvn test

Class BaseCheckerTest{
static {
 try {
 prop = new Properties();
prop.load(ClassLoader.class.getResourceAsStream("/config.properties"));
 } catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
 }
}



c:\>mvn --version
Apache Maven 3.0.4 (r1232337; 2012-01-17 16:44:56+0800)
Maven home: C:\Downloads\apache-maven-3.0.4\bin\..
Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
Java home: C:\Program Files (x86)\Java\jdk1.6.0_24\jre

Re: mvn test can't find the resource but mvn exec:exec running is ok

Posted by Dennis Lundberg <de...@apache.org>.
Hi

Where in your source tree is the file config.properties located?

Also, it looks like you are feeding exec-maven-plugin an empty classpath in
<args></args>.

On Wed, Jun 19, 2013 at 10:14 AM, Inred <in...@gmail.com> wrote:

> my pom.xml
>
>    <groupId>org.codehaus.mojo</groupId>
>    <artifactId>exec-maven-plugin</artifactId>
>    <version>1.2.1</version>
>    <configuration>
>       <executable>java</executable>
>       <arguments>
>     <argument>-classpath</argument>
>
>     <classpath/>
>     <argument>helper.BaseCheckerTest</argument>
>       </arguments>
> </configuration>
>
> </plugin>
>
>             <plugin>
>    <groupId>org.codehaus.mojo</groupId>
>    <artifactId>exec-maven-plugin</artifactId>
>    <version>1.2.1</version>
>    <executions>
> <execution>
>  <phase>process-test-classes</phase>
>  <goals>
>   <goal>java</goal>
>  </goals>
>  </execution>
>    </executions>
>  <configuration>
>   <mainClass>helper.BaseCheckerTest</mainClass>
>   <classpathScope>runtime</classpathScope>
>
>   <args>
>      <arg>-classpath</arg>
>             <classpath/>
>
>   </args>
>  </configuration>
>
> </plugin>
>
>
>
> it's ok when
> c:\>mvn  exec:exec
>
> but it report that can't find the resouce file config.properties when i do
> c:\>mvn test
>
> Class BaseCheckerTest{
> static {
>  try {
>  prop = new Properties();
> prop.load(ClassLoader.class.getResourceAsStream("/config.properties"));
>  } catch (Exception e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>  }
> }
>
>
>
> c:\>mvn --version
> Apache Maven 3.0.4 (r1232337; 2012-01-17 16:44:56+0800)
> Maven home: C:\Downloads\apache-maven-3.0.4\bin\..
> Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
> Java home: C:\Program Files (x86)\Java\jdk1.6.0_24\jre
>
> --
> Dennis Lundberg