failing to load log4j2 while running fatjar - java

i am working on a project where i utilize log4j2 logging.
while developing in intellij, all works fine and the logging is done as expected. the log4j2.xml is linked through java property passed to jvm on startup via intellij settings.
but once i try to run a standalone gradle built fat-jar, i'm experiencing the following problems:
java -Dlog4j.debug=true -Dlog4j.configurationFile=/home/aaa/log4j2.xml -jar /home/aaa/myjar-SNAPSHOT.jar
exceptions:
ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
...
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
i don't even understand where those [thread]s come from, since i get the same error even while using a basic simplest config in my log4j2:
<?xml version="1.0" encoding="UTF-8" ?><Configuration status="WARN" monitorInterval="86400">
<Appenders>
<Console name="console-log" target="SYSTEM_OUT">
<PatternLayout
pattern="%-5p %d{yyyy-MM-dd HH:mm:ss.SSS} ${hostName} %c{1} %msg %throwable{7}%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="info" additivity="false">
<AppenderRef ref="console-log"/>
</Root>
</Loggers>
any thoughts are welcome. thanks.

in fatJar, dependencies can provide a log4j-provider.properties in the META-INF that cause this issue,
remove it in the gradle task :
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'project',
'Implementation-Version': project.version,
'Main-Class': 'com.sample.CLI'
}
baseName = project.name + '-all'
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it).matching {
exclude 'META-INF/**.RSA'
exclude 'META-INF/MANIFEST.MF'
exclude 'META-INF/log4j-provider.properties'
} } }
with jar
}

The problem is described here: https://issues.apache.org/jira/browse/LOG4J2-673
Unfortunately at the moment there only seems to be a solution for the maven-shade-plugin: https://github.com/edwgiz/maven-shaded-log4j-transformer
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${project.artifactId}${appSuffix}</finalName>
<transformers>
...
<transformer
implementation="com.github.edwgiz.mavenShadePlugin.log4j2CacheTransformer.PluginsCacheFileTransformer">
</transformer>
</transformers>
...
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.github.edwgiz</groupId>
<artifactId>maven-shade-plugin.log4j2-cachefile-transformer</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>

Kinda late to this party, but I thought I'd add my situation, in case it helps anyone.
I build my own fat jar out of a subset of classes and jars from the larger project. The essential class runs, but I was getting all the "Unrecognized format specifier" and all. Most of the answers involve mvn shade or other such, so that wasn't helping me. But poking around, I learned that log4j-web.jar also includes the Log4jPlugins.dat file, causing the problems. Removing that from the build, and all is good.
(And I thought my build script was so tricky, including all the jars by project name, eg all jars for "log4j.")

The LoggerContextFactory binds the Log4j API to its implementation. The Log4j LogManager locates a LoggerContextFactory by locating all instances of META-INF/log4j-provider.properties, a standard java.util.Properties file, and then inspecting each to verify that it specifies a value for the Log4jAPIVersion property that conforms to the version required by the LogManager.
Incase of fat jar, you can also explicitly specify log4j2 to use LoggerContextFactory in your application by:
System.setProperty("log4j2.loggerContextFactory", "org.apache.logging.log4j.core.impl.Log4jContextFactory")
or as specified in the log4j-provider.properties file included in your log4j-core jar.

When you run your application from an IDE, jar runs itself without embedding the dependencies and you don't have conflict of log settings. But when you convert the application into a fat jar then all the dependencies will be injected into your project's jar file and your log4j settings that come from external jar files (dependencies) may be conflicted while fatJar process merge them into a single artifact.
In this case i think your "Log4j2Plugins.dat" files may be conflicted. To be sure, you can open your fatJar file with a zip editor (ex: 7Zip), navigate to path in fatJar as below and delete one of the conflicted files (you can choose smallest one by size) from your fatJar. Run the fatJar and check the logging is working properly.
\META-INF\org\apache\logging\log4j\core\config\plugins\Log4j2Plugins.dat
Now we can check the dependencies (artifacts) and find which of them contain the "Log4j2Plugins.dat" files. So you can exclude the modules that have the file from your build tool and then your fatJar creation process will exclude the conflicted files and your new fatJar can start logging as expected.
In my case, my fatJar module imports some other modules from Spring Boot and when i exclude the conflicted logging libraries, my fatJar starts logging without any error.
configurations {
all*.exclude module: 'spring-boot'
all*.exclude module: 'spring-boot-starter-logging'
all*.exclude module: 'logback-classic'
all*.exclude module: 'commons-logging'
}

Related

Logback in a Java 9 modular application not working

I have a Maven project with Java 9 and am using modules. Logback seems to support this since version 1.3.0-alpha1 but unfortunately I didn't got it to work.
I get the following message from SLF4J:
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
It looks like it can't find Logback. And inspecting the (by Jlink generated) artifact using jimage list .../modules I can't find anything about logback apart my logback.xml configuration file.
Maybe the problem lies in my module-info.java:
open module my.super.app {
requires jackson.annotations;
requires jdk.jsobject;
requires com.fasterxml.jackson.databind;
requires com.fasterxml.jackson.core;
requires javafx.graphics;
requires javafx.controls;
requires org.slf4j;
exports my.super.app;
}
How and where do I declare to depend on Logback using Java 9 modules?
Short answer: You declare it in your jlink-call by adding logback to the module path and using the --bind-services option. In your module you only define an usage of SLF4j.
Long answer:
I made it work in a simple example with the following parts.
Starting from version 1.8.0 SLF4J is modularized and uses the ServiceLoader mechanism to find its logging backend.
Logback-classic:1.3.0-alpha4 is modularized, too, and declares a service both in META-INF/services/org.slf4j.spi.SLF4JServiceProvider and in its module descriptor:
provides org.slf4j.spi.SLF4JServiceProvider with ch.qos.logback.classic.spi.LogbackServiceProvider;
SLF4J declares in its module descriptor that it needs a SLF4JServiceProvider:
uses org.slf4j.spi.SLF4JServiceProvider
Therefore, in my POM (see below) I only declare a runtime dependency to Logback and my module descriptor only contains a "requires" clause to SLF4J.
My module "com.github.gv2011.j9mod.loguse" contains a main class that logs a statement to a SLF4J-Logger.
Further, it contains a logback.xml configuration file as resource. This file is accessible to Logback because it is a "miscellaneous resource", which is a resource not in a module package (see BuiltinClassLoader source).
Logback must be added explicitely to the runtime image via the jlink "--bind-services" option (because it is a service implementation).
Additionally, Logback and its dependencies must be available on the modulepath (jlink "--module-path" option).
Module descriptor:
module com.github.gv2011.j9mod.loguse {
requires org.slf4j;
}
pom.xml:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.gv2011.j9mod</groupId>
<artifactId>j9mod-log-use</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.8.0-beta4</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.3.0-alpha4</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
</plugins>
</build>
logback.xml:
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<!-- "+++" just to make it obvious that this file is used: -->
<pattern>+++ %d{"yyyy-MM-dd'T'HH:mm:ss,SSSXXX", UTC} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="com.github.gv2011.j9mod.loguse.Main" level="INFO" />
<root level="WARN">
<appender-ref ref="STDOUT" />
</root>
</configuration>
Main-Class:
package com.github.gv2011.j9mod.loguse;
import static org.slf4j.LoggerFactory.getLogger;
import org.slf4j.Logger;
public class Main {
private static final Logger LOG = getLogger(Main.class);
public static void main(final String[] args) {
LOG.info("Tach.");
}
}
Output (Eclipse - Run As - Java Application):
+++ 2019-05-09T17:43:20,594Z [main] INFO com.github.gv2011.j9mod.loguse.Main - Tach.
jlink:
%JAVA_HOME%\bin\jlink.exe ^
--output target\image ^
--module-path ^
target\classes;^
%M2_REPO%\org\slf4j\slf4j-api\1.8.0-beta4\slf4j-api-1.8.0-beta4.jar;^
%M2_REPO%\ch\qos\logback\logback-classic\1.3.0-alpha4\logback-classic-1.3.0-alpha4.jar;^
%M2_REPO%\ch\qos\logback\logback-core\1.3.0-alpha4\logback-core-1.3.0-alpha4.jar ^
--bind-services ^
--launcher hello=com.github.gv2011.j9mod.loguse/com.github.gv2011.j9mod.loguse.Main ^
--add-modules com.github.gv2011.j9mod.loguse
Output (target/image/bin/hello):
+++ 2019-05-10T11:45:24,844Z [main] INFO com.github.gv2011.j9mod.loguse.Main - Tach.
Tested with openjdk-11.0.2_windows-x64, apache-maven-3.6.0 and eclipse-jee-2019-03-R-win32-x86_64 on Windows 10, 64 Bit.
I finally figured it out. At the end, I just added Logback as a dependency in my module-info.java:
open module my.super.app {
requires jackson.annotations;
requires jdk.jsobject;
requires com.fasterxml.jackson.databind;
requires com.fasterxml.jackson.core;
requires javafx.graphics;
requires javafx.controls;
requires org.slf4j;
requires ch.qos.logback.classic; //only runtime dependency
exports my.super.app;
}
I guess there is no way to declare a runtime dependency (similar to Maven) - it is now also required at compile time.

