我使用 Windows 和 ubuntu 进行 Java 开发工作。我使用 dropbox 为他们管理一个公共(public)工作区。在 ubuntu 中,我的 dropbox 文件夹位于主目录中,而在 Windows 中,它位于单独的分区中。
我想通过 dropbox 在 Windows 和 Linux 上拥有一个通用的 .m2 文件夹。据我所知,通过修改 settings.xml
中的以下行我可以实现它:
<localRepository>${user.home}/dropbox/.m2/repository</localRepository>
虽然当在 ubuntu 和 Windows 的主目录中设置保管箱时这有效,但这对我不起作用,因为我更喜欢将我的保管箱设置在 Windows 中完全不同的分区中。
有什么方法可以定义一个类似于 user.home
的新系统变量,例如在 Windows 和 ubuntu 中使用 user.dropbox.home
来实现它?
最佳答案
我终于能够通过设置自定义用户变量来做到这一点,如下所示:
Windows:
_JAVA_OPTIONS
-Duser.dropbox.maven=E:\Dropbox\maven
Linux:
_JAVA_OPTIONS
-Duser.dropbox.maven=/home/creationk/Dropbox/maven
并且settings.xml
修改如下:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>${user.dropbox.maven}/.m2/repository</localRepository>
</settings>
关于linux - 如何使用 dropbox 为 Windows 和 Linux 设置通用的 Maven 存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41662723/