You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by Richard Eckart de Castilho <ri...@gmail.com> on 2013/06/12 10:03:18 UTC

Re: svn commit: r1492003 - /uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java

I've had various issues with File <-> URL conversion. The best way, so far, appears to be:

File -> URL: new File("myfile.txt").toURI().toURL() (possibly with an getAbsoluteFile() in between)
URL -> File: new File(aUrl.toURI())

Other approaches appear to have problems with URL-encoding, in particular with spaces. Problems often start cropping up when the builds run in a Jenkins where the Jobs has spaces in the name.

-- Richard

Am 12.06.2013 um 00:46 schrieb schor@apache.org:

> Author: schor
> Date: Tue Jun 11 22:45:53 2013
> New Revision: 1492003
> 
> URL: http://svn.apache.org/r1492003
> Log:
> [UIMA-2983] make import setLocation argument be a proper form for a URL to an absolute file location.
> 
> Modified:
>    uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java
> 
> Modified: uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java
> URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java?rev=1492003&r1=1492002&r2=1492003&view=diff
> ==============================================================================
> --- uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java (original)
> +++ uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java Tue Jun 11 22:45:53 2013
> @@ -134,7 +134,7 @@ public class JCasGenMojo
>         boolean contextDelta = false;
>         for (String descriptorLocation : ds.getIncludedFiles()) {
>             Import imp = new Import_impl();
> -            imp.setLocation(new File(ds.getBasedir(), descriptorLocation).getAbsolutePath());
> +            imp.setLocation("file:///" + (new File(ds.getBasedir(), descriptorLocation)).getAbsolutePath());
>             imports.add(imp);
> 
>             contextDelta |= this.buildContext
> 
> 


Re: svn commit: r1492003 - /uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java

Posted by Marshall Schor <ms...@schor.com>.
good point.  I'll change this to use the suggested File -> URL.

Thanks! -Marshall
On 6/12/2013 4:03 AM, Richard Eckart de Castilho wrote:
> I've had various issues with File <-> URL conversion. The best way, so far, appears to be:
>
> File -> URL: new File("myfile.txt").toURI().toURL() (possibly with an getAbsoluteFile() in between)
> URL -> File: new File(aUrl.toURI())
>
> Other approaches appear to have problems with URL-encoding, in particular with spaces. Problems often start cropping up when the builds run in a Jenkins where the Jobs has spaces in the name.
>
> -- Richard
>
> Am 12.06.2013 um 00:46 schrieb schor@apache.org:
>
>> Author: schor
>> Date: Tue Jun 11 22:45:53 2013
>> New Revision: 1492003
>>
>> URL: http://svn.apache.org/r1492003
>> Log:
>> [UIMA-2983] make import setLocation argument be a proper form for a URL to an absolute file location.
>>
>> Modified:
>>    uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java
>>
>> Modified: uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java
>> URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java?rev=1492003&r1=1492002&r2=1492003&view=diff
>> ==============================================================================
>> --- uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java (original)
>> +++ uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java Tue Jun 11 22:45:53 2013
>> @@ -134,7 +134,7 @@ public class JCasGenMojo
>>         boolean contextDelta = false;
>>         for (String descriptorLocation : ds.getIncludedFiles()) {
>>             Import imp = new Import_impl();
>> -            imp.setLocation(new File(ds.getBasedir(), descriptorLocation).getAbsolutePath());
>> +            imp.setLocation("file:///" + (new File(ds.getBasedir(), descriptorLocation)).getAbsolutePath());
>>             imports.add(imp);
>>
>>             contextDelta |= this.buildContext
>>
>>
>