Reputation: 4076
I am searching for a maven plugin that triggers a rest call at pre-integrate-test
.
I just need a plugin which does this for me.
For now I tried using groovy-maven-plugin version 2.0
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.0</version>
<dependencies>
<dependency>
<groupId>org.apache.ivy</groupId>
<artifactId>ivy</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>${root.relative.path}/target/triggerCacheLoading.groovy</source>
</configuration>
</execution>
</executions>
</plugin>
groovy file:
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7' )
import groovyx.net.http.RESTClient
import static groovyx.net.http.ContentType.XML
solr = new RESTClient('http://localhost:8080/endpoint')
log.info "----------------------------------- START GROOVY REST CALL -----------------------------------";
def response = solr.post(
contentType: XML,
requestContentType: XML,
body: { }
)
log.info "Solr response status: ${response.status}"
log.info "----------------------------------- END GROOVY REST CALL -----------------------------------";
and I get:
[ERROR] Failed to execute goal org.codehaus.gmaven:groovy-maven-plugin:2.0:execute (default-cli) on project reg-reporting: Execution default-cli of goal org.codehaus.gmaven:groovy-maven-plugin:2.0:execute failed: A required class was missing while executing org.codehaus.gmaven:groovy-maven-plugin:2.0:execute: org/apache/ivy/core/report/ResolveReport
...
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: org.apache.ivy.core.report.ResolveReport
Upvotes: 1
Views: 1062
Reputation: 26743
I am not sure why you need the ivy dependency there? It's probably a good idea to let Maven manage all the dependencies, including the HTTP builder one, rather than using Grape:
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<id>cache-loading</id>
<phase>pre-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>${root.relative.path}/target/triggerCacheLoading.groovy</source>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.6</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy.modules.http-builder</groupId>
<artifactId>http-builder</artifactId>
<version>0.7.1</version>
</dependency>
</dependencies>
</plugin>
Upvotes: 1