The gradle plugin for Jamplate. For more information please visit: jamplate.org
Add this to your build.gradle.
apply plugin: 'java'
apply plugin: 'jamplate'
buildscript() {
repositories {
maven {
url 'https://jitpack.io'
}
}
dependencies {
//replace 'TAG' with the desired version
classpath 'org.jamplate:gradle:TAG'
}
}- Apply the plugin.
- Create a new directory named
jamplatein your project'ssrc/mainorsrc/testdirectory. - Create your
packagedirectory like you would for anyjavasource code. - Create a new file in that desired
packagewith.jamplateextension. - Start coding in
jamplate. - Keep in mind that the output of the processed file will be compiled as a
javasource-code. - Build your project using an
IDE, or by typinggradle buildorgradlew buildin the terminal.
//utility imports
import static org.jamplate.glucose.internal.util.Values.*
import static org.jamplate.impl.unit.Action.*
import static org.jamplate.util.Specs.*
jamplate {
//with the method `unit`, you create a new task for the module you give it to it
//the method will return the created unit object for that module
unit('main').spec.add(listener({ event ->
if (event.action == PRE_EXEC) {
//here you can put all the default mappings you want
event.memory.set 'Text', text('Value')
event.memory.set 'Object', object(["Key": "Value"])
event.memory.set 'Array', array(["item1", "item2"])
event.memory.set 'Dynamic', { memory -> 'Dynamic Variable' }
event.memory.set "Random", { '' + (long) (Math.random() * (1L << 60)) }
event.memory.set "Document", { '' + it.frame.instruction?.tree?.document() }
}
}))
//with this method, the unit output will be treated as generated java source
java('main')
//with this method, the unit output will be treated as generated text
source('main')
}- If
Intellijdid not recognize the output files and gives you an error- Exit
Intellij - Delete
.ideafolder in your project - Open
Intellijagain
- Exit
- If
Intellijdo not recognize.jamplateextension- Follow these instructions Intellij.md