Search code examples
maven-plugincode-generationxmlbeans

How to pass log4j-core to xmlbeans maven generation phase?


I found the description of the xmlbeans 5 maven plugin configuration. It tells to add the dependency on log4j-core of the schema generation to the configuration.

However, it seems not to work. I still get the error message

SchemaCompiler  Metadata LOAD:org/apache/xmlbeans/metadata GEN:eu/ngong/eaGuid
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...

Obviously the SchemaCompiler needs log4j-core while generating. Is there another way to put log4j-core onto the classpath while generating?


Solution

  • The related question helped me.

    I had to add the dependency in pom.xml directly in the plugin clause:

    <plugin>
        <groupId>org.apache.xmlbeans</groupId>
        <artifactId>xmlbeans</artifactId>
        <version>5.1.1</version>
        <executions>
            <execution>
                <goals>
                    <goal>compile</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <repackage>eu.ngong.tstLog</repackage>
            <name>tstLog</name>
            <noAnn>true</noAnn>
            <partialMethods>ALL,-GET_ARRAY,-XGET_LIST,-XGET_ARRAY</partialMethods>
            <xmlConfigs>${basedir}/src/main/schema/tstLog.xsdconfig</xmlConfigs>
        </configuration>
        <dependencies>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
                <version>2.20.0</version>
            </dependency>
        </dependencies>
    </plugin>