Skip to content

Commit

Permalink
add fat jar compile mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Theaninova committed Aug 13, 2020
1 parent a9e5ace commit d6a3691
Show file tree
Hide file tree
Showing 14 changed files with 224 additions and 47 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
servers.json
admin.json
*.hprof
/build
/.gradle
203 changes: 171 additions & 32 deletions .idea/workspace.xml

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,22 @@ compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}

jar {
manifest {
attributes('Main-Class': 'de.wulkanat.MainKt')
}
}

task fatJar(type: Jar) {
baseName = project.name + '-all'
from((configurations.compile.findAll { !it.path.endsWith(".pom") }).collect {
it.isDirectory() ? it : zipTree(it)
})
with jar
manifest {
attributes 'Main-Class': 'de.wulkanat.MainKt',
'Implementation-Version': version
}
}

apply plugin: 'kotlinx-serialization'
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
kotlin.code.style=official
kotlin.code.style=official
org.gradle.jvmargs=-Xmx1024m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package de.wulkanat

import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration
import net.dv8tion.jda.api.EmbedBuilder
Expand All @@ -24,7 +26,7 @@ object Admin {

admin = value?.retrieveUserById(userId)?.complete()
if (admin == null) {
kotlin.io.println("Connection to Admin failed!")
kotlin.io.println("Connection to de.wulkanat.Admin failed!")
} else {
kotlin.io.println("Connected to ${admin!!.name}. No further errors will be printed here.")
}
Expand Down Expand Up @@ -86,7 +88,7 @@ object Admin {
fun ready() {
sendDevMessage(
EmbedBuilder()
.setTitle("Now watching for new Hytale Blogposts every ${updateMs/1000}s")
.setTitle("Now watching for new Hytale Blogposts every ${updateMs / 1000}s")
.setDescription(Channels.getServerNames().joinToString("\n"))
.setColor(Color.GREEN)
.build(),
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/Bot.kt → src/main/kotlin/de/wulkanat/Bot.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package de.wulkanat

import net.dv8tion.jda.api.events.message.MessageReceivedEvent
import net.dv8tion.jda.api.hooks.ListenerAdapter

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package de.wulkanat

import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonConfiguration
import kotlinx.serialization.list
Expand Down Expand Up @@ -82,6 +84,10 @@ object Channels {
}

private fun saveChannels() {
SERVERS_FILE.writeText(json.stringify(DiscordChannel.serializer().list, channels))
SERVERS_FILE.writeText(
json.stringify(
DiscordChannel.serializer().list,
channels
))
}
}
6 changes: 4 additions & 2 deletions src/main/kotlin/Cli.kt → src/main/kotlin/de/wulkanat/Cli.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import model.BlogPostPreview
package de.wulkanat

import de.wulkanat.model.BlogPostPreview
import net.dv8tion.jda.api.events.message.MessageReceivedEvent
import net.dv8tion.jda.api.hooks.ListenerAdapter
import web.SiteWatcher
import de.wulkanat.web.SiteWatcher
import kotlin.system.exitProcess

class Cli : ListenerAdapter() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package de.wulkanat

import kotlinx.serialization.Serializable
import java.io.File

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package de.wulkanat

import net.dv8tion.jda.api.JDABuilder
import net.dv8tion.jda.api.entities.Activity
import net.dv8tion.jda.api.requests.GatewayIntent
import web.SiteWatcher
import de.wulkanat.web.SiteWatcher
import kotlin.concurrent.timer

fun main() {
// TODO: move toke into file
val builder = JDABuilder.createLight(Admin.token,
val builder = JDABuilder.createLight(
Admin.token,
GatewayIntent.GUILD_MESSAGES, GatewayIntent.DIRECT_MESSAGES)
.addEventListeners(Bot())
.setActivity(Activity.watching("for new Blogposts"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package extensions
package de.wulkanat.extensions

import java.awt.Color

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package model
package de.wulkanat.model

import net.dv8tion.jda.api.EmbedBuilder
import net.dv8tion.jda.api.entities.MessageEmbed
import extensions.hex2Rgb
import de.wulkanat.extensions.hex2Rgb

data class BlogPostPreview(
val title: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package web
package de.wulkanat.web

import model.BlogPostPreview
import de.wulkanat.model.BlogPostPreview
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package web
package de.wulkanat.web

import model.BlogPostPreview
import de.wulkanat.Admin
import de.wulkanat.model.BlogPostPreview
import org.jsoup.Jsoup
import java.io.IOException

Expand Down

0 comments on commit d6a3691

Please sign in to comment.