2016-08-12 215 views
1

我使用maven-assembly-plugin創建tar.gz存檔。現在我需要在檔案中包含文件。這些只是一些普通的舊文本文件,在運行時是依賴項,而不是在編譯或(單元)測試時間。Maven:添加非JAR依賴關係

我想過要添加一個Maven依賴關係,但這些文件並不存儲在Maven倉庫中,而是存儲在一個簡單的刪除文件夾中。更糟糕的是,該文件夾受密碼保護。我可以在預先構建步驟中將這些受密碼保護的文件下載到本地文件夾中。但是,在裝配中使用這些文件仍然存在問題。另外,這是我想避免的額外工作。

有沒有辦法做到這一點?

+0

如果你想要做的是從遠程文件夾下載文件並壓縮它們,爲什麼你想用maven做到這一點? –

+0

@AssenKolov我想將外部文件包含在與Maven構建,測試和打包的檔案中。 – Christoph

+0

你可以將你的文件作爲一個程序集從maven工作中發佈出來,並有一個構建最終壓縮文件的生成後步驟腳本。 –

回答

0

如果您可以下載這些文件,解決方法密碼。也許這會有所幫助。
創建模組件項目中,你把這樣的事情:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> 
<id>${artifact.version}</id> 
<formats> 
    <format>zip</format> 
</formats> 
<includeBaseDirectory>false</includeBaseDirectory> 
<dependencySets> 
    <dependencySet> 
     <useProjectArtifact>false</useProjectArtifact> 
     <useTransitiveDependencies>true</useTransitiveDependencies> 
     <unpack>false</unpack> 
     <excludes> 
      <exclude>${project.groupId}:*:*</exclude> 
     </excludes> 
     <outputFileNameMapping>project${timestamp}_code-${artifact.name}.${artifact.extension}</outputFileNameMapping> 
    </dependencySet> 
</dependencySets> 
<fileSets> 
    <fileSet> 
     <includes> 
      <include>readme.txt</include> <!-- here's that plain file --> 
     </includes> 
    </fileSet> 
</fileSets> 

您可以在文件集的那些文件。 http://maven.apache.org/plugins/maven-assembly-plugin/examples/single/filtering-some-distribution-files.html欲瞭解更多信息