You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Zilvinas Vilutis <ci...@gmail.com> on 2011/04/20 21:45:14 UTC

java file path in exec:java

Hi maven users!

I'm trying to execute a java command and pass a path to a file as an argument:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <configuration>
    <executable>java</executable>
    <workingDirectory>${project.build.outputDirectory}</workingDirectory>
    <classpathScope>runtime</classpathScope>
    <arguments>
      <argument>-c
${project.build.outputDirectory}${file.separator}orm.properties</argument>
    </arguments>
    <mainClass>com.company.deploy.product.AutomatedProductDeploy</mainClass>
  </configuration>
</plugin>

And I'm using maven properties to construct the filename:
${project.build.outputDirectory}${file.separator}orm.properties

Unfortunately, I'm getting an exception from the java class I'm running:

Caused by: java.io.FileNotFoundException:  C:\<path to my
project>\target\classes\orm.properties (The filename, directory name,
or volume label syntax is incorrect)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:106)

Most likely the it is using the argument and does not escape slashes
to new java.io.File( filePath )

As I don't have access to source code of the class - is there any way
to enforce maven use unix style path generation on windows? ( change
slashes to "/" )

I tried to override the ${file.separator} property - but it seems to
be read-only and doesn't help.

Any ideas?

Thank you!

Žilvinas Vilutis

E-mail:   cikasfm@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: java file path in exec:java

Posted by "Asmann, Roland" <Ro...@adesso.at>.
It seems gmaven might be able to help you out here:

http://maven.40175.n5.nabble.com/Exporting-Ant-properties-to-Maven-td510023.html#a510117
http://pastebin.com/XsAdbbcY

Roland


