Skip to content

Commit

Permalink
Use DSL for the rest of MPS jars
Browse files Browse the repository at this point in the history
  • Loading branch information
sergej-koscejev committed Nov 2, 2024
1 parent 443d4c9 commit 6e1add3
Showing 1 changed file with 91 additions and 206 deletions.
297 changes: 91 additions & 206 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,115 +50,6 @@ task publishMPS(type: Zip, dependsOn: unzipMPS) {
from mpsUnpackedDir
}

/*
* Repackage frequently needed JAR libraries shipping with MPS (in the lib and plugins folders) as individually consumable artifacts.
* This is useful for the development of command line utilities, Maven plugins, Gradle plugins, or other things
* that require only smaller parts of the MPS runtime and don't want to end up with a full MPS in their dependencies.
*/

task packageMpsCore(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'mps-core'
from zipTree("$mpsUnpackedDir/lib/mps-core.jar")
}

task packageMpsCoreSources(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'mps-core'
archiveClassifier = 'sources'
from zipTree("$mpsUnpackedDir/lib/MPS-src.zip")
}

task packageMpsEditor(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'mps-editor'
from zipTree("$mpsUnpackedDir/lib/mps-editor.jar")
}

task packageMpsEditorApi(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'mps-editor-api'
from zipTree("$mpsUnpackedDir/lib/mps-editor-api.jar")
}

task packageMpsEditorRuntime(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'mps-editor-runtime'
from zipTree("$mpsUnpackedDir/lib/mps-editor-runtime.jar")
}

task packageMpsOpenApi(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'mps-openapi'
from zipTree("$mpsUnpackedDir/lib/mps-openapi.jar")
}

task packageMpsOpenApiSources(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'mps-openapi'
archiveClassifier = 'sources'
from(zipTree("$mpsUnpackedDir/lib/MPS-src.zip")) {
include 'org/jetbrains/mps/**'
}
}

task packageMpsTool(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'mps-tool'
from zipTree("$mpsUnpackedDir/lib/mpsant/mps-tool.jar")
}

task packageMpsToolSources(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'mps-tool'
archiveClassifier = 'sources'
from(zipTree("$mpsUnpackedDir/lib/MPS-src.zip")) {
include 'jetbrains/mps/tool/builder/**'
}
}

task packageMpsRun(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'mps-run'
from zipTree("$mpsUnpackedDir/lib/mpsant/mps-run.jar")
}

// MPS-src.zip doesn't contain sources for mps-run.jar
/*
task packageMpsRunSources(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'mps-run'
archiveClassifier = 'sources'
from zipTree("$mpsUnpackedDir/lib/MPS-src.zip")
}
*/

task packageMpsEnvironment(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'mps-environment'
from zipTree("$mpsUnpackedDir/lib/mps-environment.jar")
}

task packageMpsEnvironmentSources(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'mps-environment'
archiveClassifier = 'sources'
from(zipTree("$mpsUnpackedDir/lib/MPS-src.zip")) {
include 'jetbrains/mps/tool/common/**'
include 'jetbrains/mps/tool/environment/**'
include 'jetbrains/mps/core/tool/environment/**'
}
}

task packageMpsPlatform(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'mps-platform'
from zipTree("$mpsUnpackedDir/lib/mps-platform.jar")
}

task packageMpsPlatformSources(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'mps-platform'
archiveClassifier = 'sources'
from zipTree("$mpsUnpackedDir/lib/MPS-src.zip")
}

task packageUtil(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'util'
from zipTree("$mpsUnpackedDir/lib/util.jar")
}

task packageUtilSources(type: Jar, dependsOn: unzipMPS) {
archiveBaseName = 'util'
archiveClassifier = 'sources'
from zipTree("$mpsUnpackedDir/lib/MPS-src.zip")
}

