Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First kotlin covert (partial) #336

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,11 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- uses: actions/setup-java@v1
- uses: actions/setup-java@v3
with:
java-version: 11

- name: Cache
uses: actions/[email protected]
with:
# Cache gradle directories
path: |
~/.gradle/caches/jars-3
~/.gradle/caches/modules-2/files-2.1/
~/.gradle/caches/modules-2/metadata-2.96/
~/.gradle/native
~/.gradle/wrapper
# Key for restoring and saving the cache
key: ${{ runner.os }}-gradle
distribution: 'temurin'
java-version: '11'
cache: 'gradle'

# Compile the code
- name: Compile code
Expand Down
18 changes: 4 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,12 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 11

- name: Cache
uses: actions/[email protected]
- uses: actions/setup-java@v3
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: |
~/.gradle/caches/jars-3
~/.gradle/caches/modules-2/files-2.1/
~/.gradle/caches/modules-2/metadata-2.96/
~/.gradle/native
~/.gradle/wrapper
# An explicit key for restoring and saving the cache
key: ${{ runner.os }}-gradle
distribution: 'temurin'
java-version: '11'
cache: 'gradle'

# Compile code
- name: Compile code
Expand Down
48 changes: 48 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ plugins {
id "com.github.lkishalmi.gatling" version "3.3.4"
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'org.springframework.boot' version "2.6.6"
id "org.jetbrains.kotlin.plugin.spring" version "1.6.20"
id "org.jetbrains.kotlin.plugin.jpa" version "1.6.20"
id "org.jetbrains.kotlin.jvm" version "1.6.20"
id "org.jetbrains.kotlin.kapt" version "1.6.20"
}

apply plugin: 'checkstyle'
apply plugin: 'kotlin'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'io.spring.dependency-management'
Expand All @@ -21,8 +26,14 @@ repositories {

bootJar {
mainClass = 'org.radarbase.appserver.AppserverApplication'
duplicatesStrategy = 'include'
}

jar {
duplicatesStrategy = 'include'
}


//apply from: 'gradle/liquibase.gradle'

ext {
Expand All @@ -37,6 +48,8 @@ ext {
}

sourceSets {
main.kotlin.srcDirs += 'src/main/java'

integrationTest {
java {
compileClasspath += main.output + test.output + test.compileClasspath
Expand All @@ -47,6 +60,15 @@ sourceSets {
}
}

kapt {
keepJavacAnnotationProcessors = true
}

allOpen {
annotation("javax.persistence.Entity")
annotation("javax.persistence.Embeddable")
annotation("javax.persistence.MappedSuperclass")
}

dependencies {
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
Expand All @@ -57,6 +79,15 @@ dependencies {
implementation('org.springframework.boot:spring-boot-starter-actuator')
implementation('org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:' + springBootVersion)
implementation('org.springframework.security.oauth:spring-security-oauth2:' + springOauth2Version)

implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

kapt("org.springframework.boot:spring-boot-configuration-processor")
kapt("org.springframework:spring-context-indexer:5.3.18")
kapt("org.projectlombok:lombok:" + lombokVersion)

implementation group: 'com.pivovarit', name: 'throwing-function', version: throwingFunctionVersion

implementation(group: 'de.codecentric', name: 'spring-boot-admin-starter-client', version: bootAdminVersion)
Expand Down Expand Up @@ -95,7 +126,9 @@ dependencies {

testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit', module: 'junit'
//exclude group: 'org.mockito', module: 'mockito-core'
}
//testImplementation("com.ninja-squad:springmockk:3.1.1")

testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: junit5Version
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: junit5Version
Expand All @@ -105,6 +138,7 @@ dependencies {
testImplementation group: 'org.junit.platform', name: 'junit-platform-engine', version: '1.8.2'

gatling('com.fasterxml.jackson.datatype:jackson-datatype-jsr310')

}

checkstyle {
Expand All @@ -114,6 +148,10 @@ checkstyle {
sourceSets = [it.sourceSets.main]
}

pmd {
toolVersion = "6.44.0"
}

javadoc {
options.addBooleanOption('html5', true)
destinationDir = new File("${project.rootDir}/src/main/resources/static/java-docs".toString())
Expand Down Expand Up @@ -183,3 +221,13 @@ test {
}
}
}
compileKotlin {
kotlinOptions {
jvmTarget = "11"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "11"
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
:omega
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,23 @@
* *
*
*/
package org.radarbase.appserver

package org.radarbase.appserver;
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration
import org.springframework.boot.runApplication

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration;

/** @author yatharthranjan */
/** @author yatharthranjan
*/
@SpringBootApplication(
exclude = {SolrAutoConfiguration.class},
scanBasePackages = {"org.radarbase.appserver", "org.radarbase.fcm"})
public class AppserverApplication {
exclude = [SolrAutoConfiguration::class],
scanBasePackages = [
"org.radarbase.appserver",
"org.radarbase.fcm",
],
)
class AppserverApplication

public static void main(String[] args) {
SpringApplication.run(AppserverApplication.class, args);
}
}
fun main(args: Array<String>) {
runApplication<AppserverApplication>(*args)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@
* *
*
*/
package org.radarbase.appserver.config

package org.radarbase.appserver.config;

import org.radarbase.fcm.config.FcmServerConfig;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.radarbase.fcm.config.FcmServerConfig
import org.springframework.context.annotation.Configuration
import org.springframework.transaction.annotation.EnableTransactionManagement
import org.springframework.scheduling.annotation.EnableAsync

@Configuration
@EnableJpaAuditing
@EnableConfigurationProperties({FcmServerConfig.class})
@EnableConfigurationProperties(
FcmServerConfig::class
)
@EnableTransactionManagement
@EnableAsync
public class ApplicationConfig {}
class ApplicationConfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,28 @@
* *
*
*/
package org.radarbase.appserver.converter

package org.radarbase.appserver.converter;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

/**
* Generic converter class for conversions between entity {@link org.radarbase.appserver.entity} and
* DTO {@link org.radarbase.appserver.dto} objects.
* Generic converter class for conversions between entity [org.radarbase.appserver.entity] and
* DTO [org.radarbase.appserver.dto] objects.
*
* @param <T> the entity object class
* @param <S> the DTO object class
* @author yatharthranjan
* <p>TODO - Use MapStruct for mapping entities and DTOs (http://mapstruct.org/)
*/
public interface Converter<T, S> {

T dtoToEntity(S s);

S entityToDto(T t);
*
* TODO - Use MapStruct for mapping entities and DTOs (http://mapstruct.org/)
</S></T> */
interface Converter<T, S> {
fun dtoToEntity(s: S): T
fun entityToDto(t: T): S

default List<T> dtosToEntities(Collection<S> ss) {
return ss.parallelStream().map(this::dtoToEntity).collect(Collectors.toList());
}
fun dtosToEntities(ss: MutableCollection<S>): MutableList<T> {
return ss.map { s: S -> dtoToEntity(s) }.toMutableList()
}

default List<S> entitiesToDtos(Collection<T> ts) {
return ts.parallelStream().map(this::entityToDto).collect(Collectors.toList());
}
}
fun entitiesToDtos(ts: MutableCollection<T>): MutableList<S> {
return ts.map { t: T -> entityToDto(t) }.toMutableList()
}
}

This file was deleted.

Loading