maven basedir - 用前斜杠替换反斜杠

Gre*_*egD 4 java maven

我怎样才能用一个 \ 替换我的 basedir 到带有 \\ 的 basedir ?

我试过了:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <configuration>
                <defaultLibBundleDir>APP-INF/lib</defaultLibBundleDir>
                <skinnyWars>true</skinnyWars>
                <version>6</version>
                <modules>
                    <webModule>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>ecad-application-ws-webservice</artifactId>
                        <bundleFileName>ecad-application-ws-webservice.war</bundleFileName>
                        <contextRoot>/ecad-ws/ecadservice</contextRoot>
                    </webModule>
                </modules>

               <source>
                    project.properties['basedir']=project.properties['basedir'].replace('\\','/');
               </source>
            </configuration>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

但这并没有改变任何事情..有人还有其他想法吗?

Gre*_*egD 5

我曾经使用 groovy 插件来解决它:

<plugin>
            <groupId>org.codehaus.groovy.maven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <executions>
              <execution>
                <id>set-unixy_build_directory!</id>
                <phase>compile</phase>
                <goals>
                  <goal>execute</goal>
                </goals>
                <configuration>
                  <classpath>
                    <element>
                      <groupId>commons-lang</groupId>
                      <artifactId>commons-lang</artifactId>
                      <version>2.4</version>
                     </element>
                  </classpath>
                  <source>
                    if (org.apache.commons.lang.SystemUtils.IS_OS_WINDOWS) {
                      project.properties.myDynamicProperty =
                      project.basedir.absolutePath.replace('\\','\\\\');
                    }
                  </source>
                </configuration>
              </execution>
            </executions>
        </plugin>
Run Code Online (Sandbox Code Playgroud)