Skip to content

Commit

Permalink
Merge remote-tracking branch 'uber/master'
Browse files Browse the repository at this point in the history
* uber/master:
  Publish v0.22.4
  Add logic to buckw to update buck and build it if needed (uber#469)
  Use relative path for merged proguard file
  Publish v0.22.3
  Better error message
  Allow transform config to accept project dependencies (uber#466)
  Remove unused parameters and clean up some code. (uber#439)
  Publish v0.22.2
  Do not generate default project ignores
  • Loading branch information
Chris Woodward committed Jul 11, 2017
2 parents 353d247 + 7e7d37a commit 92010e0
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .buckversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bd7dec472d385279ea961789eaf72bc655ca9213
f685044b764341d952491529c167403e3c3adba6
2 changes: 1 addition & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.uber:okbuck:0.22.1'
classpath 'com.uber:okbuck:0.22.4'
}
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.uber:okbuck:0.22.1'
classpath 'com.uber:okbuck:0.22.4'
}
}
Expand Down
22 changes: 21 additions & 1 deletion buckw
Original file line number Diff line number Diff line change
Expand Up @@ -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
##
#########################################################################

Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ task sourcesJar(type: Jar) {
classifier = 'sources'
}

def publishVersion = '0.22.1'
def publishVersion = '0.22.4'
group = 'com.uber'
version = publishVersion
def siteUrl = 'https://github.com/uber/okbuck'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public final class DotBuckConfigLocalFile extends BuckConfigFile {
private final Map<String, String> aliases;
private final String buildToolVersion;
private final String target;
private final List<String> ignore;
private final String groovyHome;
private final String kotlinHome;
private final String proguardJar;
Expand All @@ -22,15 +21,13 @@ public DotBuckConfigLocalFile(
Map<String, String> aliases,
String buildToolVersion,
String target,
List<String> ignore,
String groovyHome,
String kotlinHome,
String proguardJar,
Set<String> defs) {
this.aliases = aliases;
this.buildToolVersion = buildToolVersion;
this.target = target;
this.ignore = ignore;
this.groovyHome = groovyHome;
this.kotlinHome = kotlinHome;
this.proguardJar = proguardJar;
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<BuckRule> rules = createRules(project, test.espresso)
List<BuckRule> 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<BuckRule> createRules(Project project, boolean espresso) {
private static List<BuckRule> createRules(Project project) {
List<BuckRule> rules = []
ProjectType projectType = ProjectUtil.getType(project)
ProjectUtil.getTargets(project).each { String name, Target target ->
Expand Down Expand Up @@ -94,7 +91,8 @@ final class BuckFileGenerator {
}
break
default:
break
throw new IllegalArgumentException("Okbuck does not support ${project} type projects yet. Please " +
"use the extension option okbuck.buckProjects to exclude ${project}.")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ final class DotBuckConfigLocalGenerator {
return new DotBuckConfigLocalFile(aliases,
okbuck.buildToolVersion,
okbuck.target,
[".git", "**/.svn"],
groovyHome,
kotlinHome,
proguardJar,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -22,14 +29,32 @@ public final class TransformUtil {
private TransformUtil() { }

public static void fetchTransformDeps(Project project) {
Set<Configuration> 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<String> 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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 92010e0

Please sign in to comment.