maven exec插件 - logback不能正常运行

时间:2011-09-06 13:53:06

标签: java maven logback

我有一个maven项目,它保存配置信息并将其打包在一个zip文件中。我使用maven依赖插件将内容解压缩到$ {project.build.directory} / unpacked,然后运行资源插件来过滤内容并将它们直接转储到$ {project.build.directory}。

当我运行maven exec时,我的logback.xml没有被选中。似乎类路径设置为$ {basedir},但我希望它同时包含$ {project.build.directory},它和测试类,以及类。

无论何时我尝试添加一个classpath元素,都会出现配置错误。

我应该如何配置我的pom.xml来支持这一点,这是否可能?

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>

                    <executions>
                        <execution>
                            <id>run</id>
                            <phase>package</phase>
                            <goals>
                                <goal>java</goal>
                            </goals>
                        </execution>
                    </executions>

                    <configuration>
                        <workingDirectory>${project.build.directory}</workingDirectory>

                        <mainClass>${jar.mainClass}</mainClass>
                    </configuration>
                </plugin>

1 个答案:

答案 0 :(得分:0)

这应该可以解决问题。

        <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.3.1</version>
            <configuration>
                <archive>
                    <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <!-- <classpathPrefix></classpathPrefix> -->
                        <mainClass>com.stackoverflow.test</mainClass>
                    </manifest>

                    <manifestEntries>
                        <Class-Path>${project.build.outputDirectory}/unpacked/logback.xml</Class-Path>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>