From 840d4e91bb9a36119c4379380aa7e0d4ea3f419b Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Wed, 25 May 2022 21:12:40 +0530 Subject: [PATCH 01/10] Extends the plugin to check for breaking changes with docker image --- .../ballerina/plugin/BallerinaPlugin.groovy | 143 ++++++++++-------- 1 file changed, 76 insertions(+), 67 deletions(-) diff --git a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy index 82dbb79..869dbe8 100644 --- a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy +++ b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy @@ -41,23 +41,7 @@ class BallerinaPlugin implements Plugin { @Override void apply(Project project) { project.extensions.create('ballerina', BallerinaExtension) - - project.configurations { - jbalTools - } - - project.dependencies { - if (project.extensions.ballerina.langVersion == null) { - jbalTools("org.ballerinalang:jballerina-tools:${project.ballerinaLangVersion}") { - transitive = false - } - } else { - jbalTools("org.ballerinalang:jballerina-tools:${project.extensions.ballerina.langVersion}") { - transitive = false - } - } - } - + def packageOrg = '' def platform = 'java11' def tomlVersion @@ -75,6 +59,7 @@ class BallerinaPlugin implements Plugin { def needPublishToCentral = false def needPublishToLocalCentral = false def skipTests = true + def checkForBreakingChanges = (System.getenv('CHECK_BRAEKING_CHANGES') == "true") if (project.version.matches(project.ext.timestampedVersionRegex)) { def splitVersion = project.version.split('-') @@ -93,68 +78,86 @@ class BallerinaPlugin implements Plugin { from project.configurations.externalJars } - project.tasks.register('unpackJballerinaTools') { - project.configurations.each { configuration -> - if (configuration.name == "externalJars") { - dependsOn(project.copyToLib) + if (!checkForBreakingChanges) { + project.configurations { + jbalTools + } + + project.dependencies { + if (project.extensions.ballerina.langVersion == null) { + jbalTools("org.ballerinalang:jballerina-tools:${project.ballerinaLangVersion}") { + transitive = false + } + } else { + jbalTools("org.ballerinalang:jballerina-tools:${project.extensions.ballerina.langVersion}") { + transitive = false + } } } - doLast { - project.configurations.jbalTools.resolvedConfiguration.resolvedArtifacts.each { artifact -> - project.copy { - from project.zipTree(artifact.getFile()) - into new File("${project.buildDir}/") + + project.tasks.register('unpackJballerinaTools') { + project.configurations.each { configuration -> + if (configuration.name == "externalJars") { + dependsOn(project.copyToLib) } + } + doLast { + project.configurations.jbalTools.resolvedConfiguration.resolvedArtifacts.each { artifact -> + project.copy { + from project.zipTree(artifact.getFile()) + into new File("${project.buildDir}/") + } - project.copy { - from(project.zipTree(artifact.getFile())) { - eachFile { fcd -> - fcd.relativePath = new RelativePath(!fcd.file.isDirectory(), fcd.relativePath.segments.drop(1)) + project.copy { + from(project.zipTree(artifact.getFile())) { + eachFile { fcd -> + fcd.relativePath = new RelativePath(!fcd.file.isDirectory(), fcd.relativePath.segments.drop(1)) + } + includeEmptyDirs = false } - includeEmptyDirs = false + into "${project.rootDir}/target/ballerina-runtime" } - into "${project.rootDir}/target/ballerina-runtime" } } } - } - project.tasks.register('unpackStdLibs') { - dependsOn(project.unpackJballerinaTools) - doLast { - project.configurations.ballerinaStdLibs.resolvedConfiguration.resolvedArtifacts.each { artifact -> - project.copy { - from project.zipTree(artifact.getFile()) - into new File("${project.buildDir}/extracted-stdlibs", artifact.name + '-zip') + project.tasks.register('unpackStdLibs') { + dependsOn(project.unpackJballerinaTools) + doLast { + project.configurations.ballerinaStdLibs.resolvedConfiguration.resolvedArtifacts.each { artifact -> + project.copy { + from project.zipTree(artifact.getFile()) + into new File("${project.buildDir}/extracted-stdlibs", artifact.name + '-zip') + } } } } - } - project.tasks.register('copyStdlibs') { - dependsOn(project.unpackStdLibs) - doLast { - /* Standard Libraries */ - project.configurations.ballerinaStdLibs.resolvedConfiguration.resolvedArtifacts.each { artifact -> - def artifactExtractedPath = "${project.buildDir}/extracted-stdlibs/" + artifact.name + '-zip' - project.copy { - def ballerinaDist = "build/jballerina-tools-${project.ballerinaLangVersion}" - into ballerinaDist - into('repo/bala') { - from "${artifactExtractedPath}/bala" - } - into('repo/cache') { - from "${artifactExtractedPath}/cache" - } - } - project.copy { - def runtimePath = "${project.rootDir}/target/ballerina-runtime" - into runtimePath - into('repo/bala') { - from "${artifactExtractedPath}/bala" + project.tasks.register('copyStdlibs') { + dependsOn(project.unpackStdLibs) + doLast { + /* Standard Libraries */ + project.configurations.ballerinaStdLibs.resolvedConfiguration.resolvedArtifacts.each { artifact -> + def artifactExtractedPath = "${project.buildDir}/extracted-stdlibs/" + artifact.name + '-zip' + project.copy { + def ballerinaDist = "build/jballerina-tools-${project.ballerinaLangVersion}" + into ballerinaDist + into('repo/bala') { + from "${artifactExtractedPath}/bala" + } + into('repo/cache') { + from "${artifactExtractedPath}/cache" + } } - into('repo/cache') { - from "${artifactExtractedPath}/cache" + project.copy { + def runtimePath = "${project.rootDir}/target/ballerina-runtime" + into runtimePath + into('repo/bala') { + from "${artifactExtractedPath}/bala" + } + into('repo/cache') { + from "${artifactExtractedPath}/cache" + } } } } @@ -240,7 +243,9 @@ class BallerinaPlugin implements Plugin { project.exec { workingDir project.projectDir environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true' - if (Os.isFamily(Os.FAMILY_WINDOWS)) { + if (checkForBreakingChanges) { + commandLine 'sh', '-c', "docker run --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal pack --target-dir ${balBuildTarget} --offline ${debugParams}" + } else if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'cmd', '/c', "$balJavaDebugParam $distributionBinPath/bal.bat pack --target-dir ${balBuildTarget} --offline ${debugParams} && exit %%ERRORLEVEL%%" } else { commandLine 'sh', '-c', "$balJavaDebugParam $distributionBinPath/bal pack --target-dir ${balBuildTarget} --offline ${debugParams}" @@ -251,7 +256,9 @@ class BallerinaPlugin implements Plugin { project.exec { workingDir project.projectDir environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true' - if (Os.isFamily(Os.FAMILY_WINDOWS)) { + if (checkForBreakingChanges) { + commandLine 'sh', '-c', "docker run --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" + } else if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'cmd', '/c', "$balJavaDebugParam $distributionBinPath/bal.bat test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams} && exit %%ERRORLEVEL%%" } else { commandLine 'sh', '-c', "$balJavaDebugParam $distributionBinPath/bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" @@ -322,7 +329,9 @@ class BallerinaPlugin implements Plugin { project.exec { workingDir project.projectDir environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true' - if (Os.isFamily(Os.FAMILY_WINDOWS)) { + if (checkForBreakingChanges) { + commandLine 'sh', '-c', "docker run --net=host --user \$(id -u):\$(id -g) -v ${project.projectDir}/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" + } else if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'cmd', '/c', "${balJavaDebugParam} ${distributionBinPath}/bal.bat test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams} && exit %%ERRORLEVEL%%" } else { commandLine 'sh', '-c', "${balJavaDebugParam} ${distributionBinPath}/bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" From 9100ddb7980eb6461f08aa400db0bbe151975b60 Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Thu, 26 May 2022 20:59:41 +0530 Subject: [PATCH 02/10] Add --rm flag to docker continers to remove container on task completion --- src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy index 869dbe8..4ad7c90 100644 --- a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy +++ b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy @@ -244,7 +244,7 @@ class BallerinaPlugin implements Plugin { workingDir project.projectDir environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true' if (checkForBreakingChanges) { - commandLine 'sh', '-c', "docker run --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal pack --target-dir ${balBuildTarget} --offline ${debugParams}" + commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal pack --target-dir ${balBuildTarget} --offline ${debugParams}" } else if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'cmd', '/c', "$balJavaDebugParam $distributionBinPath/bal.bat pack --target-dir ${balBuildTarget} --offline ${debugParams} && exit %%ERRORLEVEL%%" } else { @@ -257,7 +257,7 @@ class BallerinaPlugin implements Plugin { workingDir project.projectDir environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true' if (checkForBreakingChanges) { - commandLine 'sh', '-c', "docker run --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" + commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" } else if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'cmd', '/c', "$balJavaDebugParam $distributionBinPath/bal.bat test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams} && exit %%ERRORLEVEL%%" } else { @@ -330,7 +330,7 @@ class BallerinaPlugin implements Plugin { workingDir project.projectDir environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true' if (checkForBreakingChanges) { - commandLine 'sh', '-c', "docker run --net=host --user \$(id -u):\$(id -g) -v ${project.projectDir}/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" + commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v ${project.projectDir}/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" } else if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'cmd', '/c', "${balJavaDebugParam} ${distributionBinPath}/bal.bat test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams} && exit %%ERRORLEVEL%%" } else { From c5fb3f50238d4589433a918a71ad7c5e817b55c8 Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Mon, 20 Jun 2022 11:06:37 +0530 Subject: [PATCH 03/10] Display warning message when using docker to build the moudle --- .../ballerina/plugin/BallerinaPlugin.groovy | 49 ++++++++++++------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy index 4ad7c90..cd6cbc3 100644 --- a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy +++ b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy @@ -59,7 +59,7 @@ class BallerinaPlugin implements Plugin { def needPublishToCentral = false def needPublishToLocalCentral = false def skipTests = true - def checkForBreakingChanges = (System.getenv('CHECK_BRAEKING_CHANGES') == "true") + def checkForBreakingChanges = (System.getenv('BUILD_USING_DOCKER') == "true") if (project.version.matches(project.ext.timestampedVersionRegex)) { def splitVersion = project.version.split('-') @@ -73,17 +73,19 @@ class BallerinaPlugin implements Plugin { tomlVersion = project.version.replace("${project.ext.snapshotVersion}", '') } + project.configurations { + jbalTools + } + project.tasks.register('copyToLib', Copy.class) { into "$project.projectDir/lib" from project.configurations.externalJars } - if (!checkForBreakingChanges) { - project.configurations { - jbalTools - } - - project.dependencies { + project.dependencies { + if (checkForBreakingChanges) { + println("WARNING! jbalTools dependency skiped; project uses docker to build the module") + } else { if (project.extensions.ballerina.langVersion == null) { jbalTools("org.ballerinalang:jballerina-tools:${project.ballerinaLangVersion}") { transitive = false @@ -94,13 +96,18 @@ class BallerinaPlugin implements Plugin { } } } + } - project.tasks.register('unpackJballerinaTools') { - project.configurations.each { configuration -> - if (configuration.name == "externalJars") { - dependsOn(project.copyToLib) - } + project.tasks.register('unpackJballerinaTools') { + project.configurations.each { configuration -> + if (configuration.name == "externalJars") { + dependsOn(project.copyToLib) } + } + + if (checkForBreakingChanges) { + println("WARNING! task unpackJballerinaTools skiped; project uses docker to build the module") + } else { doLast { project.configurations.jbalTools.resolvedConfiguration.resolvedArtifacts.each { artifact -> project.copy { @@ -120,9 +127,13 @@ class BallerinaPlugin implements Plugin { } } } + } - project.tasks.register('unpackStdLibs') { - dependsOn(project.unpackJballerinaTools) + project.tasks.register('unpackStdLibs') { + dependsOn(project.unpackJballerinaTools) + if (checkForBreakingChanges) { + println("WARNING! task unpackStdLibs skiped; project uses docker to build the module") + } else { doLast { project.configurations.ballerinaStdLibs.resolvedConfiguration.resolvedArtifacts.each { artifact -> project.copy { @@ -132,9 +143,13 @@ class BallerinaPlugin implements Plugin { } } } + } - project.tasks.register('copyStdlibs') { - dependsOn(project.unpackStdLibs) + project.tasks.register('copyStdlibs') { + dependsOn(project.unpackStdLibs) + if (checkForBreakingChanges) { + println("WARNING! task copyStdlibs skiped; project uses docker to build the module") + } else { doLast { /* Standard Libraries */ project.configurations.ballerinaStdLibs.resolvedConfiguration.resolvedArtifacts.each { artifact -> @@ -163,7 +178,7 @@ class BallerinaPlugin implements Plugin { } } } - + project.tasks.register('initializeVariables') { String packageName = project.extensions.ballerina.module String organisation From 67c214d5f841360f62c07b8f9012919b349846b5 Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Mon, 20 Jun 2022 13:36:02 +0530 Subject: [PATCH 04/10] Use buildUsingDocker gradle property instead of BUILD_USING_DOCKER env variable --- src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy index cd6cbc3..aad2977 100644 --- a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy +++ b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy @@ -59,7 +59,7 @@ class BallerinaPlugin implements Plugin { def needPublishToCentral = false def needPublishToLocalCentral = false def skipTests = true - def checkForBreakingChanges = (System.getenv('BUILD_USING_DOCKER') == "true") + def checkForBreakingChanges = project.hasProperty('buildUsingDocker') && project.findProperty('buildUsingDocker') == 'true' if (project.version.matches(project.ext.timestampedVersionRegex)) { def splitVersion = project.version.split('-') From 3ed102f8d210acd8d413b8a4e60446c02e28afee Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Mon, 20 Jun 2022 14:20:35 +0530 Subject: [PATCH 05/10] Skip building module with docker in windows and display a warning --- .../io/ballerina/plugin/BallerinaPlugin.groovy | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy index aad2977..7fb90fd 100644 --- a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy +++ b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy @@ -259,7 +259,11 @@ class BallerinaPlugin implements Plugin { workingDir project.projectDir environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true' if (checkForBreakingChanges) { - commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal pack --target-dir ${balBuildTarget} --offline ${debugParams}" + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + println("WARNING! task build skiped; project uses docker and building ballerina module using docker only allowed in linux/mac OS") + } else { + commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal pack --target-dir ${balBuildTarget} --offline ${debugParams}" + } } else if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'cmd', '/c', "$balJavaDebugParam $distributionBinPath/bal.bat pack --target-dir ${balBuildTarget} --offline ${debugParams} && exit %%ERRORLEVEL%%" } else { @@ -272,7 +276,11 @@ class BallerinaPlugin implements Plugin { workingDir project.projectDir environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true' if (checkForBreakingChanges) { - commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + println("WARNING! task build skiped; project uses docker and building ballerina module using docker only allowed in linux/mac OS") + } else { + commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" + } } else if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'cmd', '/c', "$balJavaDebugParam $distributionBinPath/bal.bat test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams} && exit %%ERRORLEVEL%%" } else { @@ -345,7 +353,11 @@ class BallerinaPlugin implements Plugin { workingDir project.projectDir environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true' if (checkForBreakingChanges) { - commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v ${project.projectDir}/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + println("WARNING! task test skiped; project uses docker and running ballerina test using docker only allowed in linux/mac OS") + } else { + commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v ${project.projectDir}/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" + } } else if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'cmd', '/c', "${balJavaDebugParam} ${distributionBinPath}/bal.bat test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams} && exit %%ERRORLEVEL%%" } else { From 0eb21aac4cca8f23a67a1010c9dacc11e249bab3 Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Mon, 20 Jun 2022 14:21:17 +0530 Subject: [PATCH 06/10] Bump the version to 0.15.0 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 9e5cdb8..6475921 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ group=io.ballerina -version=0.14.3-SNAPSHOT +version=0.15.0 From 5ea5046fb0f14f9b2c73a1ece27c731ee331c3ab Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Mon, 20 Jun 2022 15:20:10 +0530 Subject: [PATCH 07/10] Allow building module with docker in windows --- .../groovy/io/ballerina/plugin/BallerinaPlugin.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy index 7fb90fd..cb2edc5 100644 --- a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy +++ b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy @@ -260,7 +260,7 @@ class BallerinaPlugin implements Plugin { environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true' if (checkForBreakingChanges) { if (Os.isFamily(Os.FAMILY_WINDOWS)) { - println("WARNING! task build skiped; project uses docker and building ballerina module using docker only allowed in linux/mac OS") + commandLine 'cmd', '/c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal pack --target-dir ${balBuildTarget} --offline ${debugParams}" } else { commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal pack --target-dir ${balBuildTarget} --offline ${debugParams}" } @@ -277,7 +277,7 @@ class BallerinaPlugin implements Plugin { environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true' if (checkForBreakingChanges) { if (Os.isFamily(Os.FAMILY_WINDOWS)) { - println("WARNING! task build skiped; project uses docker and building ballerina module using docker only allowed in linux/mac OS") + commandLine 'cmd', '/c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" } else { commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" } @@ -354,9 +354,9 @@ class BallerinaPlugin implements Plugin { environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true' if (checkForBreakingChanges) { if (Os.isFamily(Os.FAMILY_WINDOWS)) { - println("WARNING! task test skiped; project uses docker and running ballerina test using docker only allowed in linux/mac OS") + commandLine 'cmd', '/c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v ${project.projectDir}/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" } else { - commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v ${project.projectDir}/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" + commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v ${project.projectDir}/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" } } else if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'cmd', '/c', "${balJavaDebugParam} ${distributionBinPath}/bal.bat test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams} && exit %%ERRORLEVEL%%" From 7291681f985f31b860c157921e9dddf5ede0032c Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Mon, 20 Jun 2022 15:23:24 +0530 Subject: [PATCH 08/10] Update version to 0.15.0-SNAPSHOT --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 6475921..0835fb7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ group=io.ballerina -version=0.15.0 +version=0.15.0-SNAPSHOT From 6477aa6e2a9626b0c6c0c97c14862c0f37352ca0 Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Mon, 20 Jun 2022 16:04:54 +0530 Subject: [PATCH 09/10] Allow plugin to use specified docker image from gradle property --- .../io/ballerina/plugin/BallerinaPlugin.groovy | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy index cb2edc5..928740a 100644 --- a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy +++ b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy @@ -59,7 +59,8 @@ class BallerinaPlugin implements Plugin { def needPublishToCentral = false def needPublishToLocalCentral = false def skipTests = true - def checkForBreakingChanges = project.hasProperty('buildUsingDocker') && project.findProperty('buildUsingDocker') == 'true' + def checkForBreakingChanges = project.hasProperty('buildUsingDocker') + def ballerinaDockerTag = project.findProperty('buildUsingDocker') if (project.version.matches(project.ext.timestampedVersionRegex)) { def splitVersion = project.version.split('-') @@ -260,9 +261,9 @@ class BallerinaPlugin implements Plugin { environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true' if (checkForBreakingChanges) { if (Os.isFamily(Os.FAMILY_WINDOWS)) { - commandLine 'cmd', '/c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal pack --target-dir ${balBuildTarget} --offline ${debugParams}" + commandLine 'cmd', '/c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:$ballerinaDockerTag $balJavaDebugParam bal pack --target-dir ${balBuildTarget} --offline ${debugParams}" } else { - commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal pack --target-dir ${balBuildTarget} --offline ${debugParams}" + commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:$ballerinaDockerTag $balJavaDebugParam bal pack --target-dir ${balBuildTarget} --offline ${debugParams}" } } else if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'cmd', '/c', "$balJavaDebugParam $distributionBinPath/bal.bat pack --target-dir ${balBuildTarget} --offline ${debugParams} && exit %%ERRORLEVEL%%" @@ -277,9 +278,9 @@ class BallerinaPlugin implements Plugin { environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true' if (checkForBreakingChanges) { if (Os.isFamily(Os.FAMILY_WINDOWS)) { - commandLine 'cmd', '/c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" + commandLine 'cmd', '/c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:$ballerinaDockerTag $balJavaDebugParam bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" } else { - commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly $balJavaDebugParam bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" + commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v $project.projectDir/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:$ballerinaDockerTag $balJavaDebugParam bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" } } else if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'cmd', '/c', "$balJavaDebugParam $distributionBinPath/bal.bat test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams} && exit %%ERRORLEVEL%%" @@ -354,9 +355,9 @@ class BallerinaPlugin implements Plugin { environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true' if (checkForBreakingChanges) { if (Os.isFamily(Os.FAMILY_WINDOWS)) { - commandLine 'cmd', '/c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v ${project.projectDir}/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" + commandLine 'cmd', '/c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v ${project.projectDir}/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:$ballerinaDockerTag bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" } else { - commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v ${project.projectDir}/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:nightly bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" + commandLine 'sh', '-c', "docker run --rm --net=host --user \$(id -u):\$(id -g) -v ${project.projectDir}/..:/home -v $project.projectDir:/home/ballerina ballerina/ballerina:$ballerinaDockerTag bal test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams}" } } else if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'cmd', '/c', "${balJavaDebugParam} ${distributionBinPath}/bal.bat test --offline ${testCoverageParams} ${groupParams} ${disableGroups} ${debugParams} && exit %%ERRORLEVEL%%" From f10fcb553069a82ef0f0faab2b1c8a1a636b74c5 Mon Sep 17 00:00:00 2001 From: MohamedSabthar Date: Mon, 20 Jun 2022 17:15:03 +0530 Subject: [PATCH 10/10] Update src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy Co-authored-by: Niveathika --- src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy index 928740a..b2fd32e 100644 --- a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy +++ b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy @@ -61,6 +61,10 @@ class BallerinaPlugin implements Plugin { def skipTests = true def checkForBreakingChanges = project.hasProperty('buildUsingDocker') def ballerinaDockerTag = project.findProperty('buildUsingDocker') + if (ballerinaDockerTag == '') { + ballerinaDockerTag = 'nightly' + } + if (project.version.matches(project.ext.timestampedVersionRegex)) { def splitVersion = project.version.split('-')