From b70ac7d11ea7d1317e79069225b8412279dd6676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergej=20Ko=C5=A1=C4=8Dejev?= Date: Thu, 24 Oct 2024 08:34:28 +0200 Subject: [PATCH 1/5] build: configure `test` and `check` tasks It should be possible to run `./gradlew check` on CI and have it run all tests. --- build/com.mbeddr/languages/build.gradle | 15 +++++++++++++-- build/com.mbeddr/platform/build.gradle | 12 ++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/build/com.mbeddr/languages/build.gradle b/build/com.mbeddr/languages/build.gradle index 21fd03e3abd..89e8007cde0 100755 --- a/build/com.mbeddr/languages/build.gradle +++ b/build/com.mbeddr/languages/build.gradle @@ -1,5 +1,9 @@ import de.itemis.mps.gradle.* +plugins { + id 'lifecycle-base' +} + // :com.mbeddr.build def script_build_mbeddr = new File(scriptsBasePath + "/com.mbeddr.build/" + "build.xml") @@ -157,6 +161,15 @@ task test_mbeddr_xmodel(dependsOn: []) {} task test_mbeddr(dependsOn: [test_mbeddr_core, test_mbeddr_performance, test_mbeddr_cc, test_mbeddr_ext, test_mbeddr_xmodel]) {} +tasks.register('test') { + dependsOn(test_mbeddr) +} + +tasks.named('check') { + dependsOn 'test' +} + + def pubDeb if (ciBuild) { pubDeb = test_mbeddr @@ -220,5 +233,3 @@ if({project.mbeddrBuild}() == "master") { */ tasks.findByName("publishMbeddrPublicationToMavenRepository").dependsOn("publishMbeddrPublicationToGitHubPackagesRepository") } - -check.dependsOn test_mbeddr diff --git a/build/com.mbeddr/platform/build.gradle b/build/com.mbeddr/platform/build.gradle index 17f8dead8e7..c985b8a7690 100755 --- a/build/com.mbeddr/platform/build.gradle +++ b/build/com.mbeddr/platform/build.gradle @@ -1,3 +1,7 @@ +plugins { + id 'lifecycle-base' +} + import de.itemis.mps.gradle.* def script_test_mbeddrPlatform = new File(scriptsBasePath + "/com.mbeddr.platform/" + "build-ts-tests.xml") @@ -93,6 +97,14 @@ task test_mbeddr_platform(type: TestLanguages, dependsOn: build_platform) { description "execute typesystem and generator tests for the plaform" } +tasks.register('test') { + dependsOn(test_mbeddr_platform) +} + +tasks.named('check') { + dependsOn('test') +} + task build_platform_distribution(type: BuildLanguages, dependsOn: [build_platform, test_mbeddr_platform]) { script scriptFile('com.mbeddr.platform/build-distribution.xml') } From 86c8a9f3fc950a78655668f871c57080e834c2f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergej=20Ko=C5=A1=C4=8Dejev?= Date: Thu, 24 Oct 2024 09:02:35 +0200 Subject: [PATCH 2/5] build: model mbeddr->platform dependency via configurations It is a Gradle best practice to use configurations and project dependencies rather than task dependencies. --- build/com.mbeddr/languages/build.gradle | 26 +++++++++++++------------ build/com.mbeddr/platform/build.gradle | 7 ++++++- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/build/com.mbeddr/languages/build.gradle b/build/com.mbeddr/languages/build.gradle index 89e8007cde0..ddbdfcbd126 100755 --- a/build/com.mbeddr/languages/build.gradle +++ b/build/com.mbeddr/languages/build.gradle @@ -21,6 +21,8 @@ configurations { mbeddrPlatform } +def usePrebuiltPlatform = ciBuild && !project.hasProperty('forceBuildPlatform') + dependencies { junitAnt 'junit:junit:4.12' junitAnt('org.apache.ant:ant-junit:1.9.7') { @@ -29,9 +31,18 @@ dependencies { junitAnt('org.apache.ant:ant-junit4:1.9.7') { transitive = false } - mbeddrPlatform "com.mbeddr:platform:$mbeddrPlatformBuildNumber" -} + def mbeddrPlatformDependency + + if (usePrebuiltPlatform) { + // By default, on CI we don't build the platform but take it from Nexus, unless overridden by `-PforceBuildPlatform`. + mbeddrPlatformDependency = "com.mbeddr:platform:$mbeddrPlatformBuildNumber" + } else { + mbeddrPlatformDependency = project(':com.mbeddr:platform') + } + + mbeddrPlatform mbeddrPlatformDependency +} task resolve_mbeddr_platform() { doLast { @@ -56,16 +67,7 @@ ant.taskdef(name: 'junitreport', classname: 'org.apache.tools.ant.taskdefs.optio def mbeddrPlatformDependency -def usePrebuiltPlatform = ciBuild && !project.hasProperty('forceBuildPlatform') - -//on teamcity we don't build the platform we take it from the nexus. Locally we want to build it -if (usePrebuiltPlatform) { - mbeddrPlatformDependency = resolve_mbeddr_platform -} else { - mbeddrPlatformDependency = ':com.mbeddr:platform:build_platform' -} - -task build_mbeddr(type: BuildLanguages, dependsOn: [':com.mbeddr:platform:copy_allScripts', mbeddrPlatformDependency]) { +task build_mbeddr(type: BuildLanguages, dependsOn: [':com.mbeddr:platform:copy_allScripts', configurations.mbeddrPlatform]) { script script_build_mbeddr outputs.dir("$artifactsDir/mbeddr") } diff --git a/build/com.mbeddr/platform/build.gradle b/build/com.mbeddr/platform/build.gradle index c985b8a7690..1bf78cc0ddd 100755 --- a/build/com.mbeddr/platform/build.gradle +++ b/build/com.mbeddr/platform/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'lifecycle-base' + id 'base' } import de.itemis.mps.gradle.* @@ -115,6 +115,11 @@ task package_mbeddrPlatform(type: Zip, dependsOn: test_mbeddr_platform) { include "com.mbeddr.platform/**" } +artifacts { + 'default'(package_mbeddrPlatform) +} + + task defaultWrapper(dependsOn: build_platform) { doFirst { println "####################################################################################" From e3d97ae55024461afe3163198b769136ffd99ea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergej=20Ko=C5=A1=C4=8Dejev?= Date: Thu, 24 Oct 2024 09:04:29 +0200 Subject: [PATCH 3/5] build: do not test mbeddr platform when packaging Test only when explicitly requested. --- build/com.mbeddr/platform/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/com.mbeddr/platform/build.gradle b/build/com.mbeddr/platform/build.gradle index 1bf78cc0ddd..854b5adea99 100755 --- a/build/com.mbeddr/platform/build.gradle +++ b/build/com.mbeddr/platform/build.gradle @@ -109,7 +109,7 @@ task build_platform_distribution(type: BuildLanguages, dependsOn: [build_platfor script scriptFile('com.mbeddr.platform/build-distribution.xml') } -task package_mbeddrPlatform(type: Zip, dependsOn: test_mbeddr_platform) { +task package_mbeddrPlatform(type: Zip, dependsOn: build_platform) { archiveFileName = 'com.mbeddr.platform.zip' from artifactsDir include "com.mbeddr.platform/**" From 940ca527dfc5ba35a7f31f4d2f17dc2b2683bcbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergej=20Ko=C5=A1=C4=8Dejev?= Date: Thu, 24 Oct 2024 09:05:10 +0200 Subject: [PATCH 4/5] build: add mbeddr artifact, do not test when packaging It is now possible to use the standard `assemble` task to assemble the artifacts without running tests. This follows Gradle conventions. --- build/com.mbeddr/languages/build.gradle | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/build/com.mbeddr/languages/build.gradle b/build/com.mbeddr/languages/build.gradle index ddbdfcbd126..930c98e62ed 100755 --- a/build/com.mbeddr/languages/build.gradle +++ b/build/com.mbeddr/languages/build.gradle @@ -171,20 +171,16 @@ tasks.named('check') { dependsOn 'test' } - -def pubDeb -if (ciBuild) { - pubDeb = test_mbeddr -} else { - pubDeb = build_mbeddr -} - -task package_mbeddr(type: Zip, dependsOn: pubDeb) { +task package_mbeddr(type: Zip, dependsOn: build_mbeddr) { archiveFileName = 'com.mbeddr.zip' from artifactsDir include "mbeddr/**" } +artifacts { + 'default'(package_mbeddr) +} + publishing { publications { mbeddr(MavenPublication) { From 249894a16a94e6cb0d4ee56fb080c74220f51d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergej=20Ko=C5=A1=C4=8Dejev?= Date: Thu, 24 Oct 2024 19:22:43 +0200 Subject: [PATCH 5/5] build: remove Graphviz It never changes, yet we publish it again on every PR. If needed again, it should be published via a separate repository, manually triggered. --- build/thirdparty/build.gradle | 24 -------------- build/thirdparty/graphviz/build.gradle | 44 -------------------------- settings.gradle.kts | 3 -- 3 files changed, 71 deletions(-) delete mode 100644 build/thirdparty/build.gradle delete mode 100644 build/thirdparty/graphviz/build.gradle diff --git a/build/thirdparty/build.gradle b/build/thirdparty/build.gradle deleted file mode 100644 index f7ca3646c18..00000000000 --- a/build/thirdparty/build.gradle +++ /dev/null @@ -1,24 +0,0 @@ -plugins { - id 'de.undercouch.download' version '5.4.0' apply false -} - -subprojects { - apply plugin: 'de.undercouch.download' - apply plugin: 'base' - apply plugin: 'maven-publish' - - publishing { - repositories { - maven { - if (project.hasProperty('artifacts.itemis.cloud.user') && project.hasProperty('artifacts.itemis.cloud.pw')) { - credentials { - username project.getProperty('artifacts.itemis.cloud.user') - password project.getProperty('artifacts.itemis.cloud.pw') - } - } - url project.releaseRepository - } - } - } - -} diff --git a/build/thirdparty/graphviz/build.gradle b/build/thirdparty/graphviz/build.gradle deleted file mode 100644 index b6c73a87019..00000000000 --- a/build/thirdparty/graphviz/build.gradle +++ /dev/null @@ -1,44 +0,0 @@ -// Graphviz is only published for Windows. Mac/Linux users will have to install it themselves. - -import de.undercouch.gradle.tasks.download.Download - -group 'org.graphviz' -version '2.38' - -task getGraphvizWindows(type: Download) { - src "https://www2.graphviz.org/Archive/stable/windows/graphviz-${version}.zip" - dest "$buildDir/graphviz-${version}-windows.zip" - overwrite false -} - -task unzipGraphvizWindows(type: Copy, dependsOn: getGraphvizWindows) { - from zipTree(getGraphvizWindows.dest) - into "$buildDir/graphviz-${version}-windows" -} - -task repackageGraphvizWindows(type: Zip, dependsOn: unzipGraphvizWindows) { - from(new File(unzipGraphvizWindows.destinationDir, "release")) -} - -publishing { - publications { - graphvizWindows(MavenPublication) { - artifactId 'graphviz' - artifact(repackageGraphvizWindows) { - classifier 'windows' - } - pom { - licenses { - license { - name = "EPL-1.0" - url = "https://gitlab.com/graphviz/graphviz/-/blob/main/LICENSE?ref_type=heads" - comments = "Eclipse Public License - v 1.0" - distribution = "repo" } - } - scm { - url = "https://gitlab.com/graphviz/graphviz/" - } - } - } - } -} diff --git a/settings.gradle.kts b/settings.gradle.kts index 9d8cf707bb3..38ac47f59b5 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -10,9 +10,6 @@ val subprojectPaths = listOf("com.mbeddr", "com.mbeddr:languages", "com.mbeddr:distribution", "com.mbeddr:analyses.test", - "thirdparty", - "thirdparty:graphviz", - "thirdparty:jdk", "publishing") fun fqpath(path: String) = ":$path"