On 21.04.2011 12:14, Asmann, Roland wrote:
> I see your problem now.
>
> Would it be a problem for you to use ant to run the program instead of
> the exec-plugin? Then you could have Ant convert the path:
>
> <pathconvert targetos="unix" property="unix-path">
> <path location="${project.build.outputDirectory}" />
> </pathconvert>
>
> Now if there was a way to have this property available in Maven, you
> could use the exec-plugin, but I believe you can't access this property
> (${unix-path}) in Maven...
>
> Roland
>
>
> On 21.04.2011 1:17, Zilvinas Vilutis wrote:
>  > yes, I can do that, however "${project.build.outputDirectory}" still
>  > generates "C:\folder1\folder2\..." & etc :)
>  >
>  > Žilvinas Vilutis
>  >
>  > Mobile: (+370) 652 38353
>  > E-mail: cikasfm@gmail.com
>  >
>  >
>  >
>  > On Wed, Apr 20, 2011 at 2:57 PM, Asmann, Roland
>  > <Ro...@adesso.at> wrote:
>  > > What I meant was: don't use ${file.separator} and write '/' in your
> POM.
>  > >
>  > > Or do you have a reason you need the variable?
>  > >
>  > >
>  > > On 20-04-11 23:51, Zilvinas Vilutis wrote:
>  > >> Exactly, but I need *maven* to generate those "/" :)
>  > >>
>  > >> I need the
>  > ${project.build.outputDirectory}${file.separator}orm.properties
>  > >> to contain "/" in the output, but it generates the path with "\"
>  > >> slashes, e.g. C:\<path to myproject>\target\classes\orm.properties
>  > >>
>  > >> Regards
>  > >>
>  > >> Žilvinas Vilutis
>  > >>
>  > >> Mobile: (+370) 652 38353
>  > >> E-mail: cikasfm@gmail.com
>  > >>
>  > >>
>  > >>
>  > >> On Wed, Apr 20, 2011 at 12:57 PM, Asmann, Roland
>  > >> <Ro...@adesso.at> wrote:
>  > >>> Just use the character '/', it works on Windows!
>  > >>>
>  > >>>
>  > >>> On 20-04-11 21:45, Zilvinas Vilutis wrote:
>  > >>>> Hi maven users!
>  > >>>>
>  > >>>> I'm trying to execute a java command and pass a path to a file as
>  > an argument:
>  > >>>>
>  > >>>> <plugin>
>  > >>>> <groupId>org.codehaus.mojo</groupId>
>  > >>>> <artifactId>exec-maven-plugin</artifactId>
>  > >>>> <configuration>
>  > >>>> <executable>java</executable>
>  > >>>>
> <workingDirectory>${project.build.outputDirectory}</workingDirectory>
>  > >>>> <classpathScope>runtime</classpathScope>
>  > >>>> <arguments>
>  > >>>> <argument>-c
>  > >>>>
>  >
> ${project.build.outputDirectory}${file.separator}orm.properties</argument>
>  > >>>> </arguments>
>  > >>>>
>  > <mainClass>com.company.deploy.product.AutomatedProductDeploy</mainClass>
>  > >>>> </configuration>
>  > >>>> </plugin>
>  > >>>>
>  > >>>> And I'm using maven properties to construct the filename:
>  > >>>> ${project.build.outputDirectory}${file.separator}orm.properties
>  > >>>>
>  > >>>> Unfortunately, I'm getting an exception from the java class I'm
>  > running:
>  > >>>>
>  > >>>> Caused by: java.io.FileNotFoundException: C:\<path to my
>  > >>>> project>\target\classes\orm.properties (The filename, directory
> name,
>  > >>>> or volume label syntax is incorrect)
>  > >>>> at java.io.FileInputStream.open(Native Method)
>  > >>>> at java.io.FileInputStream.<init>(FileInputStream.java:106)
>  > >>>>
>  > >>>> Most likely the it is using the argument and does not escape slashes
>  > >>>> to new java.io.File( filePath )
>  > >>>>
>  > >>>> As I don't have access to source code of the class - is there
> any way
>  > >>>> to enforce maven use unix style path generation on windows? ( change
>  > >>>> slashes to "/" )
>  > >>>>
>  > >>>> I tried to override the ${file.separator} property - but it seems to
>  > >>>> be read-only and doesn't help.
>  > >>>>
>  > >>>> Any ideas?
>  > >>>>
>  > >>>> Thank you!
>  > >>>>
>  > >>>> Žilvinas Vilutis
>  > >>>>
>  > >>>> E-mail: cikasfm@gmail.com
>  > >>>>
>  > >>>>
> ---------------------------------------------------------------------
>  > >>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>  > >>>> For additional commands, e-mail: users-help@maven.apache.org
>  > >>>>
>  > >>>
>  > >>> --
>  > >>> Roland Asmann
>  > >>> Senior Software Engineer
>  > >>>
>  > >>> adesso Austria GmbH
>  > >>> Floridotower 26. Stock T +43 1 2198790-27
>  > >>> Floridsdorfer Hauptstr. 1 F +43 1 2198790-927
>  > >>> A-1210 Wien M +43 664 88657566
>  > >>> E roland.asmann@adesso.at
>  > >>> W www.adesso.at
>  > >>>
>  > >>> -------------------------------------------------------------
>  > >>> >>> business. people. technology.<<<
>  > >>> -------------------------------------------------------------
>  > >>
>  > >> ---------------------------------------------------------------------
>  > >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>  > >> For additional commands, e-mail: users-help@maven.apache.org
>  > >>
>  > >
>  > > --
>  > > Roland Asmann
>  > > Senior Software Engineer
>  > >
>  > > adesso Austria GmbH
>  > > Floridotower 26. Stock T +43 1 2198790-27
>  > > Floridsdorfer Hauptstr. 1 F +43 1 2198790-927
>  > > A-1210 Wien M +43 664 88657566
>  > > E roland.asmann@adesso.at
>  > > W www.adesso.at
>  > >
>  > > -------------------------------------------------------------
>  > > >>> business. people. technology. <<<
>  > > -------------------------------------------------------------
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>  > For additional commands, e-mail: users-help@maven.apache.org
>  >
>
> --
> Roland Asmann
> Senior Software Engineer
>
> adesso Austria GmbH
> Floridotower 26. Stock T +43 1 2198790-27
> Floridsdorfer Hauptstr. 1 F +43 1 2198790-927
> A-1210 Wien M +43 664 88657566
> E roland.asmann@adesso.at
> W www.adesso.at
>
> -------------------------------------------------------------
>  >>> business. people. technology. <<<
> -------------------------------------------------------------
>

