You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by stug23 <pa...@gmail.com> on 2009/04/24 05:55:40 UTC

Properties: backslashes in pathname on Windows

Is there a way in Maven 2.0.9 to end up with forward slashes in a
file/directory pathname on the Windows platform when filtering a property
such as ${project.parent.basedir}?

I need to supply a file URL for a Hibernate URL specified in a
persistence.xml configuraton file. The following property statement from a
persistence.xml file gets filtered as a resource file from
src/test/resources into the test-classes directory under target.

However on Windows the pathname ends up including backslashes which don't
play well with Hibernate. The JPA hibernate entity manager cannot resolve a
URL with backslashes in it.

The XML element in questions looks more or less like this:

<property name="hibernate.connection.url"
value="jdbc:hsqldb:file:///${project.parent.basedir}/target/hsql/testdb"/>

Suggestions on how to accomplish this would be appreciated.

TIA!

-- 
View this message in context: http://www.nabble.com/Properties%3A-backslashes-in-pathname-on-Windows-tp23209361p23209361.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Properties: backslashes in pathname on Windows

Posted by stug23 <pa...@gmail.com>.
I found a Maven plugin at Google that can replace tokens which I applied to
the filtered xml file.

This does remove the backslashes, however I think a much better solution
would be for Maven to have a simple and direct means of obtaining a file:URL
with correct form via a Maven project property.

Perhaps something like ${project.parent.basedir.url}? At this stage a
feature such as this might be more relevant as a Maven 3.0 addition?

Here is an example of using the maven-replacer-plugin configuration that can
replace tokens:

<plugin>
	<groupId>bakersoftware</groupId>
	<artifactId>maven-replacer-plugin</artifactId>
	<version>0.0.9</version>
	<executions>
		<execution>
			<phase>test-compile</phase>
			<goals>
				<goal>replace</goal>
			</goals>
			<configuration>
				<file>target/test-classes/persistence.xml</file>
				<token>\\</token>
				<value>/</value>
			</configuration>
		</execution>
	</executions>
</plugin>


stug23 wrote:
> 
> Is there a way in Maven 2.0.9 to end up with forward slashes in a
> file/directory pathname on the Windows platform when filtering a property
> such as ${project.parent.basedir}?
> 
> I need to supply a file URL for a Hibernate URL specified in a
> persistence.xml configuraton file. The following property statement from a
> persistence.xml file gets filtered as a resource file from
> src/test/resources into the test-classes directory under target.
> 
> However on Windows the pathname ends up including backslashes which don't
> play well with Hibernate. The JPA hibernate entity manager cannot resolve
> a URL with backslashes in it.
> 
> The XML element in questions looks more or less like this:
> 
> <property name="hibernate.connection.url"
> value="jdbc:hsqldb:file:///${project.parent.basedir}/target/hsql/testdb"/>
> 
> Suggestions on how to accomplish this would be appreciated.
> 
> TIA!
> 
> 

-- 
View this message in context: http://www.nabble.com/Properties%3A-backslashes-in-pathname-on-Windows-tp23209361p23219538.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


RE: Properties: backslashes in pathname on Windows

Posted by Sean Hennessy <sh...@astutenetworks.com>.
 ant's ${file.separator} ??

-----Original Message-----
From: stug23 [mailto:pat.podenski@gmail.com]
Sent: Thursday, April 23, 2009 8:56 PM
To: users@maven.apache.org
Subject: Properties: backslashes in pathname on Windows



Is there a way in Maven 2.0.9 to end up with forward slashes in a file/directory pathname on the Windows platform when filtering a property such as ${project.parent.basedir}?

I need to supply a file URL for a Hibernate URL specified in a persistence.xml configuraton file. The following property statement from a persistence.xml file gets filtered as a resource file from src/test/resources into the test-classes directory under target.

However on Windows the pathname ends up including backslashes which don't play well with Hibernate. The JPA hibernate entity manager cannot resolve a URL with backslashes in it.

The XML element in questions looks more or less like this:

<property name="hibernate.connection.url" value="jdbc:hsqldb:file:///${project.parent.basedir}/target/hsql/testdb"/>

Suggestions on how to accomplish this would be appreciated.

TIA!

--
View this message in context: http://www.nabble.com/Properties%3A-backslashes-in-pathname-on-Windows-tp23209361p23209361.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


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