Skip to content

Commit 001ba44

Browse files
committed
Update dependencies and auth
1 parent 792cf5d commit 001ba44

File tree

3 files changed

+31
-35
lines changed

3 files changed

+31
-35
lines changed

build.gradle.kts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
22

33
plugins {
4-
kotlin("jvm") version "1.4.21"
4+
kotlin("jvm") version "1.6.10"
55
application
6-
id("org.openjfx.javafxplugin") version "0.0.8"
6+
id("org.openjfx.javafxplugin") version "0.0.12"
77
//id("org.beryx.jlink") version "2.17.1"
88
//id("com.github.johnrengelman.shadow") version "5.2.0"
9-
id("org.beryx.runtime") version "1.9.1"
9+
id("org.beryx.runtime") version "1.12.7"
1010
}
1111

1212
group = "ru.mipt.physics"
13-
version = "1.1.3"
13+
version = "1.1.4"
1414

1515
val compileKotlin: KotlinCompile by tasks
1616
val compileJava: JavaCompile by tasks
17-
compileJava.destinationDir = compileKotlin.destinationDir
17+
compileJava.destinationDirectory.set(compileKotlin.destinationDirectory.get())
1818

1919
compileKotlin.kotlinOptions {
2020
jvmTarget = "11"
2121
}
2222

2323
application {
24-
mainClassName = "ru.mipt.physics.survey.ReportAppKt"
24+
mainClass.set("ru.mipt.physics.survey.ReportAppKt")
2525
}
2626

2727
repositories {
2828
mavenCentral()
29-
jcenter()
3029
}
3130

