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
jamplate
in your project'ssrc/main
orsrc/test
directory. - Create your
package
directory like you would for anyjava
source code. - Create a new file in that desired
package
with.jamplate
extension. - Start coding in
jamplate
. - Keep in mind that the output of the processed file will be compiled as a
java
source-code. - Build your project using an
IDE
, or by typinggradle build
orgradlew build
in 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
Intellij
did not recognize the output files and gives you an error- Exit
Intellij
- Delete
.idea
folder in your project - Open
Intellij
again
- Exit
- If
Intellij
do not recognize.jamplate
extension- Follow these instructions Intellij.md