Skip to content

Instantly share code, notes, and snippets.

@orekyuu
Created September 26, 2015 04:52
Show Gist options
  • Save orekyuu/ffa3c223012eb36af2ff to your computer and use it in GitHub Desktop.
Save orekyuu/ffa3c223012eb36af2ff to your computer and use it in GitHub Desktop.
Scalaですらw
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'scala'
sourceCompatibility = 1.8
targetCompatibility = 1.8
[compileJava, compileTestJava].each {
it.options.encoding = 'UTF-8'
}
configurations { providedCompile }
sourceSets.main.compileClasspath += configurations.providedCompile
sourceSets.test.compileClasspath += configurations.providedCompile
sourceSets.test.runtimeClasspath += configurations.providedCompile
jar {
baseName = 'ScalaDemoPlugin'
version = '1.0.0'
manifest {
attributes 'Plugin-ID': 'net.orekyuu.demo.scala'
attributes 'Plugin-Name': 'ScalaDemoPlugin'
attributes 'Author': 'orekyuu'
attributes 'Author-Web': ''
attributes 'Plugin-Version': '1.0.0'
attributes 'Min-API-Version': '1.0.1'
attributes 'Plugin-Class': 'net.orekyuu.demo.scala.ScalaDemo'
}
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
repositories {
mavenCentral()
maven {
url = 'http://repos.orekyuu.net/'
}
}
dependencies {
providedCompile 'net.orekyuu:JavaBeamStudioAPI:1.0.1'
compile 'org.scala-lang:scala-library:2.11.1'
}
package net.orekyuu.demo.scala
import java.util
import java.util.function.Consumer
import net.orekyuu.javatter.api.command.Command
import net.orekyuu.javatter.api.service.TwitterUserService
import net.orekyuu.javatter.api.twitter.{TweetBuilder, TwitterUser}
import net.orekyuu.javatter.api.util.lookup.Lookup
class ScalaCommand extends Command {
override def command(): String = "scala"
override def exec(args: util.List[String]): Unit = {
val service: TwitterUserService = Lookup.lookup(classOf[TwitterUserService])
service.selectedAccount().ifPresent(new Consumer[TwitterUser] {
override def accept(user: TwitterUser): Unit = {
val builder: TweetBuilder = user.createTweet()
builder.setAsync().setText("Scalaですからw").tweet()
}
})
}
override def help(): String = "Scalaですからw"
}
package net.orekyuu.demo.scala
import javax.inject.Inject
import net.orekyuu.javatter.api.command.CommandManager
import net.orekyuu.javatter.api.plugin.{OnInit, OnPostInit}
class ScalaDemo {
@Inject
var commandManager: CommandManager = _
@OnInit
def init(): Unit = {
commandManager.registerCommand(new ScalaCommand)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment