Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Tooling API to start new build #811

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package pl.allegro.tech.build.axion.release


import org.gradle.api.Task
import org.gradle.api.tasks.TaskAction
import org.gradle.tooling.GradleConnector
import pl.allegro.tech.build.axion.release.domain.Releaser
import pl.allegro.tech.build.axion.release.domain.scm.ScmPushResult
import pl.allegro.tech.build.axion.release.domain.scm.ScmPushResultOutcome
Expand All @@ -10,6 +13,8 @@ import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardOpenOption

import static java.util.stream.Collectors.toList

abstract class ReleaseTask extends BaseAxionTask {

@TaskAction
Expand Down Expand Up @@ -40,6 +45,32 @@ abstract class ReleaseTask extends BaseAxionTask {
StandardOpenOption.APPEND
)
}
def projectConnection = GradleConnector
.newConnector()
.forProjectDirectory(layout.projectDirectory.asFile)
.connect()

def tasksExceptCurrentOne = project.gradle.taskGraph.allTasks - this

tasksExceptCurrentOne.forEach { task ->
if (!task.state.executed) {
task.actions.clear()
}
}

def taskNames = tasksExceptCurrentOne
.stream()
.map(Task::getName)
.collect(toList())

def buildLauncher = projectConnection
.newBuild()
.forTasks(*taskNames)
.addArguments('-Prelease.localOnly', '-Prelease.disableChecks')
.setStandardInput(System.in)
.setStandardOutput(System.out)
.setStandardError(System.err)
buildLauncher.run()
}
}
}
Loading