🤪 Various improvements

This commit is contained in:
Christian Basler 2018-06-13 19:19:30 +02:00
parent 2bc6abf42c
commit 701282099a
9 changed files with 98 additions and 44 deletions

View File

@ -1,6 +1,6 @@
buildscript {
ext.kotlin_version = '1.2.0'
ext {
kotlin_version = '1.2.41'
springBootVersion = '2.0.0.M7'
}
repositories {
@ -9,17 +9,16 @@ buildscript {
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion")
classpath('se.transmode.gradle:gradle-docker:1.2')
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
classpath("org.jetbrains.kotlin:kotlin-allopen:$kotlin_version")
classpath('com.github.ben-manes:gradle-versions-plugin:0.17.0')
}
}
group = 'dissem'
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'eclipse'
@ -51,23 +50,24 @@ dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
compile("io.springfox:springfox-swagger2:2.7.0")
compile("io.springfox:springfox-swagger-ui:2.7.0")
compile("com.fasterxml.jackson.module:jackson-module-kotlin:")
compile "ch.dissem.jabit:jabit-core:$jabitVersion"
compile "ch.dissem.jabit:jabit-networking:$jabitVersion"
compile "ch.dissem.jabit:jabit-repositories:$jabitVersion"
compile "ch.dissem.jabit:jabit-cryptography-bouncy:$jabitVersion"
compile "ch.dissem.jabit:jabit-extensions:$jabitVersion"
compile("ch.dissem.jabit:jabit-core:$jabitVersion")
compile("ch.dissem.jabit:jabit-networking:$jabitVersion")
compile("ch.dissem.jabit:jabit-repositories:$jabitVersion")
compile("ch.dissem.jabit:jabit-cryptography-bouncy:$jabitVersion")
compile("ch.dissem.jabit:jabit-extensions:$jabitVersion")
compile 'com.h2database:h2:1.4.194'
compile('com.h2database:h2:1.4.194')
compile 'com.google.zxing:core:3.3.1'
compile('com.google.zxing:core:3.3.1')
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
testCompile("org.springframework.boot:spring-boot-starter-test")
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version")
compile("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
compile("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
}
@ -92,25 +92,24 @@ task buildDocker(type: Docker, dependsOn: build) {
jar {
baseName = 'jabit-server'
}
//frontend:build will be run before processResources
processResources {
dependsOn('frontend:build')
from('frontend/dist') {
//Public is a default supported Spring Boot resources directory.
into 'public'
}
}
//frontend:build will be run before the processResources
processResources.dependsOn('frontend:build')
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
kotlinOptions.jvmTarget = "1.8"
}

View File

@ -0,0 +1,18 @@
package ch.dissem.bitmessage.server
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import javax.servlet.http.HttpServletRequest
@Controller
@RequestMapping
class FrontendController {
@RequestMapping("/{path:[^\\.]+}/**")
fun redirect(request: HttpServletRequest): String {
// Also forward to home page so that route is preserved.
return "forward:/index.html"
}
}

View File

@ -20,8 +20,10 @@ import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.context.annotation.ComponentScan
import org.springframework.scheduling.annotation.EnableScheduling
import org.springframework.web.servlet.config.annotation.EnableWebMvc
import springfox.documentation.swagger2.annotations.EnableSwagger2
@EnableWebMvc
@EnableSwagger2
@EnableScheduling
@SpringBootApplication

View File

@ -172,13 +172,13 @@ class JabitServerConfig {
if (identities.isEmpty()) {
LOG.info("Creating new identity...")
identity = bitmessageContext().createIdentity(false, Pubkey.Feature.DOES_ACK)
LOG.info("Identity " + identity.address + " created.")
LOG.info("Identity ${identity.address} created.")
} else {
LOG.info("Identities:")
identities.forEach { LOG.info(it.address) }
identity = identities[0]
if (identities.size > 1) {
LOG.info("Using " + identity)
LOG.info("Using $identity")
}
}
LOG.info("QR Code:\n" + Utils.qrCode(identity))

View File

@ -0,0 +1,20 @@
package ch.dissem.bitmessage.server
import org.springframework.context.annotation.Configuration
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
@Configuration
class WebMvcConfig : WebMvcConfigurer {
override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
if (!registry.hasMappingForPattern("/webjars/**")) {
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/")
}
if (!registry.hasMappingForPattern("/**")) {
registry.addResourceHandler("/**").addResourceLocations("classpath:/public/")
}
}
}

View File

@ -1,9 +0,0 @@
logging.file=jabit.log
logging.level.*=ERROR
logging.level.ch.dissem.*=WARN
bitmessage.port=8444
bitmessage.connection.ttl.hours=12
bitmessage.connection.limit=100
database.url=jdbc:h2:file:./jabit;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=10
database.user=sa
database.password=

View File

@ -0,0 +1,16 @@
#server.servlet.contextPath=/jabit-server
logging:
file: 'jabit.log'
level.*: ERROR
level.ch.dissem.*: WARN
bitmessage:
port: 8444
connection:
ttl.hours: 12
limit: 100
database:
url: 'jdbc:h2:file:./jabit;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=10'
user: 'sa'
password:

View File

@ -1,7 +0,0 @@
logging.file=jabit.log
logging.level.*=DEBUG
logging.level.ch.dissem.*=DEBUG
bitmessage.port=18444
database.url=jdbc:h2:mem:jabit;DB_CLOSE_DELAY=10
bitmessage.connection.ttl.hours=12
bitmessage.connection.limit=100

View File

@ -0,0 +1,15 @@
logging:
file: 'jabit.log'
level.*: DEBUG
level.ch.dissem.*: DEBUG
bitmessage:
port: 18444
connection:
ttl.hours: 12
limit: 100
database:
url: 'jdbc:h2:mem:jabit;DB_CLOSE_DELAY=10'
user: sa
password: