git init
This commit is contained in:
commit
c38a5eeb80
45
.gitignore
vendored
Normal file
45
.gitignore
vendored
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
.gradle
|
||||||
|
build/
|
||||||
|
!gradle/wrapper/gradle-wrapper.jar
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
out/
|
||||||
|
!**/src/main/**/out/
|
||||||
|
!**/src/test/**/out/
|
||||||
|
|
||||||
|
### Kotlin ###
|
||||||
|
.kotlin
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
bin/
|
||||||
|
!**/src/main/**/bin/
|
||||||
|
!**/src/test/**/bin/
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
23
README.md
Normal file
23
README.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# AuthApplication
|
||||||
|
|
||||||
|
This project uses [Gradle](https://gradle.org/).
|
||||||
|
To build and run the application, use the *Gradle* tool window by clicking the Gradle icon in the right-hand toolbar,
|
||||||
|
or run it directly from the terminal:
|
||||||
|
|
||||||
|
* Run `./gradlew run` to build and run the application.
|
||||||
|
* Run `./gradlew build` to only build the application.
|
||||||
|
* Run `./gradlew check` to run all checks, including tests.
|
||||||
|
* Run `./gradlew clean` to clean all build outputs.
|
||||||
|
|
||||||
|
Note the usage of the Gradle Wrapper (`./gradlew`).
|
||||||
|
This is the suggested way to use Gradle in production projects.
|
||||||
|
|
||||||
|
[Learn more about the Gradle Wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html).
|
||||||
|
|
||||||
|
[Learn more about Gradle tasks](https://docs.gradle.org/current/userguide/command_line_interface.html#common_tasks).
|
||||||
|
|
||||||
|
This project follows the suggested multi-module setup and consists of the `app` and `utils` subprojects.
|
||||||
|
The shared build logic was extracted to a convention plugin located in `buildSrc`.
|
||||||
|
|
||||||
|
This project uses a version catalog (see `gradle/libs.versions.toml`) to declare and version dependencies
|
||||||
|
and both a build cache and a configuration cache (see `gradle.properties`).
|
19
app/build.gradle.kts
Normal file
19
app/build.gradle.kts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
plugins {
|
||||||
|
// Apply the shared build logic from a convention plugin.
|
||||||
|
// The shared code is located in `buildSrc/src/main/kotlin/kotlin-jvm.gradle.kts`.
|
||||||
|
id("buildsrc.convention.kotlin-jvm")
|
||||||
|
|
||||||
|
// Apply the Application plugin to add support for building an executable JVM application.
|
||||||
|
application
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// Project "app" depends on project "utils". (Project paths are separated with ":", so ":utils" refers to the top-level "utils" project.)
|
||||||
|
implementation(project(":utils"))
|
||||||
|
}
|
||||||
|
|
||||||
|
application {
|
||||||
|
// Define the Fully Qualified Name for the application main class
|
||||||
|
// (Note that Kotlin compiles `App.kt` to a class with FQN `com.example.app.AppKt`.)
|
||||||
|
mainClass = "org.example.app.AppKt"
|
||||||
|
}
|
23
app/src/main/kotlin/main.kt
Normal file
23
app/src/main/kotlin/main.kt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import model.UserAuthorize
|
||||||
|
import java.time.LocalDate
|
||||||
|
|
||||||
|
val authorizeList = mutableListOf<UserAuthorize>()
|
||||||
|
fun main(){
|
||||||
|
authorizeList.add(registration())
|
||||||
|
authorizeList.forEach {
|
||||||
|
println(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fun registration(): UserAuthorize {
|
||||||
|
val userLogin = readlnOrNull()
|
||||||
|
checkNotNull(userLogin)
|
||||||
|
require(userLogin.length >= 4){
|
||||||
|
"Никнейм должен быть больше 4 символов"
|
||||||
|
}
|
||||||
|
return UserAuthorize(
|
||||||
|
authorizeList.size + 1,
|
||||||
|
password = "123",
|
||||||
|
login = userLogin,
|
||||||
|
lastAuthorizeDate = LocalDate.now()
|
||||||
|
)
|
||||||
|
}
|
10
app/src/main/kotlin/model/UserAuthorize.kt
Normal file
10
app/src/main/kotlin/model/UserAuthorize.kt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import java.time.LocalDate
|
||||||
|
|
||||||
|
data class UserAuthorize(
|
||||||
|
val userId: Int,
|
||||||
|
val login: String,
|
||||||
|
var password: String,
|
||||||
|
var lastAuthorizeDate: LocalDate
|
||||||
|
)
|
15
buildSrc/build.gradle.kts
Normal file
15
buildSrc/build.gradle.kts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
plugins {
|
||||||
|
// The Kotlin DSL plugin provides a convenient way to develop convention plugins.
|
||||||
|
// Convention plugins are located in `src/main/kotlin`, with the file extension `.gradle.kts`,
|
||||||
|
// and are applied in the project's `build.gradle.kts` files as required.
|
||||||
|
`kotlin-dsl`
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvmToolchain(21)
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// Add a dependency on the Kotlin Gradle plugin, so that convention plugins can apply it.
|
||||||
|
implementation(libs.kotlinGradlePlugin)
|
||||||
|
}
|
17
buildSrc/settings.gradle.kts
Normal file
17
buildSrc/settings.gradle.kts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
dependencyResolutionManagement {
|
||||||
|
|
||||||
|
// Use Maven Central and the Gradle Plugin Portal for resolving dependencies in the shared build logic (`buildSrc`) project.
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reuse the version catalog from the main build.
|
||||||
|
versionCatalogs {
|
||||||
|
create("libs") {
|
||||||
|
from(files("../gradle/libs.versions.toml"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = "buildSrc"
|
29
buildSrc/src/main/kotlin/kotlin-jvm.gradle.kts
Normal file
29
buildSrc/src/main/kotlin/kotlin-jvm.gradle.kts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// The code in this file is a convention plugin - a Gradle mechanism for sharing reusable build logic.
|
||||||
|
// `buildSrc` is a Gradle-recognized directory and every plugin there will be easily available in the rest of the build.
|
||||||
|
package buildsrc.convention
|
||||||
|
|
||||||
|
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
// Apply the Kotlin JVM plugin to add support for Kotlin in JVM projects.
|
||||||
|
kotlin("jvm")
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
// Use a specific Java version to make it easier to work in different environments.
|
||||||
|
jvmToolchain(21)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Test>().configureEach {
|
||||||
|
// Configure all test Gradle tasks to use JUnitPlatform.
|
||||||
|
useJUnitPlatform()
|
||||||
|
|
||||||
|
// Log information about all test results, not only the failed ones.
|
||||||
|
testLogging {
|
||||||
|
events(
|
||||||
|
TestLogEvent.FAILED,
|
||||||
|
TestLogEvent.PASSED,
|
||||||
|
TestLogEvent.SKIPPED
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
7
gradle.properties
Normal file
7
gradle.properties
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Enable the build cache to save time by reusing outputs produced by other successful builds.
|
||||||
|
# https://docs.gradle.org/current/userguide/build_cache.html
|
||||||
|
org.gradle.caching=true
|
||||||
|
# Enable the configuration cache to reuse the build configuration and enable parallel task execution.
|
||||||
|
# (Note that some plugins may not yet be compatible with the configuration cache.)
|
||||||
|
# https://docs.gradle.org/current/userguide/configuration_cache.html
|
||||||
|
org.gradle.configuration-cache=true
|
22
gradle/libs.versions.toml
Normal file
22
gradle/libs.versions.toml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Version catalog is a central place for you to declare and version dependencies
|
||||||
|
# https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
|
||||||
|
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format
|
||||||
|
|
||||||
|
[versions]
|
||||||
|
kotlin = "2.0.21"
|
||||||
|
kotlinxDatetime = "0.6.1"
|
||||||
|
kotlinxSerializationJSON = "1.7.2"
|
||||||
|
kotlinxCoroutines = "1.8.1"
|
||||||
|
|
||||||
|
[libraries]
|
||||||
|
kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||||
|
kotlinxDatetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinxDatetime" }
|
||||||
|
kotlinxSerialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJSON" }
|
||||||
|
kotlinxCoroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" }
|
||||||
|
|
||||||
|
# Libraries can be bundled together for easier import
|
||||||
|
[bundles]
|
||||||
|
kotlinxEcosystem = ["kotlinxDatetime", "kotlinxSerialization", "kotlinxCoroutines"]
|
||||||
|
|
||||||
|
[plugins]
|
||||||
|
kotlinPluginSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
25
settings.gradle.kts
Normal file
25
settings.gradle.kts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// The settings file is the entry point of every Gradle build.
|
||||||
|
// Its primary purpose is to define the subprojects.
|
||||||
|
// It is also used for some aspects of project-wide configuration, like managing plugins, dependencies, etc.
|
||||||
|
// https://docs.gradle.org/current/userguide/settings_file_basics.html
|
||||||
|
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
// Use Maven Central as the default repository (where Gradle will download dependencies) in all subprojects.
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
// Use the Foojay Toolchains plugin to automatically download JDKs required by subprojects.
|
||||||
|
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Include the `app` and `utils` subprojects in the build.
|
||||||
|
// If there are changes in only one of the projects, Gradle will rebuild only the one that has changed.
|
||||||
|
// Learn more about structuring projects with Gradle - https://docs.gradle.org/8.7/userguide/multi_project_builds.html
|
||||||
|
include(":app")
|
||||||
|
include(":utils")
|
||||||
|
|
||||||
|
rootProject.name = "AuthApplication"
|
13
utils/build.gradle.kts
Normal file
13
utils/build.gradle.kts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
plugins {
|
||||||
|
// Apply the shared build logic from a convention plugin.
|
||||||
|
// The shared code is located in `buildSrc/src/main/kotlin/kotlin-jvm.gradle.kts`.
|
||||||
|
id("buildsrc.convention.kotlin-jvm")
|
||||||
|
// Apply Kotlin Serialization plugin from `gradle/libs.versions.toml`.
|
||||||
|
alias(libs.plugins.kotlinPluginSerialization)
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// Apply the kotlinx bundle of dependencies from the version catalog (`gradle/libs.versions.toml`).
|
||||||
|
implementation(libs.bundles.kotlinxEcosystem)
|
||||||
|
testImplementation(kotlin("test"))
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user