簡體   English   中英

如何在多模塊Maven項目中將文件從一個模塊包含到另一個模塊

[英]how to include file from one module to another module in multi module maven project

我正在一個Maven項目中,這是一個多模塊項目,我想將文件從moduleA / src / main / bin / abc.sh包含到其他模塊,例如moduleB,它已經具有其結構,例如moduleB / src / main / bin / pqr.sh在構建項目時,模塊的結構類似於moduleB / bin /..*。sh。如何在abcB中包含abc.sh?我曾嘗試使用maven-resources-plugin作為

  <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-cleanup</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>/bin</outputDirectory>
                        <overwrite>true</overwrite>
                        <resources>
                            <resource>
                                <directory>${multi.module.project.root.dir}/modules/abc/src/main/bin</directory>
                                <includes>
                                    <include>abc.sh</include>
                                </includes>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

這給我在構建項目時出錯

Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.0.1:copy-resources (copy-cleanup) on project moduleB: /bin/abc.sh (Permission denied) -> [Help 1]

如果您確實在計算機的/bin目錄中工作,則應注意,要在UNIX上的此目錄中工作,您需要root帳戶。

另外,在這種情況下,我建議不要在您的計算機上使用ROOT帳戶

我建議改為授予您當前用於打包應用程序的用戶的read訪問權限。

命令:

sudo chmod o+r /bin/abc.sh

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM