Move a folder generated inside "target/bla/bla/bla" to "src\main\java\com\demo\project" using Maven/POM.xml

Viewed 508

I am using a (Swagger) OpenApi YAML spec to generate Client Java code (much like creating SOAP client using WSDL file)

In my eclipse I am doing project (right click) -> Run -> Maven Build... (Set goal as "generate-sources" and profile as "codegen")

This is creating the "folder" inside target folder which has my client JAVA (.java) code.

I need to move it to the "src" to a specific folder.

This is my POM.xml

         <profile>
            <id>codegen</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.openapitools</groupId>
                        <artifactId>openapi-generator-maven-plugin</artifactId>
                        <version>5.0.0</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                                <id>generate-sources</id>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <inputSpec>${project.basedir}/src/main/resources/ClientSideJavaCode.yaml</inputSpec>
                                    <generatorName>java</generatorName>
                                    <packageName>com.demo.project.test.rest.generated</packageName>
                                    <apiPackage>com.demo.project.test.rest.generated.api</apiPackage>
                                    <modelPackage>com.demo.project.test.rest.generated.model</modelPackage>
                                    <configOptions>
                                        <sourceFolder>src/java/main</sourceFolder>
                                    </configOptions>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

What should I change/add to make it work? Will copy-resource plugin work?

1 Answers

Don't

The build should only write to the target directory.

Everything else will mess up your git/svn.

The generated source code should go to target and be compiled from there.

Related