0

I'm new to maven, I've a xsd file and am trying to generate JAXB classes for that but the below code is not generating any classes. Below is part of my pom.xml, after adding jaxb2-maven-plugin I did maven clean and maven install and there are no classes generated. Am I missing something or have I misplaced it ? any help would be appreciated.

Update : I was able to generate classes when I ran the command mvn jaxb2:xjc , but not when I do mvn clean install. What should be done for this ?

    <build>
        <finalName>${project.artifactId}</finalName>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>buildinfo.txt</include>
                    <include>log4j.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>buildinfo.txt</exclude>
                    <exclude>log4j.xml</exclude>
                </excludes>
                <filtering>false</filtering>
            </resource>
        </resources>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>1.6.0</version>
                    <executions>
                        <execution>
                            <id>some-execution</id>
                            <phase>compile</phase>
                            <goals>
                                <goal>exec</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <executable>java</executable>
                        <workingDirectory>target</workingDirectory>
                        <arguments>
                            <argument>-cp</argument>
                            <argument>classes:${rev-trac-properties}:dependency/*</argument>
                            <argument>-Xdebug</argument>
                            <argument>-Xrunjdwp:transport=dt_socket,address=${dport},server=y,suspend=n</argument>
                            <argument>-Dtrac.home="${trac.home}"</argument>
                            <argument>com.rev.trac.service.app.MainApp</argument>
                        </arguments>
                    </configuration>
                </plugin>
                <!-- My code -->
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>jaxb2-maven-plugin</artifactId>
                    <version>1.6</version>
                    <executions>
                        <execution>
                            <id>xjc</id>
                            <goals>
                                <goal>xjc</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                    <schemaDirectory>src/main/webapp/schemas/</schemaDirectory>
                    <schemaFiles>syncConfig.xsd</schemaFiles>
                    <packageName>com.example.mapping</packageName>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>2.3.1</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                    <encoding>ISO-8859-1</encoding>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <finalName>${project.artifactId}-${project.version}</finalName>
                    <descriptors>
                        <descriptor>assembly.xml</descriptor>
                    </descriptors>
                    <appendAssemblyId>false</appendAssemblyId>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>${eclipsePluginVersion}</version>
                <configuration>
                    <!-- by default download all sources when generating project files -->
                    <downloadSources>true</downloadSources>
                    <classpathContainers>
                        <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER/${vmtype}/${jdkName}</classpathContainer>
                    </classpathContainers>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.18</version>
            </plugin>
        </plugins>
    </build>

Preeti
  • 69
  • 1
  • 8
  • What is the output of mvn jaxb2:xjc – user1717259 Nov 21 '19 at 13:39
  • I thought if we didn't specify the the classes generate at target\generated-sources. Anyway I did add it, but still no luck.. – Preeti Nov 21 '19 at 15:19
  • I understood what you meant by 'output of mvn jaxb2:xjc' now. I ran this command and I could see the classes getting generated. Now my question is, why are the classes not getting generated when I just give mvn clean install ? Please help.. – Preeti Nov 27 '19 at 11:02
  • When you run mvn install, does it log anything under the generate-sources phase? – user1717259 Nov 27 '19 at 16:59
  • yes, when I do mvn install, in generated sources I can see annotations, test annotations(both empty) and a zip file. but no jaxb classes. – Preeti Nov 28 '19 at 11:07

0 Answers0