添加< outputDirectory>时类路径为空pom [英] Classpath empty when adding <outputDirectory> to pom
问题描述
我正在使用这个简单的pom.xml
通过maven-bundle-plugin
生成OSGi捆绑包:
I am using this simple pom.xml
to generate an OSGi-bundle using the maven-bundle-plugin
:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.test.osgi</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
这可以按预期工作(该项目包含一个公共类,我已经确认将其导出到分发包中).现在,如果我将以下<configuration>
添加到插件中:
This works as expected (that project contains a single public class that I have verified to be exported in the bundle). Now , if I add the following <configuration>
to the plugin:
<configuration>
<outputDirectory>D:\Test</outputDirectory>
</configuration>
构建因以下错误而失败:
the build fails with the following error:
[INFO] --- maven-bundle-plugin:2.3.7:bundle (default-cli) @ test ---
[WARNING] Bundle de.test.osgi:test:bundle:0.0.1-SNAPSHOT : Classpath is empty. Private-Package and Export-Package can only expand from the classpath when there is one
[WARNING] Bundle de.test.osgi:test:bundle:0.0.1-SNAPSHOT : Instructions in Private-Package, or -testpackages that are never used: .*
Classpath:
[ERROR] Bundle de.test.osgi:test:bundle:0.0.1-SNAPSHOT : The JAR is empty: dot
[ERROR] Error(s) found in bundle configuration
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.891s
[INFO] Finished at: Fri Mar 30 14:49:46 CEST 2012
[INFO] Final Memory: 8M/20M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.felix:maven-bundle-plugin:2.3.7:bundle (default-cli) on project test: Error(s) found in bundle configuration -> [Help 1]
为什么类路径为空? <outputDirectory>
与它有什么关系?这是一个错误,还是我误解了某些东西?
Why is the classpath empty? What does the <outputDirectory>
have to do with it? Is this a bug, or have I misunderstood something?
修改
使用debug-output运行可以发现类路径确实与<outputDirectory>
相同.默认情况下,这是mavens target
目录,因此他将在其中找到要包含在捆绑软件中的类.如果更改它,它将指向一个不包含要包含的类的目录.令人困惑的是,
Edit
Running with debug-output reveals that the classpath is indeed identical with <outputDirectory>
. By default, this is mavens target
directory, so he will find the classes to include in the bundle there. If I change it, it will point to a directory that contains no classes to include. Confusingly, the documentation for the plugin says that <outputDirectory>
is:
生成的包的目录.
The directory for the generated bundles.
这是一个错误吗?
推荐答案
outputDirectory
也是编写类的地方-有关空类路径点"的错误是由于给maven-bundle-plugin一个空目录造成的
outputDirectory
is where the compiled classes have been written too - the error regarding empty classpath "dot" is due to giving maven-bundle-plugin an empty directory.
bundle插件将MANIFEST.MF写入outputDirectory位置,这也是它希望在其中查找该bundle的任何其他元数据(例如scr插件的输出)的地方.
The bundle plugin writes the MANIFEST.MF to the outputDirectory location and this is also where it expects to find any other metadata (e.g. scr plugin's output) for the bundle.
您是否正在使用编译器插件?如果不是这样,它看起来像是捆绑插件中的错误,它在调用编译器时不遵循outputDirectory(但是在其他所有地方都遵循它).
Are you using the compiler plugin? If not it looks like a bug in the bundle plugin not honouring the outputDirectory when it calls the compiler (but honouring it everywhere else).
正如@nobeh所指出的,如果${project.build.outputDirectory}
和outputDirectory
指向相同的位置,您应该没事.
As @nobeh points out, you should be fine if ${project.build.outputDirectory}
and outputDirectory
point to the same location.
这篇关于添加< outputDirectory>时类路径为空pom的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!