¿Cómo puede ensamblar una pila actualizada de bibliotecas y marcos usados para que pueda desarrollar cómodamente si se aísla por sí mismo en una aldea remota, vuela 8 horas en un avión o su empresa tiene acceso limitado a la World Wide Web para que no pueda usar repositorios públicos de artefactos, como maven? ¿central? ¿Cómo proporcionamos todos los artefactos necesarios de los que dependemos, incluidas las dependencias transitivas? ¿Cómo actualizarlos más tarde junto con nuevas versiones del marco?
. 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 — , .