Execution default of goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile failed: Unable to load the mojo 'compile' - eclipse-plugin

I try to add org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1 into my springboot application pom.xml to generate automaticly protobuff java code when I use Maven Update Project.
The error appear sometime. If I use "Maven Update Project" and "Project > Clean ...", it will disappear sometime. However, it still there which I can't tolerate anymore.
The error I meet:
Execution default of goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile failed: Unable to load the mojo 'compile' (or one of its required components) from the plugin 'org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1' (org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile:default:generate-sources)
org.apache.maven.plugin.PluginExecutionException: Execution default of goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile failed: Unable to load the mojo 'compile' (or one of its required components) from the plugin 'org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1'
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:156)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:331)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.lambda$7(MavenImpl.java:1342)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1341)
at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:52)
at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:137)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:173)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1$1.call(MavenBuilder.java:116)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:106)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:87)
at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:201)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:833)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:220)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:263)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:316)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:319)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:371)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:392)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:154)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.apache.maven.plugin.PluginContainerException: Unable to load the mojo 'compile' (or one of its required components) from the plugin 'org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1'
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:553)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:124)
... 30 more
Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
role: org.apache.maven.plugin.Mojo
roleHint: org.xolstice.maven.plugins:protobuf-maven-plugin:0.6.1:compile
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:267)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:519)
... 31 more
Caused by: java.util.NoSuchElementException
at org.eclipse.sisu.plexus.RealmFilteredBeans$FilteredItr.next(RealmFilteredBeans.java:118)
at org.eclipse.sisu.plexus.RealmFilteredBeans$FilteredItr.next(RealmFilteredBeans.java:1)
at org.eclipse.sisu.plexus.DefaultPlexusBeans$Itr.next(DefaultPlexusBeans.java:76)
at org.eclipse.sisu.plexus.DefaultPlexusBeans$Itr.next(DefaultPlexusBeans.java:1)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
... 33 more
The <build> of my pom.xml:
<build>
<plugins>
<plugin>
<!-- https://mvnrepository.com/artifact/kr.motd.maven/os-maven-plugin -->
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.6.2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>detect</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<!-- https://www.xolstice.org/protobuf-maven-plugin/index.html -->
<!-- https://mvnrepository.com/artifact/org.xolstice.maven.plugins/protobuf-maven-plugin -->
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<extensions>true</extensions>
<configuration>
<!-- <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact> -->
<!-- https://www.xolstice.org/protobuf-maven-plugin/compile-mojo.html -->
<!-- 默认为: src/main/proto/xxx.proto -->
<!-- <protoSourceRoot>${project.basedir}/src/main/proto</protoSourceRoot> -->
<!-- 默认为: ${project.build.directory}/generated-sources/protobuf/java,会自动添加为source,因为使用默认即可 -->
<!-- <outputDirectory>${project.basedir}/src/main/java</outputDirectory> -->
<!-- 当 clearOutputDirectory = true 时,每次执行都会清楚 outputDirectory 指定的目录下的所有文件 -->
<!-- <clearOutputDirectory>false</clearOutputDirectory> -->
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
The error happens in :
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>

Related

Thorntail arquillian jacoco test case coverage shows 0%

I am using thorntail framework and developed intregation test cases by using Arquillian. When I am trying yo generate test case coverage report it shows 0% coverage. I have already tried many solutions incuding thorntail-example, arquillian jacoco extension but couldn't able to resolve this.
below is my pom.xml
<profile>
<id>jacoco</id>
<dependencies>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.core</artifactId>
<version>${version.jacoco}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-jacoco</artifactId>
<version>${version.arquillian_jacoco}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.15</version>
<executions>
<!-- Ensures that both integration-test and verify goals of the Failsafe
Maven plugin are executed. -->
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<!-- Sets the VM argument line used when integration tests are run. -->
<argLine>${failsafeArgLine}</argLine>
<!-- Skips integration tests if the value of skip.integration.tests
property is true -->
<skipTests>false</skipTests>
<systemPropertyVariables>
<thorntail.arquillian.jvm.args>${failsafeArgLine}</thorntail.arquillian.jvm.args>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${version.jacoco}</version>
<executions>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<destFile>${jacoco.it.execution.data.file}</destFile>
<!-- Sets the name of the property containing the settings for JaCoCo
runtime agent. -->
<propertyName>failsafeArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>${jacoco.it.execution.data.file}</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
and this is my arquillian.xml
<container default="true" qualifier="daemon">
<configuration>
<property name="host">localhost</property>
<property name="port">${thorntail.arquillian.daemon.port:8085}</property>
<property name="javaVmArguments">${thorntail.arquillian.jvm.args:}</property>
</configuration>
</container>
<extension qualifier="jacoco">
<property name="includes">com.*</property>
</extension>

