From 5daef47bd12f06946c7e48c4a8b6f5c2ca1cd232 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Thu, 14 Jul 2016 23:45:41 +0700 Subject: [PATCH] Allow to build project outside of the git repository. Added new task buildFixes for fast and simply building project. Example: "gradlew --max-workers=1 clean buildFixes" --- build.gradle | 11 +++-------- rehlds/build.gradle | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index d08279c..dfa6e1e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ import versioning.GitVersioner import versioning.RehldsVersionInfo +import org.joda.time.DateTime apply plugin: 'maven-publish' apply from: 'shared.gradle' @@ -14,14 +15,8 @@ idea { } def gitInfo = GitVersioner.versionForDir(project.rootDir) -if (!gitInfo) { - throw new RuntimeException('Running outside git repository') -} - - - RehldsVersionInfo versionInfo -if (gitInfo.tag && gitInfo.tag[0] == 'v') { +if (gitInfo && gitInfo.tag && gitInfo.tag[0] == 'v') { def m = gitInfo.tag =~ /^v(\d+)\.(\d+)(\.(\d+))?$/ if (!m.find()) { throw new RuntimeException("Invalid git version tag name ${gitInfo.tag}") @@ -38,7 +33,7 @@ if (gitInfo.tag && gitInfo.tag[0] == 'v') { majorVersion: project.majorVersion as int, minorVersion: project.minorVersion as int, suffix: 'SNAPSHOT', - lastCommitDate: gitInfo.lastCommitDate + lastCommitDate: gitInfo ? gitInfo.lastCommitDate : new DateTime() ) } diff --git a/rehlds/build.gradle b/rehlds/build.gradle index 63fed9a..88dec9c 100644 --- a/rehlds/build.gradle +++ b/rehlds/build.gradle @@ -331,6 +331,23 @@ task buildRelease { } } +task buildFixes { + dependsOn binaries.withType(SharedLibraryBinarySpec).matching { + SharedLibraryBinarySpec blib -> blib.buildable && blib.buildType.name == 'release' && blib.flavor.name == 'rehldsFixes' && blib.component.name == 'rehlds_swds_engine' + } +} + +gradle.taskGraph.whenReady { graph -> + if (!graph.hasTask(buildFixes)) { + return; + } + + // skip all tasks with the matched substrings in the name like "test" + def tasks = graph.getAllTasks(); + tasks.findAll { it.name.toLowerCase().contains("test") }.each { task -> + task.enabled = false; + } +} task prepareDevEnvTests { def rehldsTests = new File(project.projectDir, '_dev/testDemos')