def additionalPomInfo = {
licenses {
// official SPDX identifier
Expand Down Expand Up @@ -205,86 +96,15 @@ publishing {
artifact publishMPS
pom additionalPomInfo
}
mpsCore(MavenPublication) {
groupId 'com.jetbrains'
artifactId 'mps-core'
version mpsVersion
artifact packageMpsCore
artifact packageMpsCoreSources
pom additionalPomInfo
}
mpsEditor(MavenPublication) {
groupId 'com.jetbrains'
artifactId 'mps-editor'
version mpsVersion
artifact packageMpsEditor
pom additionalPomInfo
}
mpsEditorApi(MavenPublication) {
groupId 'com.jetbrains'
artifactId 'mps-editor-api'
version mpsVersion
artifact packageMpsEditorApi
pom additionalPomInfo
}
mpsEditorRuntime(MavenPublication) {
groupId 'com.jetbrains'
artifactId 'mps-editor-runtime'
version mpsVersion
artifact packageMpsEditorRuntime
pom additionalPomInfo
}
mpsOpenApi(MavenPublication) {
groupId 'com.jetbrains'
artifactId 'mps-openapi'
version mpsVersion
artifact packageMpsOpenApi
artifact packageMpsOpenApiSources
pom additionalPomInfo
}
mpsTool(MavenPublication) {
groupId 'com.jetbrains'
artifactId 'mps-tool'
version mpsVersion
artifact packageMpsTool
artifact packageMpsToolSources
pom additionalPomInfo
}
mpsRun(MavenPublication) {
groupId 'com.jetbrains'
artifactId 'mps-run'
version mpsVersion
artifact packageMpsRun
//artifact packageMpsRunSources
pom additionalPomInfo
}
mpsEnvironment(MavenPublication) {
groupId 'com.jetbrains'
artifactId 'mps-environment'
version mpsVersion
artifact packageMpsEnvironment
artifact packageMpsEnvironmentSources
pom additionalPomInfo
}
mpsPlatform(MavenPublication) {
groupId 'com.jetbrains'
artifactId 'mps-platform'
version mpsVersion
artifact packageMpsPlatform
artifact packageMpsPlatformSources
pom additionalPomInfo
}
util(MavenPublication) {
groupId 'com.jetbrains'
artifactId 'util'
version mpsVersion
artifact packageUtil
artifact packageUtilSources
pom additionalPomInfo
}
}
}

/*
* Repackage frequently needed JAR libraries shipping with MPS (in the lib and plugins folders) as individually consumable artifacts.
* This is useful for the development of command line utilities, Maven plugins, Gradle plugins, or other things
* that require only smaller parts of the MPS runtime and don't want to end up with a full MPS in their dependencies.
*/

