![](/img/trans.png)
[英]Can we refer to a JavaScript inside the jar file of a Maven dependency?
[英]Maven path to file inside a dependency jar
我有一個 maven 插件,我想通過提供一個文件/目錄的路徑來配置它,該文件/目錄位於依賴項 jar 內。
這是我的 maven 項目 pom.xml 的示例。 它有一個帶有依賴項的插件,該依賴項有一個屬性作為其execution
的一部分,稱為templateDirectory
。 我想在此處放置插件依賴mylang-swagger-codegen
的路徑到依賴項內的文件/目錄{ Some path }/src/resources/api/
我怎樣才能到達這條路? 我了解像${project.basedir}
這樣的參考資料可以進入項目。 有沒有辦法可以引用依賴項並在 jar 內部訪問我想要的文件/目錄?
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.4.19</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/api/swagger.yaml</inputSpec>
<language>myLang</language>
<templateDirectory> <!-- Path here to api.mustache --> </templateDirectory>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>mylang-swagger-codegen</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
Jar 文件建立在.zip 上。 也許一個解開依賴關系的 Maven 插件可以幫助你完成你想要完成的事情。
看一下這個來解壓一個特定的工件: https://maven.apache.org/plugins/maven-dependency-plugin/examples/unpacking-artifacts.ZFC35FDC70D5FC69D23EZ8C
運行此插件后,您可以訪問解壓 jar 的路徑。 在上面的示例中,插件在 maven 的“打包”階段運行。 If you want to change the order, take a look at the maven build phases: https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.