Maven依赖插件目标/类-访问被拒绝 [英] maven-dependency-plugin target/classes - Access is denied

查看:478
本文介绍了Maven依赖插件目标/类-访问被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多模块项目,一个父项目A,两个子项目B和C.项目B对项目C有依赖关系.我使用maven-dependency-plugin将B的依赖关系复制到lib/target/目录中的目录.因此,我可以使用maven-assembly-plugin在最终的zip文件中包含这个lib/目录.问题是在项目B上运行mvn clean package时出现以下错误:

在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ...还有19个

由以下原因引起:java.io.FileNotFoundException:D:\ projects-directory目录\ C \ target \ classes(访问被拒绝)

在java.io.FileInputStream.open(本机方法)

在java.io.FileInputStream.(FileInputStream.java:120)

在org.codehaus.plexus.util.io.FileInputStreamFacade.getInputStream(FileInputStreamFacade.java:36)

在org.codehaus.plexus.util.FileUtils.copyStreamToFile(FileUtils.java:1141)

在org.codehaus.plexus.util.FileUtils.copyFile(FileUtils.java:1048)

在org.apache.maven.plugin.dependency.AbstractDependencyMojo.copyFile(AbstractDependencyMojo.java:192) ...另外23个

有人有主意吗?

我已经在网络上进行了一些研究,发现存在这样的问题(请参见 http://jira.codehaus.org/browse/MWAR-192 ,用于战争,但我对JAR也有类似的问题).似乎无法访问项目C的target/classes目录来创建C.jar(C.jar必须包含在项目B的lib/目录中).

谢谢

解决方案

我也使用配置也遇到了这个问题

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
        <archive>
            <index>true</index>
            <manifest>
                <addClasspath>true</addClasspath>
            </manifest>
            <manifestEntries>
                <mode>development</mode>
                <url>${project.url}</url>
                <key>value</key>
            </manifestEntries>
        </archive>
    </configuration>
    ...
</plugin>
 

由清单自定义示例提供,该示例位于 http://maven.apache.org/plugins/maven-jar-plugin/examples/manifest-customization.html .我将其诊断为<index>true</index>,因为该部分被注释掉后问题消失了,并验证了这是maven jar插件的2.3.2、2.3.1、2.3、2.2、2.1版的问题.

根据Maven插件jira进行操作-请参见 https://jira.codehaus.org/browse /MJAR-69 -它已经修复

I have a multi module project with a parent project A, and two childs project B and C. Project B has a dependency on project C. I use the maven-dependency-plugin to copy the dependencies of B to a lib/ directory in the target/ directory. So, I can use the maven-assembly-plugin to include this lib/ directory in the final zip. The problem is I get the following error when I run mvn clean package on project B:

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more

Caused by: java.io.FileNotFoundException: D:\path-to-projects-directory\C\target\classes (Access is denied)

at java.io.FileInputStream.open(Native Method)

at java.io.FileInputStream.(FileInputStream.java:120)

at org.codehaus.plexus.util.io.FileInputStreamFacade.getInputStream(FileInputStreamFacade.java:36)

at org.codehaus.plexus.util.FileUtils.copyStreamToFile(FileUtils.java:1141)

at org.codehaus.plexus.util.FileUtils.copyFile(FileUtils.java:1048)

at org.apache.maven.plugin.dependency.AbstractDependencyMojo.copyFile(AbstractDependencyMojo.java:192) ... 23 more

Someone has an idea?

I've done some research on the web and I found that there is such an issue (see http://jira.codehaus.org/browse/MWAR-192 , that's for the wars but I have the similar problem with JAR). It seems that the target/classes directory of project C can't be accessed to create the C.jar (the C.jar must be included in the lib/ directory of project B).

Thanks

解决方案

I just ran into this issue as well using the configuration

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
        <archive>
            <index>true</index>
            <manifest>
                <addClasspath>true</addClasspath>
            </manifest>
            <manifestEntries>
                <mode>development</mode>
                <url>${project.url}</url>
                <key>value</key>
            </manifestEntries>
        </archive>
    </configuration>
    ...
</plugin>

provided from the manifest customization example at http://maven.apache.org/plugins/maven-jar-plugin/examples/manifest-customization.html. I diagnosed it to the <index>true</index> as the problem went away when that part was commented out, and verified that this was an issue for versions 2.3.2, 2.3.1, 2.3, 2.2, 2.1 of the maven jar plugin.

According to the maven plugin jira -- see https://jira.codehaus.org/browse/MJAR-69 -- it's just been fixed

这篇关于Maven依赖插件目标/类-访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