-- 
Roland Asmann
Senior Software Engineer

adesso Austria GmbH
Floridotower 26. Stock              T +43 1 2198790-27
Floridsdorfer Hauptstr. 1           F +43 1 2198790-927
A-1210 Wien                         M +43 664 88657566
                                    E roland.asmann@adesso.at
                                    W www.adesso.at

-------------------------------------------------------------
             >>> business. people. technology. <<<
-------------------------------------------------------------

Re: java file path in exec:java

Posted by "Asmann, Roland" <Ro...@adesso.at>.
I see your problem now.

Would it be a problem for you to use ant to run the program instead of 
the exec-plugin? Then you could have Ant convert the path:

<pathconvert targetos="unix" property="unix-path">
    <path location="${project.build.outputDirectory}" />
</pathconvert>

Now if there was a way to have this property available in Maven, you 
could use the exec-plugin, but I believe you can't access this property 
(${unix-path}) in Maven...

Roland


On 21.04.2011 1:17, Zilvinas Vilutis wrote:
> yes, I can do that, however "${project.build.outputDirectory}" still
> generates "C:\folder1\folder2\..." & etc :)
>
> Žilvinas Vilutis
>
> Mobile:   (+370) 652 38353
> E-mail:   cikasfm@gmail.com
>
>
>
> On Wed, Apr 20, 2011 at 2:57 PM, Asmann, Roland
> <Ro...@adesso.at> wrote:
>  > What I meant was: don't use ${file.separator} and write '/' in your POM.
>  >
>  > Or do you have a reason you need the variable?
>  >
>  >
>  > On 20-04-11 23:51, Zilvinas Vilutis wrote:
>  >> Exactly, but I need *maven* to generate those "/" :)
>  >>
>  >> I need the
> ${project.build.outputDirectory}${file.separator}orm.properties
>  >> to contain "/" in the output, but it generates the path with "\"
>  >> slashes, e.g. C:\<path to myproject>\target\classes\orm.properties
>  >>
>  >> Regards
>  >>
>  >> Žilvinas Vilutis
>  >>
>  >> Mobile:   (+370) 652 38353
>  >> E-mail:   cikasfm@gmail.com
>  >>
>  >>
>  >>
>  >> On Wed, Apr 20, 2011 at 12:57 PM, Asmann, Roland
>  >> <Ro...@adesso.at>  wrote:
>  >>> Just use the character '/', it works on Windows!
>  >>>
>  >>>
>  >>> On 20-04-11 21:45, Zilvinas Vilutis wrote:
>  >>>> Hi maven users!
>  >>>>
>  >>>> I'm trying to execute a java command and pass a path to a file as
> an argument:
>  >>>>
>  >>>> <plugin>
>  >>>> <groupId>org.codehaus.mojo</groupId>
>  >>>> <artifactId>exec-maven-plugin</artifactId>
>  >>>> <configuration>
>  >>>> <executable>java</executable>
>  >>>> <workingDirectory>${project.build.outputDirectory}</workingDirectory>
>  >>>> <classpathScope>runtime</classpathScope>
>  >>>> <arguments>
>  >>>> <argument>-c
>  >>>>
> ${project.build.outputDirectory}${file.separator}orm.properties</argument>
>  >>>> </arguments>
>  >>>>
> <mainClass>com.company.deploy.product.AutomatedProductDeploy</mainClass>
>  >>>> </configuration>
>  >>>> </plugin>
>  >>>>
>  >>>> And I'm using maven properties to construct the filename:
>  >>>> ${project.build.outputDirectory}${file.separator}orm.properties
>  >>>>
>  >>>> Unfortunately, I'm getting an exception from the java class I'm
> running:
>  >>>>
>  >>>> Caused by: java.io.FileNotFoundException:  C:\<path to my
>  >>>> project>\target\classes\orm.properties (The filename, directory name,
>  >>>> or volume label syntax is incorrect)
>  >>>>           at java.io.FileInputStream.open(Native Method)
>  >>>>           at java.io.FileInputStream.<init>(FileInputStream.java:106)
>  >>>>
>  >>>> Most likely the it is using the argument and does not escape slashes
>  >>>> to new java.io.File( filePath )
>  >>>>
>  >>>> As I don't have access to source code of the class - is there any way
>  >>>> to enforce maven use unix style path generation on windows? ( change
>  >>>> slashes to "/" )
>  >>>>
>  >>>> I tried to override the ${file.separator} property - but it seems to
>  >>>> be read-only and doesn't help.
>  >>>>
>  >>>> Any ideas?
>  >>>>
>  >>>> Thank you!
>  >>>>
>  >>>> Žilvinas Vilutis
>  >>>>
>  >>>> E-mail:   cikasfm@gmail.com
>  >>>>
>  >>>> ---------------------------------------------------------------------
>  >>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>  >>>> For additional commands, e-mail: users-help@maven.apache.org
>  >>>>
>  >>>
>  >>> --
>  >>> Roland Asmann
>  >>> Senior Software Engineer
>  >>>
>  >>> adesso Austria GmbH
>  >>> Floridotower 26. Stock              T +43 1 2198790-27
>  >>> Floridsdorfer Hauptstr. 1           F +43 1 2198790-927
>  >>> A-1210 Wien                         M +43 664 88657566
>  >>>                                     E roland.asmann@adesso.at
>  >>>                                     W www.adesso.at
>  >>>
>  >>> -------------------------------------------------------------
>  >>> >>>  business. people. technology.<<<
>  >>> -------------------------------------------------------------
>  >>
>  >> ---------------------------------------------------------------------
>  >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>  >> For additional commands, e-mail: users-help@maven.apache.org
>  >>
>  >
>  > --
>  > Roland Asmann
>  > Senior Software Engineer
>  >
>  > adesso Austria GmbH
>  > Floridotower 26. Stock              T +43 1 2198790-27
>  > Floridsdorfer Hauptstr. 1           F +43 1 2198790-927
>  > A-1210 Wien                         M +43 664 88657566
>  >                                    E roland.asmann@adesso.at
>  >                                    W www.adesso.at
>  >
>  > -------------------------------------------------------------
>  > >>> business. people. technology. <<<
>  > -------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

-- 
Roland Asmann
Senior Software Engineer

adesso Austria GmbH
Floridotower 26. Stock              T +43 1 2198790-27
Floridsdorfer Hauptstr. 1           F +43 1 2198790-927
A-1210 Wien                         M +43 664 88657566
                                    E roland.asmann@adesso.at
                                    W www.adesso.at

-------------------------------------------------------------
             >>> business. people. technology. <<<
-------------------------------------------------------------

Re: java file path in exec:java

Posted by Zilvinas Vilutis <ci...@gmail.com>.
yes, I can do that, however "${project.build.outputDirectory}" still
generates "C:\folder1\folder2\..." & etc :)

Žilvinas Vilutis

Mobile:   (+370) 652 38353
E-mail:   cikasfm@gmail.com



On Wed, Apr 20, 2011 at 2:57 PM, Asmann, Roland <Ro...@adesso.at> wrote:
> What I meant was: don't use ${file.separator} and write '/' in your POM.
>
> Or do you have a reason you need the variable?
>
>
> On 20-04-11 23:51, Zilvinas Vilutis wrote:
>> Exactly, but I need *maven* to generate those "/" :)
>>
>> I need the ${project.build.outputDirectory}${file.separator}orm.properties
>> to contain "/" in the output, but it generates the path with "\"
>> slashes, e.g. C:\<path to myproject>\target\classes\orm.properties
>>
>> Regards
>>
>> Žilvinas Vilutis
>>
>> Mobile:   (+370) 652 38353
>> E-mail:   cikasfm@gmail.com
>>
>>
>>
>> On Wed, Apr 20, 2011 at 12:57 PM, Asmann, Roland
>> <Ro...@adesso.at>  wrote:
>>> Just use the character '/', it works on Windows!
>>>
>>>
>>> On 20-04-11 21:45, Zilvinas Vilutis wrote:
>>>> Hi maven users!
>>>>
>>>> I'm trying to execute a java command and pass a path to a file as an argument:
>>>>
>>>> <plugin>
>>>>     <groupId>org.codehaus.mojo</groupId>
>>>>     <artifactId>exec-maven-plugin</artifactId>
>>>>     <configuration>
>>>>       <executable>java</executable>
>>>>       <workingDirectory>${project.build.outputDirectory}</workingDirectory>
>>>>       <classpathScope>runtime</classpathScope>
>>>>       <arguments>
>>>>         <argument>-c
>>>> ${project.build.outputDirectory}${file.separator}orm.properties</argument>
>>>>       </arguments>
>>>>       <mainClass>com.company.deploy.product.AutomatedProductDeploy</mainClass>
>>>>     </configuration>
>>>> </plugin>
>>>>
>>>> And I'm using maven properties to construct the filename:
>>>> ${project.build.outputDirectory}${file.separator}orm.properties
>>>>
>>>> Unfortunately, I'm getting an exception from the java class I'm running:
>>>>
>>>> Caused by: java.io.FileNotFoundException:  C:\<path to my
>>>> project>\target\classes\orm.properties (The filename, directory name,
>>>> or volume label syntax is incorrect)
>>>>           at java.io.FileInputStream.open(Native Method)
>>>>           at java.io.FileInputStream.<init>(FileInputStream.java:106)
>>>>
>>>> Most likely the it is using the argument and does not escape slashes
>>>> to new java.io.File( filePath )
>>>>
>>>> As I don't have access to source code of the class - is there any way
>>>> to enforce maven use unix style path generation on windows? ( change
>>>> slashes to "/" )
>>>>
>>>> I tried to override the ${file.separator} property - but it seems to
>>>> be read-only and doesn't help.
>>>>
>>>> Any ideas?
>>>>
>>>> Thank you!
>>>>
>>>> Žilvinas Vilutis
>>>>
>>>> E-mail:   cikasfm@gmail.com
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>
>>>
>>> --
>>> Roland Asmann
>>> Senior Software Engineer
>>>
>>> adesso Austria GmbH
>>> Floridotower 26. Stock              T +43 1 2198790-27
>>> Floridsdorfer Hauptstr. 1           F +43 1 2198790-927
>>> A-1210 Wien                         M +43 664 88657566
>>>                                     E roland.asmann@adesso.at
>>>                                     W www.adesso.at
>>>
>>> -------------------------------------------------------------
>>>              >>>  business. people. technology.<<<
>>> -------------------------------------------------------------
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>
> --
> Roland Asmann
> Senior Software Engineer
>
> adesso Austria GmbH
> Floridotower 26. Stock              T +43 1 2198790-27
> Floridsdorfer Hauptstr. 1           F +43 1 2198790-927
> A-1210 Wien                         M +43 664 88657566
>                                    E roland.asmann@adesso.at
>                                    W www.adesso.at
>
> -------------------------------------------------------------
>             >>> business. people. technology. <<<
> -------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: java file path in exec:java

