How can you assemble an up-to-date stack of used libraries and frameworks so that you can comfortably develop if you are self-isolating in a remote village, fly 8 hours in an airplane or your company has limited access to the World Wide Web so that you cannot use public repositories of artifacts, such as maven central? How do we provide all the necessary artifacts that we depend on, including transitive dependencies? How to update them later along with new versions of the 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 — , .