Create working example of external module
This commit is contained in:
@@ -15,6 +15,9 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
testCompile group: 'junit', name: 'junit', version: '4.12'
|
||||||
|
compileOnly(group: 'org.pf4j', name: 'pf4j', version: "3.2.0") {
|
||||||
|
exclude group: "org.slf4j"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compileKotlin {
|
compileKotlin {
|
||||||
|
|||||||
11
api/src/main/kotlin/io/smnp/ext/ModuleDefinition.kt
Normal file
11
api/src/main/kotlin/io/smnp/ext/ModuleDefinition.kt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package io.smnp.ext
|
||||||
|
|
||||||
|
import io.smnp.callable.function.Function
|
||||||
|
import io.smnp.callable.method.Method
|
||||||
|
import org.pf4j.ExtensionPoint
|
||||||
|
|
||||||
|
interface ModuleDefinition : ExtensionPoint {
|
||||||
|
fun modulePath(): String
|
||||||
|
fun functions(): List<Function>
|
||||||
|
fun methods(): List<Method>
|
||||||
|
}
|
||||||
@@ -10,7 +10,6 @@ subprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// plugin location
|
|
||||||
ext.pluginsDir = rootProject.buildDir.path + '/modules'
|
ext.pluginsDir = rootProject.buildDir.path + '/modules'
|
||||||
|
|
||||||
group 'io.bartek'
|
group 'io.bartek'
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'java'
|
|
||||||
id 'org.jetbrains.kotlin.jvm'
|
|
||||||
}
|
|
||||||
|
|
||||||
group 'io.bartek'
|
|
||||||
version '1.0-SNAPSHOT'
|
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
|
||||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
|
||||||
}
|
|
||||||
|
|
||||||
compileKotlin {
|
|
||||||
kotlinOptions.jvmTarget = "1.8"
|
|
||||||
}
|
|
||||||
compileTestKotlin {
|
|
||||||
kotlinOptions.jvmTarget = "1.8"
|
|
||||||
}
|
|
||||||
61
modules/lang/build.gradle
Normal file
61
modules/lang/build.gradle
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id 'java'
|
||||||
|
id 'org.jetbrains.kotlin.jvm'
|
||||||
|
id 'kotlin-kapt'
|
||||||
|
}
|
||||||
|
|
||||||
|
group 'io.bartek'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
sourceCompatibility = 1.8
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
manifest {
|
||||||
|
attributes 'Plugin-Id': "${pluginId}",
|
||||||
|
'Plugin-Class': "${pluginClass}",
|
||||||
|
'Plugin-Version': "${pluginVersion}",
|
||||||
|
'Plugin-Provider': "${pluginProvider}",
|
||||||
|
'Plugin-Dependencies': "${pluginDependencies}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task plugin(type: Jar) {
|
||||||
|
archiveBaseName = "plugin-${pluginId}"
|
||||||
|
into('classes') {
|
||||||
|
with jar
|
||||||
|
}
|
||||||
|
into('lib') {
|
||||||
|
from configurations.compile
|
||||||
|
}
|
||||||
|
archiveExtension = 'zip'
|
||||||
|
}
|
||||||
|
|
||||||
|
task assemblePlugin(type: Copy) {
|
||||||
|
from plugin
|
||||||
|
into pluginsDir
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// compileOnly important!!! We do not want to put the api into the zip file since the main program has it already!
|
||||||
|
compileOnly project(':api')
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
|
kapt(group: 'org.pf4j', name: 'pf4j', version: "3.2.0")
|
||||||
|
compileOnly(group: 'org.pf4j', name: 'pf4j', version: "3.2.0") {
|
||||||
|
exclude group: "org.slf4j"
|
||||||
|
}
|
||||||
|
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'
|
||||||
|
testCompile group: 'junit', name: 'junit', version: '4.+'
|
||||||
|
}
|
||||||
7
modules/lang/gradle.properties
Normal file
7
modules/lang/gradle.properties
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
version=0.0.1
|
||||||
|
|
||||||
|
pluginVersion=0.1
|
||||||
|
pluginId=smnp.lang
|
||||||
|
pluginClass=
|
||||||
|
pluginProvider=Bartłomiej Pluta
|
||||||
|
pluginDependencies=
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package io.smnp.ext.lang
|
||||||
|
|
||||||
|
import io.smnp.callable.function.Function
|
||||||
|
import io.smnp.callable.function.FunctionDefinitionTool
|
||||||
|
import io.smnp.callable.signature.Signature.Companion.vararg
|
||||||
|
import io.smnp.type.matcher.Matcher.Companion.allTypes
|
||||||
|
import io.smnp.type.model.Value
|
||||||
|
|
||||||
|
class DisplayFunction : Function("println") {
|
||||||
|
override fun define(new: FunctionDefinitionTool) {
|
||||||
|
new function vararg(allTypes()) define { _, v ->
|
||||||
|
println(v.joinToString("") { it.toString() })
|
||||||
|
Value.void()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
modules/lang/src/main/kotlin/io/smnp/ext/lang/LangModule.kt
Normal file
14
modules/lang/src/main/kotlin/io/smnp/ext/lang/LangModule.kt
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package io.smnp.ext.lang
|
||||||
|
|
||||||
|
import io.smnp.callable.method.Method
|
||||||
|
import io.smnp.ext.ModuleDefinition
|
||||||
|
import org.pf4j.Extension
|
||||||
|
|
||||||
|
@Extension
|
||||||
|
class LangModule : ModuleDefinition {
|
||||||
|
override fun modulePath() = "smnp.io"
|
||||||
|
|
||||||
|
override fun functions() = listOf(DisplayFunction())
|
||||||
|
|
||||||
|
override fun methods() = emptyList<Method>()
|
||||||
|
}
|
||||||
@@ -3,6 +3,4 @@ include 'api'
|
|||||||
include 'app'
|
include 'app'
|
||||||
include 'modules'
|
include 'modules'
|
||||||
|
|
||||||
//include 'modules:A'
|
include 'modules:lang'
|
||||||
//include 'modules:B'
|
|
||||||
//include 'modules:C'
|
|
||||||
|
|||||||
Reference in New Issue
Block a user