1

I am using following Maven Plugin to generate the VDMs for OData consumption.

<plugin>
            <groupId>com.sap.cloud.sdk.datamodel</groupId>
            <artifactId>odata-generator-maven-plugin</artifactId>
            <version>3.13.0</version>
            <executions>
                <execution>
                    <id>generate-consumption</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <overwriteFiles>true</overwriteFiles>                    
                        <inputDirectory>/src/main/resources/connectedsystem/edmx</inputDirectory>
                        <outputDirectory>${project.basedir}/src/gen/java</outputDirectory>
                        <deleteOutputDirectory>false</deleteOutputDirectory>
                        <packageName>com.sap.requisitioning.vdm</packageName>
                    </configuration>
                </execution>
            </executions>
        </plugin>

However I do not want the VDM's to be generated in every maven build. I would like to achieve the following behaviour

  • VDM are not generated in mvn clean install by default
  • VDM classes are generated when we pass come explicit parameter mvn clean install -D<>

Could you please suggest how can this be achieved ?

Regards atanu

1 Answer 1

0

You can use Maven profiles to achieve this. Declare the plugin under a specific profile that is only active given a specific parameter like in this example.

Additionally you should take care that when running clean the generated sources are not deleted. This could happen if you generate them into the output directory (typically target).

1
  • Dear Colleague, thanks for the help. This can be one approach, but only for the conditional generation of VDM I do not want to create another maven profile. IF there are no other option we might do that. My question is,many standard Maven Plugins offer parameters which can be passed in maven to do things conditionally. Is there any such parameterization possible with VDM generators or a separate maven profile is the ONLY option. Commented Jun 16, 2020 at 6:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.