Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get maven-jaxb-schemagen-plugin working with Java 7?

When I try to use maven-jaxb-schemagen-plugin with java 7

<groupId>com.sun.tools.jxc.maven2</groupId>
<artifactId>maven-jaxb-schemagen-plugin</artifactId>
<version>1.2</version>

I get an error:

[ERROR] Failed to execute goal com.sun.tools.jxc.maven2:maven-jaxb-schemagen-plugin:1.2:generate (default) on project TopologyProvisionerDom: Execution default of goal com.sun.tools.jxc.maven2:maven-jaxb-schemagen-plugin:1.2:generate failed: A required class was missing while executing com.sun.tools.jxc.maven2:maven-jaxb-schemagen-plugin:1.2:generate: com/sun/mirror/apt/AnnotationProcessorFactory

It seems like the AnnotationProcessorFactory is being removed/deprecated in Java 7? Is it possible to get jaxb schemagen to work using this plugin? Is there an alternative approach to get schema generation from the JAXB source code when using JDK 7?

like image 906
lexicalscope Avatar asked Dec 13 '11 17:12

lexicalscope


2 Answers

Have you tried using the org.codehaus.mojo:jaxb2-maven-plugin instead?

like image 153
Donal Fellows Avatar answered Nov 15 '22 22:11

Donal Fellows


This is how it works (add this profile to your pom.xml):

<profile>
    <id>jdk7-fix</id>
    <activation>
        <file><exists>${java.home}/../lib/tools.jar</exists></file>
    </activation>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.sun.tools.jxc.maven2</groupId>
                    <artifactId>maven-jaxb-schemagen-plugin</artifactId>
                    <dependencies>
                        <dependency>
                            <groupId>com.sun</groupId>
                            <artifactId>tools</artifactId>
                            <version>1.7</version>
                            <scope>system</scope>
                            <systemPath>${java.home}/../lib/tools.jar</systemPath>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</profile>
like image 27
yegor256 Avatar answered Nov 15 '22 20:11

yegor256