windows 如何在Maven下“路径转换”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3056614/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 14:40:22  来源:igfitidea点击:

How to "pathconvert" under Maven?

windowsmaven-2filepath

提问by Gili

I am having a similar problem as Ant produces jsfl with backslashes instead of slashesexcept that I'm running under Maven.

我遇到了类似的问题,因为Ant 生成带有反斜杠而不是斜杠的 jsfl,只是我在 Maven 下运行。

I'd like to generate cross-platform paths relative to Maven's built-in property ${basedir}. The problem is that under Windows, ${basedir} resolves to a path containing Windows-style slashes. Is there an easy way for me to get ${basedir} into a form that always uses Unix-style slashes even under Windows?

我想生成相对于 Maven 的内置属性 ${basedir} 的跨平台路径。问题是在 Windows 下, ${basedir} 解析为包含 Windows 样式斜杠的路径。有没有一种简单的方法可以让 ${basedir} 变成一种即使在 Windows 下也总是使用 Unix 风格的斜杠的形式?

回答by Gili

Answering my own question:

回答我自己的问题:

Use ${file.separator}instead of slash and watch out for bug MEXEC-81 which was fixed in 2010 by git commit 6e8be6881fe50714a00509f8f106e21d50d606a6(svn: 12372) which was where quotes and backslasheswere misinterpreted.

使用${file.separator}而不是斜杠并注意错误 MEXEC-81,该错误在 2010 年由 git commit 6e8be6881fe50714a00509f8f106e21d50d606a6(svn: 12372)修复,这是引号和反斜杠被误解的地方。

回答by Gabriel

In the case of adding a dir to the library path, you are better off creating a new artifact with its own pom, installing it in your local repo and adding it as a dependency in the project.

在将目录添加到库路径的情况下,最好使用自己的 pom 创建一个新工件,将其安装在本地存储库中并将其添加为项目中的依赖项。

Maven and Native Libraries: JDIC and java.library.path UPDATEDgoes into more detail about getting a native dependency into the library path.

Maven 和本机库:JDIC 和 java.library.path UPDATED更详细地介绍了如何将本机依赖项添加到库路径中。

Using native dependencies inside MavenIs another approach.

在 Maven 中使用本机依赖项是另一种方法。