简体   繁体   中英

maven can't find generated sources (mvn clean install)

I've just got the problem some hours ago and it always seemd to working until now.

I generate code in my pom on the following way:

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

            <configuration>
                <sourceDestDir>${basedir}/target/generated/java</sourceDestDir>
                <keep>true</keep>
                <verbose>true</verbose>
                <extension>true</extension>
                <wsdlDirectory>${basedir}/src/main/resources/META-INF</wsdlDirectory>
            </configuration>

            <executions>
                <execution>
                    <id>ecad-ws</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <wsdlFiles>
                            <wsdlFile>wsdl/ECadDocumentServiceWSDL.wsdl</wsdlFile>
                        </wsdlFiles>
                        <staleFile>${project.build.directory}/jaxws/stale/wsdl.ECadDocumentServiceWSDL.done</staleFile>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemaDirectory>${basedir}/src/main/resources/META-INF/xsd</schemaDirectory>
                    <packageName>be.fgov.health.ecad.xmlstructure</packageName>
                <outputDirectory>${basedir}/target/generated/java</outputDirectory>
            </configuration>
        </plugin> 

and I use those generated classes in my project. If I then do a "right click -> maven -> clean" + "right click -> maven -> install" everything is working. But when I run mvn clean install -DskipTest=true, then maven can't find the generated sources.. I'm stuck for several hours already and can't really find it. (doing this in Eclipse btw)

EDIT:

just figured out the following: If I remove the second plugin (to generate by xsd) I won't get any error.. If I put all the code that uses thoes generated classes in comment ofc.

Another EDIT:

I've changed the outputDirectory from the jaxb generation and now it's working. Can anyone explain me why it can't be the same as the wsimport location?

By default, the jaxb2-maven-plugin deletes the outputDirectory before putting the generated classes inside.

You can control this behaviour with the attribute clearOutputDir . Your plugin configuration would then look like :

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>xjc</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <schemaDirectory>${basedir}/src/main/resources/META-INF/xsd</schemaDirectory>
        <packageName>be.fgov.health.ecad.xmlstructure</packageName>
        <outputDirectory>${basedir}/target/generated/java</outputDirectory>
        <clearOutputDir>false</clearOutputDir>
    </configuration>
</plugin> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM