brett 2003/08/31 00:33:06
Modified: src/java/org/apache/maven/jelly/tags/maven
MakeRelativePathTag.java
src/plugins-build/idea/src/plugin-resources/templates/v3
project.jelly
src/plugins-build/idea/src/plugin-resources/templates/v4
module.jelly
src/test/touchstone-build maven.xml
Log:
allow specifying a certain type of separator - needed for IDEA plugin
Revision Changes Path
1.3 +27 -0
maven/src/java/org/apache/maven/jelly/tags/maven/MakeRelativePathTag.java
Index: MakeRelativePathTag.java
===================================================================
RCS file:
/home/cvs/maven/src/java/org/apache/maven/jelly/tags/maven/MakeRelativePathTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MakeRelativePathTag.java 19 Aug 2003 04:25:39 -0000 1.2
+++ MakeRelativePathTag.java 31 Aug 2003 07:33:05 -0000 1.3
@@ -64,6 +64,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.StringTokenizer;
/**
* Jelly tag to convert an absolute path into a relative path by removing the
basedir.
@@ -77,6 +78,9 @@
/** The path to convert. */
private String path;
+
+ /** Force a certain path separator. */
+ private String separator = null;
/** The jelly variable to store the result into. */
private String var;
@@ -100,6 +104,15 @@
}
/**
+ * Set the path separator to use.
+ * @param separator the separator.
+ */
+ public void setSeparator( String separator )
+ {
+ this.separator = separator;
+ }
+
+ /**
* Set the result variable.
* @param var the result variable name.
*/
@@ -120,6 +133,20 @@
try
{
String canonicalPath = MavenUtils.makeRelativePath( basedir, path );
+ if ( separator != null )
+ {
+ StringBuffer buf = new StringBuffer();
+ StringTokenizer tok = new StringTokenizer( canonicalPath,
File.separator );
+ while ( tok.hasMoreTokens() )
+ {
+ buf.append( tok.nextToken() );
+ if ( tok.hasMoreTokens() )
+ {
+ buf.append( separator );
+ }
+ }
+ canonicalPath = buf.toString();
+ }
getContext().setVariable( var, canonicalPath );
}
catch ( IOException e )
1.4 +5 -4
maven/src/plugins-build/idea/src/plugin-resources/templates/v3/project.jelly
Index: project.jelly
===================================================================
RCS file:
/home/cvs/maven/src/plugins-build/idea/src/plugin-resources/templates/v3/project.jelly,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- project.jelly 19 Aug 2003 05:12:22 -0000 1.3
+++ project.jelly 31 Aug 2003 07:33:05 -0000 1.4
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<j:whitespace xmlns:j="jelly:core" xmlns="dummy" trim="true">
+<j:whitespace xmlns:j="jelly:core" xmlns:maven="jelly:maven" xmlns="dummy"
trim="true">
<project version="3" relativePaths="false">
<component name="ProjectRootManager" version="2">
@@ -11,12 +11,13 @@
</projectPath>
<sourcePath>
<root type="composite">
- <!-- TODO... these won't work if absolute? -->
<j:if test="${sourcesPresent}">
- <root type="simple"
url="file://$$PROJECT_DIR$$/${pom.build.sourceDirectory}"/>
+ <maven:makeRelativePath var="value" basedir="${basedir}"
path="${pom.build.sourceDirectory}" separator="/" />
+ <root type="simple" url="file://$$PROJECT_DIR$$/${value}"/>
</j:if>
<j:if test="${unitTestSourcesPresent}">
- <root type="simple"
url="file://$$PROJECT_DIR$$/${pom.build.unitTestSourceDirectory}"/>
+ <maven:makeRelativePath var="value" basedir="${basedir}"
path="${pom.build.unitTestSourceDirectory}" separator="/" />
+ <root type="simple" url="file://$$PROJECT_DIR$$/${value}"/>
</j:if>
<root type="jdk" rootType="sourcePath" name="java version
"${java.version}""/>
</root>
1.4 +10 -7
maven/src/plugins-build/idea/src/plugin-resources/templates/v4/module.jelly
Index: module.jelly
===================================================================
RCS file:
/home/cvs/maven/src/plugins-build/idea/src/plugin-resources/templates/v4/module.jelly,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- module.jelly 19 Aug 2003 05:13:06 -0000 1.3
+++ module.jelly 31 Aug 2003 07:33:06 -0000 1.4
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<j:whitespace xmlns:j="jelly:core" xmlns="dummy" trim="true">
+<j:whitespace xmlns:j="jelly:core" xmlns:maven="jelly:maven" xmlns="dummy"
trim="true">
<module version="4" relativePaths="false">
<component name="LvcsConfiguration">
@@ -8,16 +8,19 @@
<option name="MARK_EXTERNAL_CHANGES_AS_UP_TO_DATE" value="true"/>
</component>
<component name="NewModuleRootManager">
- <!-- TODO: use maven.build.dest and maven.test.dest -->
- <output url="file://$MODULE_DIR$/target/classes"/>
- <output-test url="file://$MODULE_DIR$/target/test-classes"/>
+ <maven:makeRelativePath var="value" basedir="${basedir}"
path="${maven.build.dest}" separator="/" />
+ <output url="file://$$MODULE_DIR$$/${value}"/>
+ <!-- @todo - use maven.test.dest instead -->
+ <maven:makeRelativePath var="value" basedir="${basedir}"
path="${maven.build.dir}" separator="/" />
+ <output-test url="file://$$MODULE_DIR$$/${value}/test-classes"/>
<content url="file://$MODULE_DIR$">
- <!-- TODO... these won't work if absolute? -->
<j:if test="${sourcesPresent}">
- <sourceFolder
url="file://$$MODULE_DIR$$/${pom.build.sourceDirectory}" isTestSource="false"/>
+ <maven:makeRelativePath var="value" basedir="${basedir}"
path="${pom.build.sourceDirectory}" separator="/" />
+ <sourceFolder url="file://$$MODULE_DIR$$/${value}"
isTestSource="false"/>
</j:if>
<j:if test="${unitTestSourcesPresent}">
- <sourceFolder
url="file://$$MODULE_DIR$$/${pom.build.unitTestSourceDirectory}" isTestSource="true"/>
+ <maven:makeRelativePath var="value" basedir="${basedir}"
path="${pom.build.unitTestSourceDirectory}" separator="/" />
+ <sourceFolder url="file://$$MODULE_DIR$$/${value}"
isTestSource="true"/>
</j:if>
</content>
<orderEntry type="jdk" jdkName="java version
"${java.version}""/>
1.42 +9 -0 maven/src/test/touchstone-build/maven.xml
Index: maven.xml
===================================================================
RCS file: /home/cvs/maven/src/test/touchstone-build/maven.xml,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- maven.xml 20 Aug 2003 13:20:00 -0000 1.41
+++ maven.xml 31 Aug 2003 07:33:06 -0000 1.42
@@ -610,6 +610,15 @@
testVar = '${testVar}'; should be: '${testVar2}'
</ant:fail>
</j:if>
+
+ <maven:makeRelativePath var="testVar" basedir="${basedir}"
path="${basedir}/src\main/1\2" separator="/" />
+ <j:set var="testVar2" value="src/main/1/2"/>
+ <j:if test="${testVar != testVar2}">
+ <ant:fail>
+ makeRelativePath:
+ testVar = '${testVar}'; should be: '${testVar2}'
+ </ant:fail>
+ </j:if>
</goal>
<!--
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]