Posted by "Asmann, Roland" <Ro...@adesso.at>.
What I meant was: don't use ${file.separator} and write '/' in your POM.

Or do you have a reason you need the variable?


On 20-04-11 23:51, Zilvinas Vilutis wrote:
> Exactly, but I need *maven* to generate those "/" :)
>
> I need the ${project.build.outputDirectory}${file.separator}orm.properties
> to contain "/" in the output, but it generates the path with "\"
> slashes, e.g. C:\<path to myproject>\target\classes\orm.properties
>
> Regards
>
> Žilvinas Vilutis
>
> Mobile:   (+370) 652 38353
> E-mail:   cikasfm@gmail.com
>
>
>
> On Wed, Apr 20, 2011 at 12:57 PM, Asmann, Roland
> <Ro...@adesso.at>  wrote:
>> Just use the character '/', it works on Windows!
>>
>>
>> On 20-04-11 21:45, Zilvinas Vilutis wrote:
>>> Hi maven users!
>>>
>>> I'm trying to execute a java command and pass a path to a file as an argument:
>>>
>>> <plugin>
>>>     <groupId>org.codehaus.mojo</groupId>
>>>     <artifactId>exec-maven-plugin</artifactId>
>>>     <configuration>
>>>       <executable>java</executable>
>>>       <workingDirectory>${project.build.outputDirectory}</workingDirectory>
>>>       <classpathScope>runtime</classpathScope>
>>>       <arguments>
>>>         <argument>-c
>>> ${project.build.outputDirectory}${file.separator}orm.properties</argument>
>>>       </arguments>
>>>       <mainClass>com.company.deploy.product.AutomatedProductDeploy</mainClass>
>>>     </configuration>
>>> </plugin>
>>>
>>> And I'm using maven properties to construct the filename:
>>> ${project.build.outputDirectory}${file.separator}orm.properties
>>>
>>> Unfortunately, I'm getting an exception from the java class I'm running:
>>>
>>> Caused by: java.io.FileNotFoundException:  C:\<path to my
>>> project>\target\classes\orm.properties (The filename, directory name,
>>> or volume label syntax is incorrect)
>>>           at java.io.FileInputStream.open(Native Method)
>>>           at java.io.FileInputStream.<init>(FileInputStream.java:106)
>>>
>>> Most likely the it is using the argument and does not escape slashes
>>> to new java.io.File( filePath )
>>>
>>> As I don't have access to source code of the class - is there any way
>>> to enforce maven use unix style path generation on windows? ( change
>>> slashes to "/" )
>>>
>>> I tried to override the ${file.separator} property - but it seems to
>>> be read-only and doesn't help.
>>>
>>> Any ideas?
>>>
>>> Thank you!
>>>
>>> Žilvinas Vilutis
>>>
>>> E-mail:   cikasfm@gmail.com
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>
>> --
>> Roland Asmann
>> Senior Software Engineer
>>
>> adesso Austria GmbH
>> Floridotower 26. Stock              T +43 1 2198790-27
>> Floridsdorfer Hauptstr. 1           F +43 1 2198790-927
>> A-1210 Wien                         M +43 664 88657566
>>                                     E roland.asmann@adesso.at
>>                                     W www.adesso.at
>>
>> -------------------------------------------------------------
>>              >>>  business. people. technology.<<<
>> -------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

-- 
Roland Asmann
Senior Software Engineer

adesso Austria GmbH
Floridotower 26. Stock              T +43 1 2198790-27
Floridsdorfer Hauptstr. 1           F +43 1 2198790-927
A-1210 Wien                         M +43 664 88657566
                                    E roland.asmann@adesso.at
                                    W www.adesso.at

-------------------------------------------------------------
             >>> business. people. technology. <<<
-------------------------------------------------------------

Re: java file path in exec:java

Posted by Zilvinas Vilutis <ci...@gmail.com>.
Exactly, but I need *maven* to generate those "/" :)

I need the ${project.build.outputDirectory}${file.separator}orm.properties
to contain "/" in the output, but it generates the path with "\"
slashes, e.g. C:\<path to myproject>\target\classes\orm.properties

Regards

Žilvinas Vilutis

Mobile:   (+370) 652 38353
E-mail:   cikasfm@gmail.com



On Wed, Apr 20, 2011 at 12:57 PM, Asmann, Roland
<Ro...@adesso.at> wrote:
> Just use the character '/', it works on Windows!
>
>
> On 20-04-11 21:45, Zilvinas Vilutis wrote:
>> Hi maven users!
>>
>> I'm trying to execute a java command and pass a path to a file as an argument:
>>
>> <plugin>
>>    <groupId>org.codehaus.mojo</groupId>
>>    <artifactId>exec-maven-plugin</artifactId>
>>    <configuration>
>>      <executable>java</executable>
>>      <workingDirectory>${project.build.outputDirectory}</workingDirectory>
>>      <classpathScope>runtime</classpathScope>
>>      <arguments>
>>        <argument>-c
>> ${project.build.outputDirectory}${file.separator}orm.properties</argument>
>>      </arguments>
>>      <mainClass>com.company.deploy.product.AutomatedProductDeploy</mainClass>
>>    </configuration>
>> </plugin>
>>
>> And I'm using maven properties to construct the filename:
>> ${project.build.outputDirectory}${file.separator}orm.properties
>>
>> Unfortunately, I'm getting an exception from the java class I'm running:
>>
>> Caused by: java.io.FileNotFoundException:  C:\<path to my
>> project>\target\classes\orm.properties (The filename, directory name,
>> or volume label syntax is incorrect)
>>          at java.io.FileInputStream.open(Native Method)
>>          at java.io.FileInputStream.<init>(FileInputStream.java:106)
>>
>> Most likely the it is using the argument and does not escape slashes
>> to new java.io.File( filePath )
>>
>> As I don't have access to source code of the class - is there any way
>> to enforce maven use unix style path generation on windows? ( change
>> slashes to "/" )
>>
>> I tried to override the ${file.separator} property - but it seems to
>> be read-only and doesn't help.
>>
>> Any ideas?
>>
>> Thank you!
>>
>> Žilvinas Vilutis
>>
>> E-mail:   cikasfm@gmail.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>
> --
> Roland Asmann
> Senior Software Engineer
>
> adesso Austria GmbH
> Floridotower 26. Stock              T +43 1 2198790-27
> Floridsdorfer Hauptstr. 1           F +43 1 2198790-927
> A-1210 Wien                         M +43 664 88657566
>                                    E roland.asmann@adesso.at
>                                    W www.adesso.at
>
> -------------------------------------------------------------
>             >>> business. people. technology. <<<
> -------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: java file path in exec:java

