Thursday, May 12, 2016

Mix Groovy and Java in STS 3.7.3.RELEASE

To mix Java and Groovy together in the same Spring Starter project, a few changes can be made to the project's properties and paths. By default, when a Java project is created it only looks for source files and test files in the src/main/java and src/test/java directories.

Add src/main/groovy to Java Build Path


  1. Create the src/main/groovy directory
  2. Right-click the project in Package Explorer, then click Properties
  3. Click Java Build Path in the left sidebar
  4. Click Add Folder... to add src/main/groovy


Add Groovy libraries to classpath


  1. Right-click the project in Package Explorer
  2. Expand Groovy, then click Add Groovy libraries to classpath


Only include groovy-all


At this point, trying to run the Spring Boot app will generate errors that look like this.

...
org.apache.catalina.core.ContainerBase : A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
...


The errors can be resolved by removing the extra libraries STS automatically added in the previous step.
  1. Right-click Groovy Libraries in the project
  2. Click Properties
  3. Select "No, only include groovy-all" in the first panel that asks, "Should all jars in the groovy-eclipse lib folder be included on the classpath?"

Monday, May 9, 2016

Mix Groovy and Java in IntellJ IDEA

To mix Java and Groovy together in the same IntelliJ IDEA project, a simple change can be made to the project's .iml file. By default, when the project is created it only looks for source files and test files in the src/main/java directory.
By adding two sourceFolder elements IntellJ will automatically find and compile .groovy files in the Groovy directory.

Wednesday, May 4, 2016

Go to Assembla Ticket

Here's a simple JS code that can be converted into a bookmarklet to quickly open an Assembla ticket.