You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Martin Testrot <ma...@d-velop.de> on 2007/07/23 09:56:11 UTC
plugin with resource dependency
Hello,
is it possible to load a non-java resource from the classpath with:
if (!new File(pResource).exists() &&
ClassLoader.getSystemResource(pResource) == null){
System.out.println (pResource + " not found!");
throw new FileNotFoundException("Description " +
pResource + " not found!");
}
from within a maven plugin ("maven-test-plugin") if this resource is
placed in a separate maven artefact ("example-resources")?
I tried this by placing the resource jar as dependency for the plugin
execution as follows, but had no success:
<build>
<plugins>
<plugin>
<groupId>example.maven.plugins</groupId>
<artifactId>maven-test-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>example</groupId>
<artifactId>example-resources</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
Greetings,
Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: plugin with resource dependency
Posted by Arnaud Bailly <ab...@oqube.com>.
"Martin Testrot" <ma...@d-velop.de> writes:
> Hello,
>
> is it possible to load a non-java resource from the classpath with:
>
> if (!new File(pResource).exists() &&
> ClassLoader.getSystemResource(pResource) == null){
> System.out.println (pResource + " not found!");
> throw new FileNotFoundException("Description " +
> pResource + " not found!");
> }
>
Hello,
Did you try using standard getResource instead of getSystemResource ?
According to jdk/docs/api/java/lang/ClassLoader.html, the
getSystemResource() methods looks only in the system classloader which
may not be the right class loader to look at:
if (!new File(pResource).exists() &&
ClassLoader.getResource(pResource) == null){
System.out.println (pResource + " not found!");
throw new FileNotFoundException("Description " + pResource
+ " not found!");
}
HTH
--
OQube < software engineering \ génie logiciel >
Arnaud Bailly, Dr.
\web> http://www.oqube.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org