Posted by "Asmann, Roland" <Ro...@adesso.at>.
Just use the character '/', it works on Windows!


On 20-04-11 21:45, Zilvinas Vilutis wrote:
> Hi maven users!
>
> I'm trying to execute a java command and pass a path to a file as an argument:
>
> <plugin>
>    <groupId>org.codehaus.mojo</groupId>
>    <artifactId>exec-maven-plugin</artifactId>
>    <configuration>
>      <executable>java</executable>
>      <workingDirectory>${project.build.outputDirectory}</workingDirectory>
>      <classpathScope>runtime</classpathScope>
>      <arguments>
>        <argument>-c
> ${project.build.outputDirectory}${file.separator}orm.properties</argument>
>      </arguments>
>      <mainClass>com.company.deploy.product.AutomatedProductDeploy</mainClass>
>    </configuration>
> </plugin>
>
> And I'm using maven properties to construct the filename:
> ${project.build.outputDirectory}${file.separator}orm.properties
>
> Unfortunately, I'm getting an exception from the java class I'm running:
>
> Caused by: java.io.FileNotFoundException:  C:\<path to my
> project>\target\classes\orm.properties (The filename, directory name,
> or volume label syntax is incorrect)
>          at java.io.FileInputStream.open(Native Method)
>          at java.io.FileInputStream.<init>(FileInputStream.java:106)
>
> Most likely the it is using the argument and does not escape slashes
> to new java.io.File( filePath )
>
> As I don't have access to source code of the class - is there any way
> to enforce maven use unix style path generation on windows? ( change
> slashes to "/" )
>
> I tried to override the ${file.separator} property - but it seems to
> be read-only and doesn't help.
>
> Any ideas?
>
> Thank you!
>
> Žilvinas Vilutis
>
> E-mail:   cikasfm@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

-- 
Roland Asmann
Senior Software Engineer

adesso Austria GmbH
Floridotower 26. Stock              T +43 1 2198790-27
Floridsdorfer Hauptstr. 1           F +43 1 2198790-927
A-1210 Wien                         M +43 664 88657566
                                    E roland.asmann@adesso.at
                                    W www.adesso.at

-------------------------------------------------------------
             >>> business. people. technology. <<<
-------------------------------------------------------------