📜 ⬆️ ⬇️

Debugging Groovy scripts with Grape based on maven aether

In IntelliJ Idea, there are difficulties with debugging such scripts, as for debugging groovy IDE uses the default groove build, with Ivy provider for Grape.




')
On the New Year holidays, it is finally time to solve the problem of debugging scripts that are started using the groovy-grape-aether groove build .

The better maven aether compared with Ivy
The answer to the question of why we need a Grape based on maven aether and how it is better for Ivy provider described in the article “Street magic in scripts or what does Groovy, Ivy and Maven connect?” .


Create a Gradle project with the dependency com.github.igor-suhorukov: groovy-grape-aether: 2.4.5.1 'or pom.xml for maven:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.github.igor-suhorukov</groupId> <artifactId>debug-example</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>com.github.igor-suhorukov</groupId> <artifactId>groovy-grape-aether</artifactId> <version>2.4.5.1</version> </dependency> </dependencies> </project> 


We import the project into Idea. As an example of a script for debugging, you can take crawler.groovy from the publication “That we should parse the site. Basics webdriver API .

Create a configuration for debugging in the IDE: main class com.github.igorsuhorukov.GroovyMain, and specify the name of the groovy script as parameters and then list the script arguments.



Put breakpoints in the script, and java code that is called from it.

The solution described in the note allows you to debug scripts with maven Grape in Idea in the same way as debugging a regular groovy and java application.

Source: https://habr.com/ru/post/274875/


All Articles