Comment pouvez-vous collecter la pile actuelle de bibliothèques et de frameworks utilisés afin de pouvoir développer confortablement si vous vous auto-isolez dans un village éloigné, si vous volez 8 heures en avion ou si votre entreprise a un accès limité au World Wide Web afin que vous ne puissiez pas utiliser de référentiels publics d'artefacts, tels que maven central? Comment pouvons-nous fournir tous les artefacts nécessaires dont nous dépendons, y compris les dépendances transitoires? Comment les mettre à jour plus tard avec les nouvelles versions du framework?
. CUBA SDK — , Maven- . , Java Maven-.
,
CUBA — Open Source Java . CUBA — , , , . 20 000 . . , , , .
JVM , Apache Maven Gradle , . .
, ?
, — Nexus . , , , . , , . .
?
- 0. .
- 1. .
- 2. .
0 , 1 2.
: , , . , . , , , , , . , , .
.
, — .
, , , , . , Gradle Maven. ,
- , ,
, , . , .
?
CUBA SDK
CUBA .
CUBA SDK, CUBA.
CUBA SDK Gradle Maven?
— CUBA SDK , , .
CUBA SDK , .
, , . SDK .
.
CUBA SDK . CUBA SDK .
CUBA SDK:
- CUBA Platform
- , maven
- Nexus OSS
- , maven
- CUBA Platform
- Gradle
- IDE
- CI
SDK
CUBA SDK : CUBA Framework, CUBA addon , maven . CUBA SDK.
install. SDK , SDK , resolve push.
resolve — SDK
push — target
SDK .
, SDK :
- source — ,
- target — ,
SDK , setup-nexus SDK , Nexus OSS. start stop.
check-updates.
, SDK — . . , .pom . , Apache Maven .
Maven
Apache Maven .
CUBA SDK maven SDK Java Runtime .
,
dependency:resolve -Dtransitive=true -DincludeParents=true -DoverWriteSnapshots=true -Dclassifier=<classifier> -f pom.xml
, pom.xml, maven,
org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy-file -Durl=<repository URL>
.
.
org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get -Dartifact=<maven coordinates>
Maven CUBA SDK settings.xml
. , .
Gradle
, , CUBA Platform, Gradle .
Gradle. build.gradle , .
Gradle Gradle Tooling API.
Gradle artifact resolution query API. :
def component = project.dependencies.createArtifactResolutionQuery()
.forComponents(artifact.id.componentIdentifier)
.withArtifacts(JvmLibrary, SourcesArtifact)
.execute()
.resolvedComponents[0]
def sourceFile = component?.getArtifacts(SourcesArtifact)[0]?.file
, Gradle SDK.
lenientConfiguration
.
project.ext.properties["toResolve"].tokenize(';').each {
dependencies.add 'extraLibs', it
}
def resolved = [:]
configurations.all.collect {
if (it.canBeResolved) {
it.resolvedConfiguration.lenientConfiguration.artifacts.each { art ->
try {
...
} catch (e) {
logger.error("Error: " + e.getMessage(), e)
logger.error("could not find pom for {}", art.file)
}
}
}
}
lenientConfiguration
, Gradle .
SDK PublishToMavenRepository
Gradle.
task publishArtifact(type: PublishToMavenRepository) {
doLast {
if (project.ext.hasProperty("toUpload")) {
def toUpload = new JsonSlurper().parseText(project.ext.properties["toUpload"])
def descriptors = new JsonSlurper().parseText(project.ext.properties["descriptors"])
artifactId toUpload.artifactId
groupId toUpload.groupId
version toUpload.version
descriptors.each { descriptor ->
artifact(descriptor.filePath) {
classifier descriptor.classifier.type
extension descriptor.classifier.extenstion
}
}
}
}
}
Gradle .
CUBA SDK , CUBA CLI. jlink JRE, . SDK Java. CLI Core Sample .
CUBA SDK CLI Core, CUBA SDK . SDK maven gradle CUBA .
, SDK . Spring Boot Spring Initializr.
implementation "com.haulmont.cli.core:cli-core:1.0.0"
implementation "com.haulmont.cli.sdk:cuba-sdk:1.0.1"
spring boot SpringBootProvider
, BintraySearchComponentProvider
. BintraySearchComponentProvider
, Bintray API.
class SpringBootProvider : BintraySearchComponentProvider() {
var springComponentsInfo: SpringComponentsInfo? = null
override fun getType() = "boot-starter"
override fun getName() = "Spring boot starter"
...
override fun load() {
springComponentsInfo = Gson().fromJson(readSpringFile(), SpringComponentsInfo::class.java)
}
private fun readSpringFile(): String {
return SpringComponentsPlugin::class.java.getResourceAsStream("spring-components.json")
.bufferedReader()
.use { it.readText() }
}
spring-components.json, json yml Spring Initializr.
json data :
data class SpringComponent(
val name: String,
val id: String,
val groupId: String?,
val artifactId: String?,
val description: String?,
val starter: Boolean? = true
)
data class SpringComponentCategory(
val name: String,
val content: List<SpringComponent>
)
data class SpringInitializr(
val dependencies: List<SpringComponentCategory>
)
data class SpringComponentsInfo(
val initializr: SpringInitializr
)
, SDK, init :
class SpringBootComponentsPlugin : CliPlugin {
private val componentRegistry: ComponentRegistry by sdkKodein.instance<ComponentRegistry>()
@Subscribe
fun onInit(event: InitPluginEvent) {
val bootProvider = SpringBootProvider()
componentRegistry.addProviders(bootProvider)
bootProvider.load()
}
}
. , IDE, gradle installPlugin.
SDK
, . , resolve boot-starter:
, .
maven , ArtifactManager, .
, CUBA SDK , .
, , , , . CUBA SDK — , .