Skip to content

Commit

Permalink
Merge pull request #2563 from mbeddr/feature/build-lifecycle-tasks
Browse files Browse the repository at this point in the history
build: Use Gradle lifecycle tasks
  • Loading branch information
sergej-koscejev authored Oct 24, 2024
2 parents 72efd7d + 940ca52 commit 33492bd
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 21 deletions.
49 changes: 29 additions & 20 deletions build/com.mbeddr/languages/build.gradle
Original file line number Diff line number Diff line change
@@ -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")

Expand All @@ -17,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') {
Expand All @@ -25,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 {
Expand All @@ -52,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")
}
Expand Down Expand Up @@ -157,19 +163,24 @@ task test_mbeddr_xmodel(dependsOn: []) {}

task test_mbeddr(dependsOn: [test_mbeddr_core, test_mbeddr_performance, test_mbeddr_cc, test_mbeddr_ext, test_mbeddr_xmodel]) {}

def pubDeb
if (ciBuild) {
pubDeb = test_mbeddr
} else {
pubDeb = build_mbeddr
tasks.register('test') {
dependsOn(test_mbeddr)
}

task package_mbeddr(type: Zip, dependsOn: pubDeb) {
tasks.named('check') {
dependsOn 'test'
}

task package_mbeddr(type: Zip, dependsOn: build_mbeddr) {
archiveFileName = 'com.mbeddr.zip'
from artifactsDir
include "mbeddr/**"
}

artifacts {
'default'(package_mbeddr)
}

publishing {
publications {
mbeddr(MavenPublication) {
Expand Down Expand Up @@ -220,5 +231,3 @@ if({project.mbeddrBuild}() == "master") {
*/
tasks.findByName("publishMbeddrPublicationToMavenRepository").dependsOn("publishMbeddrPublicationToGitHubPackagesRepository")
}

check.dependsOn test_mbeddr
19 changes: 18 additions & 1 deletion build/com.mbeddr/platform/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
id 'base'
}

import de.itemis.mps.gradle.*

def script_test_mbeddrPlatform = new File(scriptsBasePath + "/com.mbeddr.platform/" + "build-ts-tests.xml")
Expand Down Expand Up @@ -93,16 +97,29 @@ 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')
}

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/**"
}

artifacts {
'default'(package_mbeddrPlatform)
}


task defaultWrapper(dependsOn: build_platform) {
doFirst {
println "####################################################################################"
Expand Down

0 comments on commit 33492bd

Please sign in to comment.