From 2daa553db25139a69fdd1f4119207c0f519a861c Mon Sep 17 00:00:00 2001 From: Gautam Korlam Date: Tue, 27 Jun 2017 17:50:44 -0700 Subject: [PATCH 1/9] Do not generate default project ignores Fixes: https://github.com/facebook/buck/issues/1402 Let the user configure the ignores instead in .buckconfig --- .../com/uber/okbuck/config/DotBuckConfigLocalFile.java | 7 ------- .../okbuck/generator/DotBuckConfigLocalGenerator.groovy | 1 - 2 files changed, 8 deletions(-) diff --git a/buildSrc/src/main/groovy/com/uber/okbuck/config/DotBuckConfigLocalFile.java b/buildSrc/src/main/groovy/com/uber/okbuck/config/DotBuckConfigLocalFile.java index cabb97a50..b5dc491ce 100644 --- a/buildSrc/src/main/groovy/com/uber/okbuck/config/DotBuckConfigLocalFile.java +++ b/buildSrc/src/main/groovy/com/uber/okbuck/config/DotBuckConfigLocalFile.java @@ -12,7 +12,6 @@ public final class DotBuckConfigLocalFile extends BuckConfigFile { private final Map aliases; private final String buildToolVersion; private final String target; - private final List ignore; private final String groovyHome; private final String kotlinHome; private final String proguardJar; @@ -22,7 +21,6 @@ public DotBuckConfigLocalFile( Map aliases, String buildToolVersion, String target, - List ignore, String groovyHome, String kotlinHome, String proguardJar, @@ -30,7 +28,6 @@ public DotBuckConfigLocalFile( this.aliases = aliases; this.buildToolVersion = buildToolVersion; this.target = target; - this.ignore = ignore; this.groovyHome = groovyHome; this.kotlinHome = kotlinHome; this.proguardJar = proguardJar; @@ -48,10 +45,6 @@ public final void print(PrintStream printer) { printer.println("\ttarget = " + target); printer.println(); - printer.println("[project]"); - printer.println("\tignore = " + String.join(", ", ignore)); - printer.println(); - if (!defs.isEmpty()) { printer.println("[buildfile]"); printer.println("\tincludes = " + String.join(" ", defs)); diff --git a/buildSrc/src/main/groovy/com/uber/okbuck/generator/DotBuckConfigLocalGenerator.groovy b/buildSrc/src/main/groovy/com/uber/okbuck/generator/DotBuckConfigLocalGenerator.groovy index 2eeae7c4f..37b8cb0ab 100644 --- a/buildSrc/src/main/groovy/com/uber/okbuck/generator/DotBuckConfigLocalGenerator.groovy +++ b/buildSrc/src/main/groovy/com/uber/okbuck/generator/DotBuckConfigLocalGenerator.groovy @@ -34,7 +34,6 @@ final class DotBuckConfigLocalGenerator { return new DotBuckConfigLocalFile(aliases, okbuck.buildToolVersion, okbuck.target, - [".git", "**/.svn"], groovyHome, kotlinHome, proguardJar, From 8618cdbd6533d93f9855d606e487c43ff7652266 Mon Sep 17 00:00:00 2001 From: Gautam Korlam Date: Tue, 27 Jun 2017 17:52:33 -0700 Subject: [PATCH 2/9] Publish v0.22.2 --- README-zh.md | 2 +- README.md | 2 +- buildSrc/build.gradle | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README-zh.md b/README-zh.md index 966434ecd..661bf82b8 100644 --- a/README-zh.md +++ b/README-zh.md @@ -9,7 +9,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.uber:okbuck:0.22.1' + classpath 'com.uber:okbuck:0.22.2' } } diff --git a/README.md b/README.md index 0a60e0198..afbe367c1 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.uber:okbuck:0.22.1' + classpath 'com.uber:okbuck:0.22.2' } } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index cf1de34b1..e7fe38d31 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -47,7 +47,7 @@ task sourcesJar(type: Jar) { classifier = 'sources' } -def publishVersion = '0.22.1' +def publishVersion = '0.22.2' group = 'com.uber' version = publishVersion def siteUrl = 'https://github.com/uber/okbuck' From 44589232e04bfdf2a37da1678feb2354f1d3f562 Mon Sep 17 00:00:00 2001 From: Nelson Osacky Date: Thu, 29 Jun 2017 15:53:54 -0700 Subject: [PATCH 3/9] Remove unused parameters and clean up some code. (#439) --- .../okbuck/generator/BuckFileGenerator.groovy | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/buildSrc/src/main/groovy/com/uber/okbuck/generator/BuckFileGenerator.groovy b/buildSrc/src/main/groovy/com/uber/okbuck/generator/BuckFileGenerator.groovy index 47b62b47f..1383b953b 100644 --- a/buildSrc/src/main/groovy/com/uber/okbuck/generator/BuckFileGenerator.groovy +++ b/buildSrc/src/main/groovy/com/uber/okbuck/generator/BuckFileGenerator.groovy @@ -52,20 +52,17 @@ final class BuckFileGenerator { * generate {@code BUCKFile} */ static void generate(Project project) { - OkBuckExtension okbuck = project.rootProject.okbuck - - TestExtension test = okbuck.test - List rules = createRules(project, test.espresso) + List rules = createRules(project) if (rules) { BUCKFile buckFile = new BUCKFile(rules) - PrintStream buckPrinter = new PrintStream(project.file(OkBuckGradlePlugin.BUCK)) - buckFile.print(buckPrinter) - IOUtils.closeQuietly(buckPrinter) + new PrintStream(project.file(OkBuckGradlePlugin.BUCK)).withStream { stream -> + buckFile.print(stream) + } } } - private static List createRules(Project project, boolean espresso) { + private static List createRules(Project project) { List rules = [] ProjectType projectType = ProjectUtil.getType(project) ProjectUtil.getTargets(project).each { String name, Target target -> @@ -94,7 +91,7 @@ final class BuckFileGenerator { } break default: - break + throw new IllegalArgumentException("ProjectType not handled: $projectType") } } From c91223b152c518ac64ff11c5534947bfdc4c8b71 Mon Sep 17 00:00:00 2001 From: Gautam Korlam Date: Thu, 29 Jun 2017 15:54:22 -0700 Subject: [PATCH 4/9] Allow transform config to accept project dependencies (#466) --- .../uber/okbuck/core/util/TransformUtil.java | 29 +++++++++++++++++-- .../uber/okbuck/core/util/transform/BUCK_FILE | 2 +- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/java/com/uber/okbuck/core/util/TransformUtil.java b/buildSrc/src/main/java/com/uber/okbuck/core/util/TransformUtil.java index d3eb8857e..a681df21c 100644 --- a/buildSrc/src/main/java/com/uber/okbuck/core/util/TransformUtil.java +++ b/buildSrc/src/main/java/com/uber/okbuck/core/util/TransformUtil.java @@ -1,12 +1,19 @@ package com.uber.okbuck.core.util; +import com.google.common.base.Joiner; +import com.google.common.collect.ImmutableMap; import com.uber.okbuck.OkBuckGradlePlugin; +import com.uber.okbuck.composer.base.BuckRuleComposer; import com.uber.okbuck.core.dependency.DependencyCache; +import com.uber.okbuck.core.model.base.Scope; import org.gradle.api.Project; +import org.gradle.api.artifacts.Configuration; import java.io.File; import java.util.Collections; +import java.util.Set; +import java.util.stream.Collectors; public final class TransformUtil { @@ -22,14 +29,32 @@ public final class TransformUtil { private TransformUtil() { } public static void fetchTransformDeps(Project project) { + Set transformConfigurations = + Collections.singleton(project.getConfigurations().getByName(CONFIGURATION_TRANSFORM)); DependencyCache dependencyCache = new DependencyCache("transform", project.getRootProject(), TRANSFORM_CACHE, - Collections.singleton(project.getConfigurations().getByName(CONFIGURATION_TRANSFORM)), + transformConfigurations, TRANSFORM_FOLDER + TRANSFORM_BUCK_FILE); + Scope transformScope = new Scope( + project, + Collections.singleton(CONFIGURATION_TRANSFORM), + Collections.emptySet(), + null, + Collections.emptyList(), + dependencyCache); + + Set targetDeps = BuckRuleComposer.targets(transformScope.getTargetDeps()) + .stream() + .map(s -> "'" + s + "'") + .collect(Collectors.toSet()); + String allTargetDeps = Joiner.on(", ").join(targetDeps); + FileUtil.copyResourceToProject( - TRANSFORM_FOLDER + TRANSFORM_BUCK_FILE, new File(dependencyCache.getCacheDir(), "BUCK")); + TRANSFORM_FOLDER + TRANSFORM_BUCK_FILE, + new File(dependencyCache.getCacheDir(), "BUCK"), + ImmutableMap.of("template-target-deps", allTargetDeps)); FileUtil.copyResourceToProject( TRANSFORM_FOLDER + TRANSFORM_JAR, new File(dependencyCache.getCacheDir(), TRANSFORM_JAR)); } diff --git a/buildSrc/src/main/resources/com/uber/okbuck/core/util/transform/BUCK_FILE b/buildSrc/src/main/resources/com/uber/okbuck/core/util/transform/BUCK_FILE index ccdb01744..ff1926806 100644 --- a/buildSrc/src/main/resources/com/uber/okbuck/core/util/transform/BUCK_FILE +++ b/buildSrc/src/main/resources/com/uber/okbuck/core/util/transform/BUCK_FILE @@ -22,7 +22,7 @@ for jar in jars: java_binary( name='okbuck_transform', - deps=map(lambda x: ":" + x, jars), + deps=map(lambda x: ":" + x, jars) + [${template-target-deps}], blacklist=[ 'META-INF', ], From f4ff71104abf10e61c375589f3fca7f8a2111147 Mon Sep 17 00:00:00 2001 From: Gautam Korlam Date: Thu, 29 Jun 2017 15:56:49 -0700 Subject: [PATCH 5/9] Better error message --- .../groovy/com/uber/okbuck/generator/BuckFileGenerator.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/groovy/com/uber/okbuck/generator/BuckFileGenerator.groovy b/buildSrc/src/main/groovy/com/uber/okbuck/generator/BuckFileGenerator.groovy index 1383b953b..7d7131d97 100644 --- a/buildSrc/src/main/groovy/com/uber/okbuck/generator/BuckFileGenerator.groovy +++ b/buildSrc/src/main/groovy/com/uber/okbuck/generator/BuckFileGenerator.groovy @@ -91,7 +91,8 @@ final class BuckFileGenerator { } break default: - throw new IllegalArgumentException("ProjectType not handled: $projectType") + throw new IllegalArgumentException("Okbuck does not support ${project} type projects yet. Please " + + "use the extension option okbuck.buckProjects to exclude ${project}.") } } From 65471eff97c0bdcf3a3325d22372746729b53693 Mon Sep 17 00:00:00 2001 From: Gautam Korlam Date: Thu, 29 Jun 2017 15:58:06 -0700 Subject: [PATCH 6/9] Publish v0.22.3 --- README-zh.md | 2 +- README.md | 2 +- buildSrc/build.gradle | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README-zh.md b/README-zh.md index 661bf82b8..5b5693f88 100644 --- a/README-zh.md +++ b/README-zh.md @@ -9,7 +9,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.uber:okbuck:0.22.2' + classpath 'com.uber:okbuck:0.22.3' } } diff --git a/README.md b/README.md index afbe367c1..62fa24f2b 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.uber:okbuck:0.22.2' + classpath 'com.uber:okbuck:0.22.3' } } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index e7fe38d31..1ff9d7414 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -47,7 +47,7 @@ task sourcesJar(type: Jar) { classifier = 'sources' } -def publishVersion = '0.22.2' +def publishVersion = '0.22.3' group = 'com.uber' version = publishVersion def siteUrl = 'https://github.com/uber/okbuck' From bc0e08b6aaec5c5c72f21d59233aa4b598ce6f59 Mon Sep 17 00:00:00 2001 From: Gautam Korlam Date: Wed, 5 Jul 2017 18:18:16 -0700 Subject: [PATCH 7/9] Use relative path for merged proguard file --- .../com/uber/okbuck/core/model/android/AndroidAppTarget.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/groovy/com/uber/okbuck/core/model/android/AndroidAppTarget.groovy b/buildSrc/src/main/groovy/com/uber/okbuck/core/model/android/AndroidAppTarget.groovy index fd4d049a0..667054884 100644 --- a/buildSrc/src/main/groovy/com/uber/okbuck/core/model/android/AndroidAppTarget.groovy +++ b/buildSrc/src/main/groovy/com/uber/okbuck/core/model/android/AndroidAppTarget.groovy @@ -125,7 +125,7 @@ class AndroidAppTarget extends AndroidLibTarget { configs.findAll { File config -> config.exists() }.each { File config -> - mergedConfig += "\n##---- ${config} ----##\n" + mergedConfig += "\n##---- ${FileUtil.getRelativePath(project.rootDir, config)} ----##\n" mergedConfig += config.text } From 469c870e37211533aa1c226a4065121a401ec390 Mon Sep 17 00:00:00 2001 From: Gautam Korlam Date: Mon, 10 Jul 2017 13:44:37 -0400 Subject: [PATCH 8/9] Add logic to buckw to update buck and build it if needed (#469) --- .buckversion | 2 +- buckw | 22 ++++++++++++++++++- .../okbuck/core/util/wrapper/BUCKW_TEMPLATE | 20 +++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/.buckversion b/.buckversion index 154c1b4f5..09e97f554 100644 --- a/.buckversion +++ b/.buckversion @@ -1 +1 @@ -bd7dec472d385279ea961789eaf72bc655ca9213 +f685044b764341d952491529c167403e3c3adba6 diff --git a/buckw b/buckw index d91b51fa2..11c4475ac 100755 --- a/buckw +++ b/buckw @@ -4,7 +4,7 @@ ## ## Buck wrapper script to invoke okbuck when needed, before running buck ## -## Created by OkBuck Gradle Plugin on : Wed Apr 19 21:13:00 PDT 2017 +## Created by OkBuck Gradle Plugin on : Mon Jul 10 10:22:56 PDT 2017 ## ######################################################################### @@ -162,6 +162,26 @@ setupBuckBinary ( ) { cd - fi + # Check for current buck version + BUCK_VERSION=$(cat .buckversion) + if [[ ! -z "$BUCK_VERSION" ]]; then + pushd "$BUCK_HOME" >/dev/null + CURRENT_BUCK_VERSION=$(git rev-parse HEAD) + if [[ "$BUCK_VERSION" != "$CURRENT_BUCK_VERSION" ]]; then + info "BUCK VERSION IS AT $CURRENT_BUCK_VERSION , BUT IT SHOULD BE $BUCK_VERSION. UPDATING BUCK" + git clean -fdx --quiet && git reset --hard --quiet && git fetch --all && git checkout "$BUCK_VERSION" --quiet + fi + popd >/dev/null + fi + + # Build buck if needed + if [[ ! -f "$BUCK_HOME/build/successful-build" ]]; then + echo "Buck does not appear to have been built -- building Buck!" + pushd "$BUCK_HOME" >/dev/null + mkdir -p build && ant > build/ant.log && success "BUCK BUILT SUCCESFULLY" || die "FAILED TO BUILD BUCK" + popd >/dev/null + fi + BUCK_BINARY="$BUCK_HOME/bin/buck" fi } diff --git a/buildSrc/src/main/resources/com/uber/okbuck/core/util/wrapper/BUCKW_TEMPLATE b/buildSrc/src/main/resources/com/uber/okbuck/core/util/wrapper/BUCKW_TEMPLATE index 7e35b67dc..f7750e61f 100644 --- a/buildSrc/src/main/resources/com/uber/okbuck/core/util/wrapper/BUCKW_TEMPLATE +++ b/buildSrc/src/main/resources/com/uber/okbuck/core/util/wrapper/BUCKW_TEMPLATE @@ -153,6 +153,26 @@ setupBuckBinary ( ) { cd - fi + # Check for current buck version + BUCK_VERSION=$(cat .buckversion) + if [[ ! -z "$BUCK_VERSION" ]]; then + pushd "$BUCK_HOME" >/dev/null + CURRENT_BUCK_VERSION=$(git rev-parse HEAD) + if [[ "$BUCK_VERSION" != "$CURRENT_BUCK_VERSION" ]]; then + info "BUCK VERSION IS AT $CURRENT_BUCK_VERSION , BUT IT SHOULD BE $BUCK_VERSION. UPDATING BUCK" + git clean -fdx --quiet && git reset --hard --quiet && git fetch --all && git checkout "$BUCK_VERSION" --quiet + fi + popd >/dev/null + fi + + # Build buck if needed + if [[ ! -f "$BUCK_HOME/build/successful-build" ]]; then + echo "Buck does not appear to have been built -- building Buck!" + pushd "$BUCK_HOME" >/dev/null + mkdir -p build && ant > build/ant.log && success "BUCK BUILT SUCCESFULLY" || die "FAILED TO BUILD BUCK" + popd >/dev/null + fi + BUCK_BINARY="$BUCK_HOME/bin/buck" fi } From 7e7d37aa7aa9adec64a71aa174f4820aacb1e1ac Mon Sep 17 00:00:00 2001 From: Gautam Korlam Date: Mon, 10 Jul 2017 15:26:13 -0700 Subject: [PATCH 9/9] Publish v0.22.4 --- README-zh.md | 2 +- README.md | 2 +- buildSrc/build.gradle | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README-zh.md b/README-zh.md index 5b5693f88..7f01e9478 100644 --- a/README-zh.md +++ b/README-zh.md @@ -9,7 +9,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.uber:okbuck:0.22.3' + classpath 'com.uber:okbuck:0.22.4' } } diff --git a/README.md b/README.md index 62fa24f2b..7c1c8fa81 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.uber:okbuck:0.22.3' + classpath 'com.uber:okbuck:0.22.4' } } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 1ff9d7414..5e84c7c48 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -47,7 +47,7 @@ task sourcesJar(type: Jar) { classifier = 'sources' } -def publishVersion = '0.22.3' +def publishVersion = '0.22.4' group = 'com.uber' version = publishVersion def siteUrl = 'https://github.com/uber/okbuck'