Skip to content

Commit f5a4bf3

Browse files
committed
Bump Android plugin for Gradle to v2.3.0 & modify gen_methodcount_badge work with the latest tools
1 parent 642d8e6 commit f5a4bf3

File tree

8 files changed

+63
-46
lines changed

8 files changed

+63
-46
lines changed

Diff for: build.gradle

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
buildscript {
44
repositories {
55
jcenter()
6+
maven {
7+
url "http://dl.bintray.com/vigidroid/maven"
8+
}
69
}
710
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.2.3'
11+
classpath 'com.android.tools.build:gradle:2.3.0'
12+
classpath 'me.vigi:fat-aar-plugin:0.2.8'
913

1014
// NOTE: Do not place your application dependencies here; they belong
1115
// in the individual module build.gradle files

Diff for: gen_methodscount_badge.sh

+33-26
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#! /usr/bin/env bash
22

3-
4-
rm -rf "./methodscount/build/dependencies"
3+
# assemble library
4+
./gradlew :library:assembleRelease > /dev/null
55

66
# assemble fat-aar and copy dependencies
7-
./gradlew :methodscount:copyDependencies > /dev/null
7+
./gradlew :methodscount:assembleRelease > /dev/null
88

99
BUILD_TOOOLS_VERSION=$(ls $ANDROID_HOME/build-tools/ | sort -n -r | head -n 1)
1010
BUILD_TOOOLS_DIR="$ANDROID_HOME/build-tools/$BUILD_TOOOLS_VERSION"
@@ -19,12 +19,31 @@ function aar-method-counts() {
1919
mkdir -p "$aar_unzip_dest"
2020

2121
unzip "$aar_file" -d "$aar_unzip_dest" > /dev/null
22-
"$BUILD_TOOOLS_DIR/dx"\
23-
--dex --no-optimize \
24-
--output="$aar_unzip_dest/classes.dex" \
25-
"$aar_unzip_dest/classes.jar"
26-
27-
dex-method-counts "$aar_unzip_dest/classes.dex" | grep 'Overall method count:' | sed -E 's/Overall method count: ([0-9]+)/\1/g'
22+
jar-method-counts "$aar_unzip_dest/classes.jar"
23+
}
24+
25+
function aar-deps-method-counts() {
26+
local aar_file=$1
27+
local aar_basename=$(basename $aar_file '.aar')
28+
local aar_unzip_dest="/tmp/aar-deps-method-counts/$aar_basename"
29+
30+
rm -rf "$aar_unzip_dest"
31+
mkdir -p "$aar_unzip_dest"
32+
33+
unzip "$aar_file" -d "$aar_unzip_dest" > /dev/null
34+
35+
DEPS_JARS=$(find "$aar_unzip_dest/libs" -type f -name '*.jar' | grep -v 'library-unspecified.jar')
36+
deps_method_counts=0
37+
38+
IFS=$'\n'
39+
for dep_jar in $(echo "$DEPS_JARS"); do
40+
count=$(jar-method-counts "$dep_jar")
41+
deps_method_counts=$(($deps_method_counts + $count))
42+
# echo "$(basename $dep_jar) $deps_method_counts $count"
43+
done
44+
unset IFS
45+
46+
echo "$deps_method_counts"
2847
}
2948

3049
function jar-method-counts() {
@@ -55,9 +74,8 @@ function file_size() {
5574
) | awk '{print $1}'
5675
}
5776

58-
LIBRARY_AAR="./methodscount/build/dependencies/library-release.aar"
59-
DEPENDENCIES_AARS=$(find ./methodscount/build/dependencies -type f -name '*.aar' | grep -v 'library-release.aar')
60-
DEPENDENCIES_JARS=$(find ./methodscount/build/dependencies -type f -name '*.jar')
77+
LIBRARY_AAR="./library/build/outputs/aar/library-release.aar"
78+
DEPS_LIBRARY_AAR="./methodscount/build/outputs/aar/methodscount-release.aar"
6179

6280
#
6381
# count library's method counts
@@ -67,20 +85,7 @@ lib_method_counts=$(aar-method-counts "$LIBRARY_AAR")
6785
#
6886
# count dependencies' method counts
6987
#
70-
deps_method_counts=0
71-
IFS=$'\n'
72-
for dep_aar in $(echo "$DEPENDENCIES_AARS"); do
73-
count=$(aar-method-counts "$dep_aar")
74-
deps_method_counts=$(($deps_method_counts + $count))
75-
# echo "$(basename $dep_aar) $deps_method_counts $count"
76-
done
77-
78-
for dep_jar in $(echo "$DEPENDENCIES_JARS"); do
79-
count=$(jar-method-counts "$dep_jar")
80-
deps_method_counts=$(($deps_method_counts + $count))
81-
# echo "$(basename $dep_jar) $deps_method_counts $count"
82-
done
83-
unset IFS
88+
deps_method_counts=$(aar-deps-method-counts "$DEPS_LIBRARY_AAR")
8489

8590
#
8691
# library version
@@ -95,6 +100,8 @@ lib_file_size_kb=$(( ($lib_file_size + 999) / 1000 ))
95100

96101
methodscount_site_url="http://www.methodscount.com/?lib=com.h6ah4i.android.widget.advrecyclerview%3Aadvrecyclerview%3A$lib_version"
97102
methodscount_badge_url="https://img.shields.io/badge/Methods and size-core: $lib_method_counts | deps: $deps_method_counts | $lib_file_size_kb KB-e91e63.svg"
103+
methodscount_badge_url=$(echo "$methodscount_badge_url" | sed -E 's/ /%20/g' | sed 's/|/%7C/g')
98104

99105
# echo "<a href=\"$methodscount_site_url\"><img src=\"$methodscount_badge_url\"/></a>"
100106
echo "[![Method Count]($methodscount_badge_url) ]($methodscount_site_url)"
107+

Diff for: gradle.properties

+1
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ org.gradle.jvmargs=-Xmx1536M
1717
# This option should only be used with decoupled projects. More details, visit
1818
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1919
org.gradle.parallel=true
20+
android.enableBuildCache=false

Diff for: gradle/wrapper/gradle-wrapper.jar

1.25 KB
Binary file not shown.

Diff for: gradle/wrapper/gradle-wrapper.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Tue Oct 04 08:03:25 JST 2016
1+
#Sun Mar 12 14:19:50 JST 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip

Diff for: gradlew

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22

33
##############################################################################
44
##
@@ -154,16 +154,19 @@ if $cygwin ; then
154154
esac
155155
fi
156156

157-
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158-
function splitJvmOpts() {
159-
JVM_OPTS=("$@")
157+
# Escape application args
158+
save ( ) {
159+
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160+
echo " "
160161
}
161-
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162-
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
162+
APP_ARGS=$(save "$@")
163+
164+
# Collect all arguments for the java command, following the shell quoting and substitution rules
165+
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
163166

164167
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
165-
if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
168+
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
166169
cd "$(dirname "$0")"
167170
fi
168171

169-
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
172+
exec "$JAVACMD" "$@"

Diff for: methodscount/build.gradle

+5-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
apply plugin: 'com.android.library'
1818

19-
apply from: 'https://raw.githubusercontent.com/adwiv/android-fat-aar/master/fat-aar.gradle'
19+
apply plugin: 'me.vigi.fat-aar'
2020

2121
// Common configurations
2222
apply from: '../common/android-set-common-properties.gradle'
@@ -36,15 +36,12 @@ android {
3636
debug {
3737
}
3838
}
39-
}
4039

41-
task copyDependencies(type: Copy) {
42-
dependsOn build
43-
from configurations.compile
44-
into "${project.projectDir}/build/dependencies"
40+
lintOptions {
41+
abortOnError false
42+
}
4543
}
4644

4745
dependencies {
48-
embedded project(':library')
46+
embed project(':library')
4947
}
50-

Diff for: methodscount/src/main/AndroidManifest.xml

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,10 @@
1414
limitations under the License.
1515
-->
1616
<manifest
17-
package="methodscount">
17+
package="methodscount"
18+
xmlns:tools="http://schemas.android.com/tools">
19+
<!---
20+
NOTE: xmlns:tools is required to workaround the following issue:
21+
https://github.com/Vigi0303/fat-aar-plugin/issues/2
22+
-->
1823
</manifest>

0 commit comments

Comments
 (0)