Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedSabthar committed Dec 5, 2023
1 parent 9f58e05 commit 5267a47
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,6 @@ class BallerinaPlugin implements Plugin<Project> {
tomlVersion = project.version.replace("${project.ext.snapshotVersion}", '')
}

project.afterEvaluate {
if (ballerinaExtension.isConnector) {
buildOnDocker = true
ballerinaDockerTag = getDockerImageTag(project)
}

if (project.hasProperty('buildUsingDocker')) {
buildOnDocker = true
ballerinaDockerTag = getDockerImageTag(project)
}

if (buildOnDocker) {
println("[Info] project builds on docker: $buildOnDocker")
println("[Info] using the Ballerina docker image tag: $ballerinaDockerTag")
}
}

project.configurations {
jbalTools
}
Expand Down Expand Up @@ -204,6 +187,13 @@ class BallerinaPlugin implements Plugin<Project> {
}

project.tasks.register('initializeVariables') {
if (ballerinaExtension.isConnector || project.hasProperty('buildUsingDocker')) {
buildOnDocker = true
ballerinaDockerTag = getDockerImageTag(project)
println("[Info] project builds on docker")
println("[Info] using the Ballerina docker image tag: $ballerinaDockerTag")
}

String packageName = ballerinaExtension.module
String organization
if (ballerinaExtension.packageOrganization == null) {
Expand Down Expand Up @@ -289,7 +279,6 @@ class BallerinaPlugin implements Plugin<Project> {
workingDir project.projectDir
environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true'
if (buildOnDocker) {
ballerinaDockerTag = getDockerImageTag(project)
createDockerEnvFile("$project.projectDir/docker.env")
def balPackWithDocker = """
docker run --env-file $project.projectDir/docker.env --rm --net=host -u root \
Expand Down Expand Up @@ -318,7 +307,6 @@ class BallerinaPlugin implements Plugin<Project> {
workingDir project.projectDir
environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true'
if (buildOnDocker) {
ballerinaDockerTag = getDockerImageTag(project)
def balTestWithDocker = """
docker run --env-file $project.projectDir/docker.env --rm --net=host -u root \
-v $parentDirectory:/home/ballerina/$parentDirectory.name \
Expand Down Expand Up @@ -362,7 +350,6 @@ class BallerinaPlugin implements Plugin<Project> {
workingDir project.projectDir
environment 'JAVA_OPTS', '-DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true'
if (buildOnDocker) {
ballerinaDockerTag = getDockerImageTag(project)
def balPushWithDocker = """
docker run --env-file $project.projectDir/docker.env --rm --net=host -u root \
-v $parentDirectory:/home/ballerina/$parentDirectory.name \
Expand Down

0 comments on commit 5267a47

Please sign in to comment.