class MpsJar {
final String name
String customArtifactId
Expand Down Expand Up @@ -329,15 +149,18 @@ void createPublicationsFromMpsJars(Iterable<MpsJar> mpsJars, mpsUnpackedDir, add

TaskProvider<Jar> packageSourcesTask

if (mpsJar.relativeSourcesPath == null && mpsJar.sourceIncludes.isEmpty()) {
if (mpsJar.relativeSourcesPath == null) {
if (!mpsJar.sourceIncludes.isEmpty()) {
throw new IllegalArgumentException("MPS jar ${mpsJar.name} specified source include patterns but no source path")
}
packageSourcesTask = null
} else {
packageSourcesTask = tasks.register("package${mpsJar.name.capitalize()}Sources", Jar) {
dependsOn(unzipMPS)
archiveBaseName = jarBaseName
archiveClassifier = 'sources'
from(zipTree("$mpsUnpackedDir/${mpsJar.relativeSourcesPath ?: 'lib/MPS-src.zip'}")) { spec ->
mpsJar.sourceIncludes.each { pattern -> spec.include(pattern) }
from(zipTree("$mpsUnpackedDir/${mpsJar.relativeSourcesPath ?: 'lib/MPS-src.zip'}")) { CopySpec spec ->
spec.include(mpsJar.sourceIncludes)
}
}
}
Expand All @@ -360,42 +183,104 @@ mpsJars.configure {
relativePath = 'lib/annotations.jar'
}

mpsWorkbench {
relativePath = 'lib/mps-workbench.jar'
mpsConsoleIdeCommandsRuntime {
relativePath = 'plugins/mps-console/lang/jetbrains.mps.console.ideCommands.runtime.jar'
relativeSourcesPath = 'plugins/mps-console/lang/jetbrains.mps.console.ideCommands.runtime-src.jar'

customArtifactId = 'mps-console-ide-commands-runtime'
}

mpsProjectCheck {
relativePath = 'lib/mps-project-check.jar'
mpsCore {
relativePath = 'lib/mps-core.jar'
relativeSourcesPath = 'lib/MPS-src.zip'
}

sourcesInclude 'jetbrains/mps/checkers/**'
sourcesInclude 'jetbrains/mps/core/platform/MPSProjectValidation.java'
sourcesInclude 'jetbrains/mps/project/validation/**'
mpsEditor {
relativePath = 'lib/mps-editor.jar'
}

mpsHttpsupportRuntime {
relativePath = 'plugins/mps-httpsupport/solutions/jetbrains.mps.ide.httpsupport.runtime.jar'
mpsEditorApi {
relativePath = 'lib/mps-editor-api.jar'
}

sourcesInclude 'jetbrains/mps/ide/httpsupport/runtime/**'
mpsEditorRuntime {
relativePath = 'lib/mps-editor-runtime.jar'
}

mpsModelchecker {
relativePath = 'plugins/mps-modelchecker/lib/modelchecker.jar'
mpsEnvironment {
relativePath = 'lib/mps-environment.jar'

sourcesInclude 'jetbrains/mps/ide/modelchecker/**'
relativeSourcesPath = 'lib/MPS-src.zip'
sourcesInclude 'jetbrains/mps/tool/common/**'
sourcesInclude 'jetbrains/mps/tool/environment/**'
sourcesInclude 'jetbrains/mps/core/tool/environment/**'
}

mpsHttpsupportRuntime {
relativePath = 'plugins/mps-httpsupport/solutions/jetbrains.mps.ide.httpsupport.runtime.jar'

relativeSourcesPath = 'lib/MPS-src.zip'
sourcesInclude 'jetbrains/mps/ide/httpsupport/runtime/**'
}

if (mpsVersion < '2023') {
// 2022.3 was the last version to have these jars
mpsMessaging {
relativePath = 'lib/mps-messaging.jar'

relativeSourcesPath = 'lib/MPS-src.zip'
sourcesInclude 'jetbrains/mps/messages/**'
}
}

mpsConsoleIdeCommandsRuntime {
relativePath = 'plugins/mps-console/lang/jetbrains.mps.console.ideCommands.runtime.jar'
relativeSourcesPath = 'plugins/mps-console/lang/jetbrains.mps.console.ideCommands.runtime-src.jar'
customArtifactId = 'mps-console-ide-commands-runtime'
mpsModelchecker {
relativePath = 'plugins/mps-modelchecker/lib/modelchecker.jar'

relativeSourcesPath = 'lib/MPS-src.zip'
sourcesInclude 'jetbrains/mps/ide/modelchecker/**'
}

mpsOpenApi {
relativePath = 'lib/mps-openapi.jar'
relativeSourcesPath = 'lib/MPS-src.zip'

sourcesInclude 'org/jetbrains/mps/**'
}

mpsPlatform {
relativePath = 'lib/mps-platform.jar'
relativeSourcesPath = 'lib/MPS-src.zip'
}

mpsProjectCheck {
relativePath = 'lib/mps-project-check.jar'

relativeSourcesPath = 'lib/MPS-src.zip'
sourcesInclude 'jetbrains/mps/checkers/**'
sourcesInclude 'jetbrains/mps/core/platform/MPSProjectValidation.java'
sourcesInclude 'jetbrains/mps/project/validation/**'
}

mpsRun {
relativePath = 'lib/mpsant/mps-run.jar'

// MPS-src.zip does not contain sources for mps-run.jar
//relativeSourcesPath = 'lib/MPS-src.zip'
}

mpsTool {
relativePath = 'lib/mpsant/mps-tool.jar'
relativeSourcesPath = 'lib/MPS-src.zip'
sourcesInclude 'jetbrains/mps/tool/builder/**'
}

mpsWorkbench {
relativePath = 'lib/mps-workbench.jar'
}

util {
relativePath = 'lib/util.jar'
relativeSourcesPath = 'lib/MPS-src.zip'
}
}

Expand Down

0 comments on commit 6e1add3

Please sign in to comment.