3231
dependencies {
@@ -35,12 +34,12 @@ dependencies {
3534
implementation("no.tornado:tornadofx:1.7.20") {
3635
exclude("org.jetbrains.kotlin")
3736
}
38-
implementation("org.freemarker:freemarker:2.3.29")
39-
implementation("com.google.api-client:google-api-client:1.30.10")
40-
implementation("com.google.oauth-client:google-oauth-client-jetty:1.30.4")
41-
implementation("com.google.apis:google-api-services-sheets:v4-rev612-1.25.0")
37+
implementation("org.freemarker:freemarker:2.3.31")
38+
implementation("com.google.api-client:google-api-client:1.33.2")
39+
implementation("com.google.oauth-client:google-oauth-client-jetty:1.33.1")
40+
implementation("com.google.apis:google-api-services-sheets:v4-rev20220308-1.32.1")
4241

43-
testImplementation("junit:junit:4.+")
42+
testImplementation("junit:junit:4.13.2")
4443
}
4544

4645
javafx {
@@ -50,13 +49,13 @@ javafx {
5049
runtime {
5150
imageZip.set(project.file("${project.buildDir}/image-zip/phys-survey.zip"))
5251
options.set(listOf("--strip-debug", "--compress", "2", "--no-header-files", "--no-man-pages"))
53-
modules.set(listOf("java.desktop", "jdk.unsupported", "java.scripting", "java.logging", "java.xml", "jdk.crypto.ec"))
52+
modules.set(listOf("java.desktop", "jdk.unsupported", "java.scripting", "java.logging", "java.xml", "jdk.crypto.ec","jdk.httpserver"))
5453

5554
jpackage {
5655
imageName = "mipt-physics-survey"
5756
skipInstaller = false
5857
installerName = "mipt-physics-survey"
5958
installerType = "msi"
60-
installerOptions = listOf("--win-menu", "--win-shortcut", "--win-dir-chooser","--win-per-user-install")
59+
installerOptions = listOf("--win-menu", "--win-shortcut", "--win-dir-chooser","--win-per-user-install", "--vendor", "MIPT-NPM")
6160
}
6261
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/kotlin/ru/mipt/physics/survey/SurveyData.kt

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow
77
import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets
88
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport
99
import com.google.api.client.http.HttpTransport
10-
import com.google.api.client.json.jackson2.JacksonFactory
10+
import com.google.api.client.json.gson.GsonFactory
1111
import com.google.api.client.util.store.FileDataStoreFactory
1212
import com.google.api.services.sheets.v4.Sheets
1313
import com.google.api.services.sheets.v4.SheetsScopes
1414
import java.io.*
1515
import java.time.LocalDate
1616
import java.time.format.DateTimeFormatter
17-
import java.util.*
1817
import java.util.logging.Level
1918
import java.util.logging.Logger
20-
import kotlin.collections.ArrayList
2119

2220

2321
const val lectureFunKey = "Увлекательность подачи материала"
@@ -72,19 +70,17 @@ object SurveyData {
7270
* Update data from server
7371
*/
7472
fun update(callback: UpdateCallback) {
75-
synchronized(this) {
76-
callback.notifyUpdateInProgress(true)
77-
try {
78-
callback.notifyUpdateMessage("Загрузка данных с сервера")
79-
val newEntries = Connection.download(entries.size)
80-
entries.addAll(newEntries)
81-
callback.notifyUpdateMessage("Загружено ${newEntries.size} новых записи с сервера")
82-
if (newEntries.isNotEmpty()) {
83-
save()
84-
}
85-
} finally {
86-
callback.notifyUpdateInProgress(false)
73+
callback.notifyUpdateInProgress(true)
74+
try {
75+
callback.notifyUpdateMessage("Загрузка данных с сервера")
76+
val newEntries = Connection.download(entries.size)
77+
entries.addAll(newEntries)
78+
callback.notifyUpdateMessage("Загружено ${newEntries.size} новых записи с сервера")
79+
if (newEntries.isNotEmpty()) {
80+
save()
8781
}
82+
} finally {
83+
callback.notifyUpdateInProgress(false)
8884
}
8985
}
9086

@@ -120,7 +116,7 @@ object SurveyData {
120116

121117
private fun save() {
122118
synchronized(this) {
123-
if (!entries.isEmpty()) {
119+
if (entries.isNotEmpty()) {
124120
val file = File(STORE_FILE_NAME)
125121
try {
126122
ObjectOutputStream(file.outputStream()).use {
@@ -155,7 +151,7 @@ private object Connection {
155151
private val DATA_STORE_FACTORY: FileDataStoreFactory = FileDataStoreFactory(DATA_STORE_DIR)
156152

157153
/** Global instance of the JSON factory. */
158-
private val JSON_FACTORY = JacksonFactory.getDefaultInstance()
154+
private val JSON_FACTORY = GsonFactory.getDefaultInstance()
159155

160156
/** Global instance of the HTTP transport. */
161157
private val HTTP_TRANSPORT: HttpTransport = GoogleNetHttpTransport.newTrustedTransport()
@@ -165,7 +161,7 @@ private object Connection {
165161
* If modifying these scopes, delete your previously saved credentials
166162
* at ~/.credentials/sheets.googleapis.com-java-quickstart
167163
*/
168-
private val SCOPES = Arrays.asList(SheetsScopes.SPREADSHEETS_READONLY)
164+
private val SCOPES = listOf(SheetsScopes.SPREADSHEETS_READONLY)
169165

170166
/**
171167
* Build and return an authorized Sheets API client service.
@@ -187,7 +183,7 @@ private object Connection {
187183
@Throws(IOException::class)
188184
private fun authorize(): Credential {
189185
// Load client secrets.
190-
val input = Connection::class.java.getResourceAsStream("/client_secret.json")
186+
val input = Connection::class.java.getResourceAsStream("/client_secret.json")!!
191187
val clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, InputStreamReader(input))
192188

193189
// Build flow and trigger user authorization request.
@@ -196,6 +192,7 @@ private object Connection {
196192
).setDataStoreFactory(DATA_STORE_FACTORY)
197193
.setAccessType("offline")
198194
.build()
195+
199196
val credential = AuthorizationCodeInstalledApp(
200197
flow, LocalServerReceiver()
201198
).authorize("user")
@@ -252,7 +249,7 @@ private object Connection {
252249
}
253250
}
254251

255-
fun reset(){
252+
fun reset() {
256253
DATA_STORE_DIR.takeIf { it.exists() }?.delete()
257254
}
258255
}

0 commit comments

Comments
 (0)