Where do I specify my custom reverse engineering class when using the hibernate-tools plugin for maven?

I have a custom strategy but I can't figure out how to get this plugin to use it.
My relevent pom section is:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.1.RELEASE</version>
</plugin>
<plugin>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tools-maven-plugin</artifactId>
<version>5.4.1.Final</version>
<executions>
<execution>
<id>Display Help</id>
<phase>validate</phase>
<goals>
<goal>help</goal>
</goals>
</execution>
<execution>
<id>Entity generation</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2java</goal>
</goals>
<configuration>
<templatePath>src/main/resources/templates/</templatePath>
<!-- Defaults: -->
<outputDirectory>generated-sources/</outputDirectory>
<ejb3>false</ejb3>
<jdk5>false</jdk5>
</configuration>
</execution>
<execution>
<id>Schema generation</id>
<phase>generate-resources</phase>
<goals>
<goal>hbm2ddl</goal>
</goals>
<configuration>
<!--Possible targetType: SCRIPT (default), STDOUT, DATABASE -->
<targetTypes>
<param>SCRIPT</param>
<param>STDOUT</param>
<param>DATABASE</param>
</targetTypes>
<!-- Defaults: -->
<outputDirectory>generated-resources/</outputDirectory>
<!--Possible schemaExportAction: CREATE (default), DROP, BOTH -->
<schemaExportAction>CREATE</schemaExportAction>
<outputFileName>schema.ddl</outputFileName>
<delimiter>;</delimiter>
<haltOnError>true</haltOnError>
<format>true</format>
</configuration>
</execution>
</executions>
<configuration>
<revengFile>src/main/hibernate/hibernate.reveng.xml</revengFile>
<!-- Defaults: -->
<packageName></packageName>
<configFile>src/main/hibernate/hibernate.cfg.xml</configFile>
<detectManyToMany>true</detectManyToMany>
<detectOneToOne>true</detectOneToOne>
<detectOptimisticLock>true</detectOptimisticLock>
<createCollectionForForeignKey>true</createCollectionForForeignKey>
<createManyToOneForForeignKey>true</createManyToOneForForeignKey>
</configuration>
<dependencies>
<!-- databases -->
<dependency>
<!-- DB Driver of your choice -->
<groupId>com.oracle</groupId>
<artifactId>oracle-jdbc8</artifactId>
<version>18</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>5.4.1.Final</version>
</plugin>
<!--
<plugin>
<groupId>org.springframework.boot</groupId>
</plugin>
-->
</plugins>
</pluginManagement>
</build>
And my hibernate.reveng.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering SYSTEM "http://hibernate.org/dtd/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering>
<type-mapping>
<sql-type jdbc-type="DATE" hibernate-type="java.time.LocalDate"/>
<sql-type jdbc-type="TIMESTAMP" hibernate-type="java.time.LocalDateTime"/>
</type-mapping>
</hibernate-reverse-engineering>
Additionally, although in the config I have specified to use "src/main/hibernate/hibernate.cfg.xml" it is reading "hibernate.properties"
I guess the example I got https://github.com/stadler/hibernate-tools-maven-plugin has the wrong configuration property name.
So:
1) The initial question
2) How do I configure this to use the specified configuration file?
3) Where is there a list of all the configuration problems and finally despite having
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>5.4.1.Final</version>
</plugin>
</plugins>
</pluginManagement>
I am getting "plugin execution not covered by lifecycle" in eclipse
So apparently I did not correctly follow this StackOverflow answer How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds
The documentation says add a revengStrategy configuration to the plugin with the full name of the class that extends DefaultReverseEngineeringStrategy. However when you try this, it throws class not instanced error. I have raised an issue with hibernate tools.
However, I have seen solutions where this is working if you have multi module project. The custom class should be part of a different module and that module should be added as a plugin dependency.
If I hear back from hibernate tools, you can find it here later
https://jonamlabs.com/how-to-use-hibernate-tools-maven-plugin-to-generate-jpa-entities-from-an-existing-database/

How to generate TestNG runner file using cucumber-jvm-parallel-plugin?

Below is my POM file. I am unable to generate TestNG runner file while all the configs are correct. Please help me to do the correct configuration.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<version>4.2.0</version>
<executions>
<execution>
<id>generateRunners</id>
<phase>generate-test-sources</phase>
<goals>
<goal>generateRunners</goal>
</goals>
<configuration>
<outputDirectory>runner</outputDirectory>
<glue>
<package>com.compareglobalgroup.stepdefs</package>
<package>com.compareglobalgroup.cucumber.hooks</package>
</glue>
<featuresDirectory>src/test/resources/feature</featuresDirectory>
<cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
<format>json</format>
<plugins>
<plugin>
<name>json</name>
</plugin>
</plugins>
<tags>
<tag>#BBDK</tag>
</tags>
<useTestNG>true</useTestNG>
<!-- <namingScheme>simple</namingScheme> <namingPattern>Parallel{c}TestRunner</namingPattern> -->
<parallelScheme>FEATURE</parallelScheme>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<forkCount>10</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>**/Parallel*IT.class</include>
</includes>
<!-- You can specify a specific testng.xml file here <suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng-sample.xml</suiteXmlFile> </suiteXmlFiles> -->
<!-- Or dynamically with something like '-DsuiteXmlFile=src/test/resources/testng-sample.xml' -->
<!-- <suiteXmlFiles> <suiteXmlFile>${suiteXmlFile}</suiteXmlFile> </suiteXmlFiles> -->
<!-- Build with '-DskipTests=true' to bypass test execution # build
time Default: false -->
<skipTests>false</skipTests>
<testFailureIgnore>true</testFailureIgnore>
<systemPropertyVariables>
<browser>${browser}</browser>
<execution>${execution}</execution>
<environment>${environment}</environment>
<!-- <suiteXmlFile>${suiteXmlFile}</suiteXmlFile> -->
<country>${country}</country>
<vertical>${vertical}</vertical>
<homeUrl>${homeUrl}</homeUrl>
<isHeadless>${isHeadless}</isHeadless>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
You need to have your <plugin> entry available under
<build>
<plugins>
<plugin>
<!-- add your plugin entry here -->
</plugin>
</plugins>
</build>
But you have added it under <pluginManagement> which is usually used to control plugin behavior for projects that inherit from the current one. See here for more information.

Filter maven resources with filter-file from external dependency

Given a property file in maven project A
I want to use them in project B for resource filtering.
So in Project B I use
<build>
<filters>
<filter>${project.build.directory}/myFile.properties</filter>
</filters>
</build>
To filter my resources based on values in myFile.properties This file is stored in project A. So I include it with
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>process-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>groupa</groupId>
<artifactId>a</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<outputDirectory>${project.build.directory}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Problem is that the resource filtering happens before the dependency is copied. So filtering does work when copying myFile.properties manually to ${project.build.directory} but it does not work with a mvn clean ...
How can I copy the filterFile before the actual filtering happens?
Maven plugins are executed in the order they appear in the pom. AFAIK the plugins configured in the parent (and the super pom) are executed before the plugins of the pom.
My suggestion is declaring the resources plugin explicitely after the dependency plugin:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<!-- ... -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<!-- ... -->
</plugin>
</plugins>
</build>

How do I build only one JAR file with classifier?

I'm using Maven 2 and maven-jar-plugin to build my jar.
I'd like to generate only a jar with a classifier. Is it possible?
In my example I'd like to generate only the myjar-another-1.0.jar but not myjar-1.0.jar.
After take a look at this question I tried to skip the default-jar. But this seems to work only with version 3 of Maven (haven't tried thou.
The parent is to do the
<modules>
Thanks all!
Here is the relevant piece of my pom.xml:
Also tried in the global configuration segment.
<project>
<!-- Definition of the Parent (only an aggregator) -->
<build>
<plugins>
<!-- <artifactId>maven-bundle-plugin</artifactId> -->
<!-- surefire -->
<!-- <artifactId>maven-source-plugin</artifactId> -->
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<classifier>another</classifier>
</configuration>
<executions>
<execution>
<id>test-jar</id>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Just use it for the plugin element:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<classifier>another</classifier>
</configuration>
</plugin>
</plugins>