Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't my Maven plugin run in the build lifecycle?

I have tried to add a goal to my maven lifecycle with the following pom part. I defined a new plugin and configured it with phase and execute information.

<build>
    <pluginManagement>
        <plugins>                   
            <plugin>
                <groupId>org.apache.openjpa</groupId>
                <artifactId>openjpa-maven-plugin</artifactId>
                <version>2.2.0</version>
                <configuration>
                <includes>**/entity/*.class</includes>
               <addDefaultConstructor>true</addDefaultConstructor>
               <connectionDriverName>com.ibm.db2.jcc.DB2Driver</connectionDriverName>
                        <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
                        <sqlFile>${project.build.directory}/database.sql</sqlFile>
                    </configuration>
                    <executions>
                        <execution>
                            <id>sql</id>
                            <phase>generate-resources</phase>
                            <goals>
                                <goal>sql</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>enhancer</id>
                            <phase>process-classes</phase>
                            <goals>
                                <goal>enhance</goal>
                            </goals>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.openjpa</groupId>
                            <artifactId>openjpa</artifactId>

                            <version>2.1.1</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

Then I run maven with mvn:install But the plugin is not run?

like image 259
Kayser Avatar asked Sep 12 '12 16:09

Kayser


1 Answers

Make sure that there is a dependency on the plugin and that the plugin is in build/plugin not build/pluginmanagement/plugin.

Try with something like this:

<dependencies>
    <dependency>
        <groupId>org.apache.openjpa</groupId>
        <artifactId>openjpa</artifactId>
        <version>2.1.1</version>
    </dependency>
</dependencies>

<build>
    <pluginManagement>
        <plugins>                   
            <plugin>
                <groupId>org.apache.openjpa</groupId>
                <artifactId>openjpa-maven-plugin</artifactId>
                <version>2.2.0</version>
                <configuration>
                    <includes>**/entity/*.class</includes>
                    <addDefaultConstructor>true</addDefaultConstructor>
                    <connectionDriverName>com.ibm.db2.jcc.DB2Driver</connectionDriverName>
                    <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
                    <sqlFile>${project.build.directory}/database.sql</sqlFile>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>

    <plugins>
        <plugin>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>sql</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>sql</goal>
                    </goals>
                </execution>
                <execution>
                    <id>enhancer</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>enhance</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
like image 67
Farid Avatar answered Oct 13 '22 03:10

Farid