[forge-users] Using template files from Jar

forge-users at lists.jboss.org forge-users at lists.jboss.org
Mon Feb 16 13:07:24 EST 2015


Hi, 

I am trying to use a template I put in src/main/resources

BTW,  First, it was not included in the addon Jar built :/
I had to modify the pom like this 

<build>
*<resources>*
*    <resource >*
*       <directory>${basedir}/src/main/resources</directory>*
*     </resource>*
*  </resources>*
  <finalName>ProjectName</finalName>

to have it included.


Now, I am trying to use it but how do I get a FileResource from the name of a file in the jar ?
I tried several options like 

But I get an error message saying the file does not exist as the path included is wrong
BUT the file object within the FileResource is ok

The wrong path is prefixed with the project root !
So it looks like    

java.lang.IllegalArgumentException: Template does not exist: d:\projects\myproject\*file:\C:\Users\Me\.forge*\addons\\fr-company-addons-ADDONS213b-1-0-1-SNAPSHOT\ADDONS213b-1.0.1-SNAPSHOT-forge-addon.jar!\voila.txt

In the debugger this is the value displayed for the fileresource I create (its toString I presume) although the toString of its file attribute is correct.

|  |  | URL voilaURL = getClass().getClassLoader().getResource("voila.txt");
File f = new File(voilaURL.getFile()) ;
FileResource<?> resource = ressfactory.create( f).reify(FileResource.class); // KO
FileResource resource =  rfactory.create(new File(voilaURL.toURI()) ).reify(FileResource.class); // KO |

I'm using version2.13.1 Final

Any idea ?

Thanks

Posted by forums
Original post: https://developer.jboss.org/message/918940#918940



More information about the forge-users mailing list