How to use custom delimiter when creating filtered fileSets in a maven artefact?

I'm trying to create a custom maven artefact that creates a basic Java Handler for AWS Lambda. One of the files in my archetype-resources is a serverless.yml file as we are looking to deploy this handler using the ServerLess Framework. I want this file to be part of a filtered=true fileSet as I want to pre-populate certain fields based on the project groupId, projectId etc. Here's a sample:
service: cmpy-prefix-${groupId}-${artifactId}-service
# exclude the code coverage files and circle ci files
package:
exclude:
- coverage/**
- .circleci/**
...
profider:
...
environment:
S3_BUCKET_NAME: ${self:provider.stage}-cmpy-bkt
And I add this file to src/main/resources/META-INF/maven/archetype-metadata.xml as follows:
<fileSet encoding="UTF-8" filtered="true" packaged="false">
<directory></directory>
<includes>
<include>serverless.yml</include>
</includes>
</fileSet>
Now my problem is that serverless.yml file contains ${self:provider.stage} which interfere's when I run maven:generate for this archetype and the error I get is:
org.apache.velocity.exception.ParseErrorException: Encountered ":provider.stage}-cmpy-bkt\...
I tried to set the <delimiter> for the maven-resource-plugin in the pom.xml for my main archetype to no avail. Essentially, I added the following to the pom of the archetype project:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${org.apache.maven.plugins.maven-resources-plugin.version}</version>
<configuration>
<addDefaultExcludes>false</addDefaultExcludes>
<delimiters>$[*]</delimiters>
</configuration>
</plugin>
</plugins>
</build>
But I still face the same problem when I try to generate a new project using this archetype. The maven archetype plugin seems to be ignoring the delimiter.
Any advice/help on how I can fix this will be immensely appreciated.
Found the solution. I had not realised I could add Velocity directives in my archetype files.
See this other Stackoverflow post for hints Maven archetype strips comments

Log4j2 api cannot find Log4j2 core in OSGi environment

I'm trying to use log4j2 OSGi bundles, but it seems log4j2 api cannot find log4j2 core in an OSGi environment. I'm continuously getting the following exception :
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console
I found the same exception discussed in few places but still I could not figure out this issue. Isuspect I'm getting this issue because log4j2 api cannot find the log4j-provider.properties inside the META-INF directory of log4j2 core.
Is there any clue why I'm getting this exception and how can I correct the issue ?
(If anybody has correct pom file for adding log4j dependencies and bundling please share it with me)
These are the dependencies I have used
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.2</version>
</dependency>
I use apache felix as the bundle plugin. This error occures because resources inside the META-INF of log4j2-core specially the log4j-providoer.properties file is not visible to log4j api.
Thanks!
The log4j-core bundle registers a bundle listener when the Activator is started and starts searching for log plugins and if something is found it performs a sequence of operations similar to the usual Logger initialization (not really idiomatic OSGi stuff and i'm not sure it works, but it seems to set at least Log4jContextSelector and LoggerContextFactory), just to be sure of it, did you install and start the log4j-core bundle and verified that nothing changed?
Update:
I did some testing and found what is an acceptable solution/workaround for log4j2 OSGi issues. But as someone else recommended, alternatively i would use slf4j, pax-logging or simply the OSGi Log Service (the simpler of the bunch).
#Grant, you have 2 separate things that need to be fixed:
1. As you described, the "Log4j2 could not find a logging implementation" error is caused by the fact that the log4j2-api bundle is unable to find the log4j-provider.properties file and, after that is fixed, log4j2-api cannot find the log4j2-core classes (it's a different bundle and log4j2-api doesn't have a specific Import-Package: for those classes).
The workaround for this is to create a small fragment bundle for log4j2-api (i called mine log4j-api-config.jar) with that .properties file in META-INF and a manifest that forces a dynamic import:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Log4j API configurator
Bundle-SymbolicName: org.apache.logging.log4j.apiconf
Bundle-Version: 1.0.0
Bundle-Vendor: None
Bundle-RequiredExecutionEnvironment: OSGi/Minimum-1.2
Fragment-Host: org.apache.logging.log4j.api
DynamicImport-Package: *
I'm importing * here, you can improve it adding the required subset of log4j2-core packages that log4j2-api needs.
With this, that error will disappear, but log4j will notice that you didn't provide a log4j2 configuration file, next thing to fix (only if you care in this case).
2. At this point Felix will display this:
log4j2.xml not found by org.apache.logging.log4j.core
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
and i suppose you could want to add your own log4j2.xml without messing with the original log4j2-core.jar. You can do this creating another fragment bundle, this time hosted by log4j2-core, with just a log4j2.xml configuration file in the root and a simple manifest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Log4j Core configurator
Bundle-SymbolicName: org.apache.logging.log4j.coreconf
Bundle-Version: 1.0.0
Bundle-Vendor: None
Bundle-RequiredExecutionEnvironment: OSGi/Minimum-1.2
Fragment-Host: org.apache.logging.log4j.core
I used this simple log4j2.xml configuration during my tests:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
With this you will not need that sort of "bridge" bundle you described below anymore, and you'll just need a simple Import-Package: org.apache.logging.log4j to use log4j from your bundle.
Update 2:
Important to note that the two fragments are NOT dependencies of the original bundles (no need to modify log4j jars or or even your bundles to add import/export), so the original bundles and your own custom ones will remain untouched.
Also, they don't depend on the original bundle either, they are just basic jar archive with a manifest and an additional text file, no code, no need for Import-Package or Export-Package.
You just need to install each fragment after their host bundle is installed.
I've created both fragments manually starting from an empty jar and copying inside the archive the properties file and modifying the MANIFEST.MF with a text editor, you can create them both with this pom.xml, remember to copy log4j-provider.properties where pom.xml is located.
For the log4j2-api fragment:
<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>my.group</groupId>
<artifactId>log4j2-api-config</artifactId>
<version>1.0</version>
<name>log4j2-api-config</name>
<packaging>bundle</packaging>
<properties>
<java-version>1.7</java-version>
</properties>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.0.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>org.apache.logging.log4j.apiconf</Bundle-SymbolicName>
<Bundle-Name>Log4j API Configurator</Bundle-Name>
<Bundle-Version>1.0.0</Bundle-Version>
<Fragment-Host>org.apache.logging.log4j.api</Fragment-Host>
<DynamicImport-Package>
*;resolution:=optional
</DynamicImport-Package>
</instructions>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>.</directory>
<includes>
<include>log4j-provider.properties</include>
</includes>
<targetPath>META-INF</targetPath>
</resource>
</resources>
</build>
</project>
Modify this pom where appropriate(included file, bundle names) to generate the other one with the log4j2-core configuration.
Log4j is not suitable for an OSGi environment. Luckily there is a nice drop in replacement pax-logging. In your bundle you use the log4j api or any other of the supported apis (I prefer slf4j-api). Then you deploy pax logging to your OSGi framework and your bundle.
You can configure pax logging using a standard log4j config. So it is very easy to use. If you want a really easy start you can simply install apache karaf and deploy your bundle to it. Karaf already includes a fully set up pax logging.
Try changing the name of the jar file something does not contain core word (eg:log4j-zore) and try again
You need specify OSGI related dependencies on Your bundle in META-INF/MANIFEST.MF by add the following dependencies:
Require-Bundle: org.apache.logging.log4j.core;org.apache.logging.log4j.api
For me this error is resolved by:
ensuring that the log4j-api bundle is actually activated - and not just resolved - before calling the logger. I did this by setting it to Auto-Start with a low start level.
let log4j-api import classes of log4j-core (as mentioned by #uraime) to make sure it finds log4j-core. The cleanest way to do this is using a fragment. Instead of dynamic import you could also add this to the manifest:
Require-Bundle: org.apache.logging.log4j.core
I also use a fragment for log4j-core to let it find my log4j2.xml configuration file, but when not using this fragment, log4j will show a different error message.
Additionally I found that it's not required for the log4j-core bundle to be activated (only resolved) but note that this does mean that the Activator cannot find custom log4j2 plugins.

Exclude resources from java maven build

There seem to be many many posts about similar questions however I have been unable to find exactly what I am looking for.
Basically, I have a Java Application built using Maven in Eclipse. When I execute the project from withing Eclipse it works correctly as it can find all files in my resources directory. When I do a normal jar with dependencies build using maven it also works. However, in the final item I cannot get this to work:
I would like the resources to be excluded from the main executable jar and placed into a directory on the same level as the jar itself. This was a user can just make changes to the settings and execute the jar, so:
|--root level
|-Jar
|-resources
|-log4j.properties
|-settings.properties
I have the maven-jar-plugin doing this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<index>true</index>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.org.interfaces.SharepointClient.App</mainClass>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
<manifestEntries>
<mode>development</mode>
<url>http://org.com</url>
<key>value</key>
<Class-Path>resources/settings.properties resources/log4j.properties</Class-Path>
</manifestEntries>
</archive>
<excludes>
<exclude>settings.properties</exclude>
<exclude>log4j.properties</exclude>
</excludes>
</configuration>
</plugin>
And I have the maven-assembly-plugin creating the resources directory with all the resource files.
The project compiles and generates the directory structure as I want it however, the class files are unable to locate anything in the resources directory even though I specifically added them the classpath in the manifest.mf
This is the Manifest for details:
Manifest-Version: 1.0
Build-Jdk: 1.7.0_17
Class-Path: resources/settings.properties resources/log4j.properties
lib/log4j-1.2.17.jar lib/jaxws-api-2.2.11.jar lib/jaxb-api-2.2.9.ja
r lib/javax.xml.soap-api-1.3.5.jar lib/javax.annotation-api-1.2-b03
.jar lib/jsr181-api-1.0-MR1.jar lib/saxon-9.1.0.8.jar lib/saxon-9.1
.0.8-dom.jar
Created-By: Apache Maven 3.0.5
Main-Class: com.org.interfaces.SharepointClient.App
key: value
url: http://org.com
mode: development
Archiver-Version: Plexus Archiver
When Executed I receive an error on this line of code:
PropertyLoader.class.getClassLoader().getResourceAsStream("settings.properties");
The error is:
Exception in thread "main" java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Unknown Source)
at java.util.Properties.load0(Unknown Source)
at java.util.Properties.load(Unknown Source)
at com.org.interfaces.SharepointClient.PropertyLoader.getProps(PropertyLoader.java:29)
EDIT:
I am only having trouble getting java to load resources, not dependencies. Those appear to load correctly.
I think you are making this more difficult that it need be. Take a look at this http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html. You should simply add all of your dependencies to the pom.xml file. This way, whenever you transport your code, maven will use the pom.xml file to rebuild the project with all of your dependencies. http://mvnrepository.com/ makes it even easier. All you have to do is search for the dependency in the repository, and copy it into your pom file.

Maven Eclipse plugin doesn't regard Maven failsave plugin?

I'm just using Maven to build my project and also my eclipse project settings. The eclipse:eclipse target generates the .classpath file for eclipse regarding the dependencies and other project settings like source directory, test source directory and so on. Now I added the Maven failsafe plugin and defined a <testSourceDirectory>/test/integration</testSourceDirectory> beside my normal (junit) test directory.
test/unit -> contains my junit test cases which are executes in maven "test" phase
test/integration -> contains my integration (maybe also junit) test cases, executed in maven phase "integration-test".
Works fine BUT eclipse plugin won't consider my <testSourceDirectory> and won't add it as entry into my .claspath file :-( Is there a way to manipulate the eclispe plugin to add the classpath entry from the failsafe plugin? I already the following:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<additionalConfig>
<file>
<name>.classpath</name>
<content>
<![CDATA[<classpathentry kind="src" path="test/integration" output="build/compile/test-classes"/>]]>
</content>
</file>
</additionalConfig>
</configuration>
</plugin>
But this results in overidden .classpath file whith the above entry as single line.. :-(
Has someone a good idea to slve it?
cheers, Yellomen
Have you tried specifying your integration dir in sourceIncludes as described here?

Categories