【问题标题】:how to include file from one module to another module in multi module maven project如何在多模块maven项目中将文件从一个模块包含到另一个模块
【发布时间】:2016-12-29 03:21:04
【问题描述】:

我正在开发一个多模块项目的 maven 项目,我想将 moduleA/src/main/bin/abc.sh 中的文件包含到其他模块中,比如 moduleB,它已经具有类似 moduleB/src/main 的结构/bin/pqr.sh 在构建项目时,模块的结构就像 moduleB/bin/..*.sh 如何在 moduleB 中包含 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]

【问题讨论】:

  • 看来启动脚本的用户权限不够。如果在项目的根目录下运行 sudo chmod 777 -R 会怎样?
  • 将文件复制到您当然没有权限的/bin/ 根本没有意义。而且你不应该在 Maven 构建期间这样做......

标签: java maven


【解决方案1】:

如果您真的在机器的/bin 目录中工作,您应该知道,要在UNIX 上的此目录中工作,您需要root 帐户。

另外,在这种情况下,我建议不要在您的机器上使用ROOT ACCOUNT。

我建议改为授予 read 访问您当前用于打包您的应用程序的用户。

命令:

sudo chmod o+r /bin/abc.sh

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-12
    • 1970-01-01
    • 1970-01-01
    • 2015-02-20
    • 2020-01-26
    • 1970-01-01
    • 2018-07-24
    相关资源
    最近更新 更多