Unable to resolve the class util in gmaven plugin - maven

<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.9.13</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>call-groovy</id>
<phase>package</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<providerSelection>1.8</providerSelection>
<source>src/main/java/test.groovy</source>
</configuration>
</execution>
</executions>
</plugin>
this test.groovy script invokes util methods as below
class test {
util.getDetails()
}
util class is not resolved here even though both are in the same package and throwing the below error
[ERROR] Failed to execute goal org.codehaus.gmaven:gmaven-plugin:1.5:execute (call-groovy) on project farmer: startup failed:
[ERROR] src/main/java/test.groovy: 7: unable to resolve class FarmerUtility

The error is resolved after adding maven-antrun-plugin which concatenate both the classes

Related

cucumber.json file does not generating

I am trying to execute a cucumber selenium setup.
pom.xml is like.
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>execution</id>
<phase>test</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>ExecuteAutomation</projectName>
<outputDirectory>${project.build.directory}/cucumber-report-html</outputDirectory>
<cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
</configuration>
</execution>
</executions>
</plugin>
and cucumber jvm is
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>6.8.0</version>
</dependency>
whenever I verify the build by maven it always shows cucumber.json does not exist.
which suppose to be auto generated.
runner file is
#CucumberOptions(features = { "src/test/features/Login.feature" },monochrome = false,
plugin = {"json:target/cucumber.json","html:target/site/cucumber-pretty"},
glue = { "steps" })
Okay! I back track the problem
first I comment maven-cucumber-reporting plugin section and try to execute through testng. there was a warning which need to resolve by -Dtestng.dtd.http=true.
and then it works!
Thanks!

maven gmavenplus-plugin problems with groovy syntax

I am trying to customize maven build process using gmavenplus-plugin.
To be precise, I have a workig script in gmaven-plugin and I am trying to re-implement it in gmavenplus-plugin(which is advertised as a rewrite of GMaven)
My running gmaven code
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
println(project.version)
println([1, 2, 3])
</source>
</configuration>
</execution>
</executions>
</plugin>
My attempt to re-write it in gmavenplus:
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.7.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
<configuration>
<scripts>
println(project.version)
println([1, 2, 3])
</scripts>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
Which fails with
[ERROR] Script1.groovy: 2: unexpected token: 1 # line 2, column 34.
[ERROR] println([1
[ERROR] ^
[ERROR]
[ERROR] 1 error
Any groovy syntax I try to use fails.
Update
CDATA does not help.
<scripts>
<![CDATA[
println(project.version)
println([1, 2, 3])
]]>
according to examples https://github.com/groovy/GMavenPlus/wiki/Examples
there should be <script> inside <scripts>:
use mvn gplus:execute with the following example pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>test-gmavenplus</groupId>
<artifactId>test-gmavenplus</artifactId>
<packaging>pom</packaging>
<version>1.1.0-SNAPSHOT</version>
<name>test gmavenplus</name>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.7.0</version>
<executions>
<execution>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
<configuration>
<scripts>
<script><![CDATA[
println "hello `${project.name}`"
]]></script>
</scripts>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.5.7</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>

Aspectj Table annotation issues

when I try to add aspectj-maven-plugin inside my existing project, I add this:
[ERROR] The attribute indexes is undefined for the annotation type Table
E:\T2_SupplierPortal_Angular\core\model\src\main\java\com\model\PaymentGrp.java:32
indexes={
^^^^
...
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.8:compile (default) on project model: AJC compiler errors:
error at indexes={
It seems that when I add this plugin, it use an older version of JPA instead of JPA 2.1.
My Configuration:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>1.8</source>
<target>1.8</target>
<complianceLevel>1.8</complianceLevel>
<weaveDependencies>
<weaveDependency>
<artifactId>common-logger</artifactId>
<groupId>com.common</groupId>
</weaveDependency>
</weaveDependencies>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.8.9</version>
</dependency>
</dependencies>
</plugin>
I don't know how to solve this. Thank you
Get rid of the syntax error in your source code, then retry the compilation. It is probably not even an AspectJ problem, just a Java syntax problem.

Maven failsafe plugin throwing InvocationTargetException when trying to setAdditionalClasspathElements

I am trying to setup maven failsafe plugin for my integration tests. Below is the POM configuration for the integration test profile and the error I am getting. I have not been able to run the integration test successfully yet. I had to install some of the POM and jar dependencies into my local repository since it was no available in my companies maven repositories. I cannot add dependencies to public repositories, it is blocked off by the company firewall. Hope somebody has run into this and knows what is causing this error.
POM configuration:
<profile>
<id>it</id>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.6.v20120903</version>
<configuration>
<contextPath>/xyzService</contextPath>
<scanIntervalSeconds>5</scanIntervalSeconds>
<maxIdleTime>3600000</maxIdleTime>
<stopPort>8005</stopPort>
<stopKey>STOP</stopKey>
<webAppSourceDirectory>
${project.build.directory}/${project.build.finalName}
</webAppSourceDirectory>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.16</version>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>maven-surefire-common</artifactId>
<version>2.10</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-api</artifactId>
<version>2.10</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-toolchain</artifactId>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
<version>0.4</version>
</dependency>
</dependencies>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
ERROR:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.
16:integration-test (integration-test) on project enterprise_ahr_services: Unabl
e to parse configuration of mojo org.apache.maven.plugins:maven-failsafe-plugin:
2.16:integration-test: Setter org.apache.maven.plugin.failsafe.IntegrationTestMo
jo.setAdditionalClasspathElements( java.util.List ) threw exception when called
with parameter '[]': org.apache.maven.plugin.failsafe.IntegrationTestMojo.setAdd
itionalClasspathElements(Ljava/util/List;)V: InvocationTargetException -> [Help
1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.

Generate test-jar along with jar file in test package

I want to package my test package to jar file . How to execute generate test-jar from maven plugin Surefire.
By using the following configuration you can create a jar from your tests:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
To use such kind of artifact:
<dependencies>
<dependency>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<type>test-jar</type>
<version>version</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies>
You can add following entries to your pom:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>

Resources