在我的xtext dsl项目中使用maven jar文件的正确方法是什么?
我试过的是这个:
pom.xml
文件中的*.dsl
将.jar
文件从maven存储库下载到./lib/
目录中。这在构建过程中尽早完成:在maven validate phase中MANIFEST.MF
中:将jar添加到类路径中:例如Bundle-ClassPath: ., lib/value-2.5.6-annotations.jar
build.properties
:将它添加到bin.includes
问题是,只有当我两次调用mvn install
时,构建才有效。
第一次,.jar
文件按预期(在构建过程的早期)下载到lib
目录,但随后构建失败,因为它无法解析我的jar file
中的类型。
当我再次运行mvn install
(.jar
文件现在已经存在于构建之前的lib
目录中)时,它工作正常。
任何想法如何解决这个问题?
目前它没有按预期工作,因为Tycho的错误
以下是我在xxx.dsl
项目中所做的工作(现在):
lib
目录。stripVersion=true
,以便lib
目录中的文件称为value-annotations.jar
(而不是value-2.5.6-annotations.jar
)。如果我以后想要更新版本,我只需要在pom.xml
文件中的一个位置更新它。generateXtext
的xtext-gradle-plugin任务将失败,因为它无法在jar文件中找到类。相关的pom.xml
代码:
<project ...>
<properties>
<xtextVersion>2.13.0</xtextVersion>
<immutablesVersion>2.5.6</immutablesVersion>
...
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-libraries</id>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<version>${immutablesVersion}</version>
<classifier>annotations</classifier>
<outputDirectory>lib</outputDirectory>
</artifactItem>
</artifactItems>
<stripVersion>true</stripVersion>
</configuration>
</execution>
</executions>
</plugin>
...
</build>
<dependencies>
<dependency>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<version>${immutablesVersion}</version>
<classifier>annotations</classifier>
</dependency>
</dependencies>
</project>
Bundle-ClassPath
,以便我们可以使用它:例如在DslJvmModelInferrer.xtend
Export-Package
,以便xxx.dsl.tests
项目可以访问这些文件MANIFEST.MF
的相关部分:
Bundle-ClassPath: ., lib/value-annotations.jar
Export-Package: xxx.xtext,
...
xxx.xtext.validation,
org.immutables.value
将jar文件添加到bin.includes
,以便将其复制到生成的jar文件(在target
目录中):
bin.includes=model/generated/,\
.,\
META-INF/,\
lib/value-annotations.jar,\
plugin.xml
现在构建在Eclipse中工作。
在命令行上(以及在我的持续集成服务器脚本中),我必须执行两次maven(因为提到的错误):
mvn verify
(下载罐子)mvn install