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

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.

Related

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

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>

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 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>

How to generate a WAR with the source code in Maven?

I want to distribute the war of my web application generated with Maven with the source code inside it. How to do that with Maven?
It is possible configure the maven-war-plugin to include the source directory as it was a web resource:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${build.sourceDirectory}</directory>
<targetPath>sources</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
The java sources will be included in a sources directory in the war. Of course you should adapt the resource directory to your own maven layout.
If you want the source files in the same directory as the class files you would use:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${build.sourceDirectory}</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
Usually I think you would go this way: (this won't include the source files, but provides them as separate files)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
At your war project's pom.xml:
<build>
...
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<attachClasses>true</attachClasses>
<classesClassifier>classes</classesClassifier>
</configuration>
</plugin>
...
</plugins>
</pluginManagement>
</build>
In the projects you want do use it:
<dependency>
<groupId>my-war-group</groupId>
<artifactId>my-war-artifact-id</artifactId>
<version>my-war-version</version>
<classifier>classes</classifier> <!-- THIS IS THE IMPORTANT LINE! -->
</dependency>

How can I change the war name generated by maven assembly plugin

How can I change the name from 1.0.snapshot-jar-with-dependencies to something else, below are contents of my POM:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<archive>
<manifest>
<mainClass>com.package.example.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
Use the following in the configuration of the maven-assembly-plugin:
<configuration>
<finalName>custom-name</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
Full details in the official documentation of the assembly:single mojo.
You can achieve this by specifying the finalName property in your pom, e.g.
<build>
<finalName>something-else</finalName>
...
</build>
In the case of packaging a JAR with dependencies, the won't work. You will fix it by using the dependency plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>project.group.id</groupId>
<artifactId>artifact-id</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${basedir}/some/dir</outputDirectory>
<destFileName>custom-name.jar</destFileName>
</artifactItem>
</artifactItems>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>