Skip to content

Commit 7dcb76b

Browse files
authored
Update tools versions and fix project setup (#79)
* Update gradle to 4.10.3 * Update build tools and gradle plugin * Update all libraries used to latest. * Update cloudinary-core (fixes url clone-configuration). * Rename gradle property from `cloudinary.url` to `cloudinaryUrl` * Improve `AndroidManifest.xml` injection of cloudinary-url. * Show dialog in sample app when no cloud is configured
1 parent 3df6cc4 commit 7dcb76b

File tree

20 files changed

+101
-90
lines changed

20 files changed

+101
-90
lines changed

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ android:
1515
components:
1616
- tools
1717
- platform-tools
18-
- build-tools-27.0.3
18+
- build-tools-28.0.3
1919
- android-21
20-
- android-27
20+
- android-28
2121
- extra-google-google_play_services
2222
- extra-google-m2repository
2323
- extra-android-m2repository
2424
- addon-google_apis-google-25
2525
- sys-img-armeabi-v7a-android-21
2626

2727
before_install:
28-
- yes | sdkmanager "platforms;android-27"
28+
- yes | sdkmanager "platforms;android-28"
2929

3030
before_cache:
3131
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock

backend/build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ sourceCompatibility = JavaVersion.VERSION_1_7
1919
targetCompatibility = JavaVersion.VERSION_1_7
2020

2121
dependencies {
22-
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.42'
23-
compile group: 'com.cloudinary', name: 'cloudinary-http44', version: '1.13.0'
24-
compile 'com.google.appengine:appengine-endpoints:1.9.42'
25-
compile 'com.google.appengine:appengine-endpoints-deps:1.9.42'
22+
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.69'
23+
compile group: 'com.cloudinary', name: 'cloudinary-http44', version: '1.19.0'
24+
compile 'com.google.appengine:appengine-endpoints:1.9.69'
25+
compile 'com.google.appengine:appengine-endpoints-deps:1.9.69'
2626
compile 'javax.servlet:servlet-api:2.5'
2727
}
2828

gradle-scripts/common.gradle

+7-14
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ allprojects {
1212
}
1313

1414
dependencies {
15-
classpath 'com.android.tools.build:gradle:3.1.2'
15+
classpath 'com.android.tools.build:gradle:3.2.1'
1616
}
1717
}
1818

@@ -32,18 +32,7 @@ allprojects {
3232
project.ext.set("publishGroupId", group)
3333
}
3434

35-
task wrapper(type: Wrapper) {
36-
gradleVersion = '4.5'
37-
}
38-
39-
ext.filterManifest = {manifestPath, newValue ->
40-
def manifestFile = new File(manifestPath)
41-
def content = manifestFile.getText()
42-
def updatedContent = content.replaceAll("cloudinary_do_not_modify", newValue)
43-
manifestFile.write(updatedContent)
44-
}
45-
46-
ext.loadExtraProperties = {fileName ->
35+
ext.loadExtraProperties = { fileName ->
4736
def props = new Properties()
4837
props.load(new FileInputStream(fileName))
4938

@@ -52,11 +41,15 @@ ext.loadExtraProperties = {fileName ->
5241
}
5342
}
5443

44+
ext.getCloudinaryUrl = { ->
45+
return findProperty("cloudinaryUrl") ?: System.getenv('CLOUDINARY_URL')
46+
}
47+
5548
ext.generateAndLoadLocalGradleProperties = { rootPath ->
5649
// Create default local gradle properties (ignored by git)
5750
def file = new File(rootPath + 'gradle-local.properties')
5851
if (file.createNewFile()) {
59-
file.text = '# Fill in your cloudinary url from cloudinary.com/console. *** IMPORTANT - This should be the url WITHOUT the api secret.\ncloudinary.url=fill_in_your_cloudinary_url'
52+
file.text = '# Uncomment and fill in your cloudinary url from cloudinary.com/console. *** IMPORTANT - This should be the url WITHOUT the api secret.\n# cloudinaryUrl=fill_in_your_cloudinary_url'
6053
}
6154
loadExtraProperties file.absoluteFile
6255
}

gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ developerEmail=info@cloudinary.com
1414
# These two properties must use these exact names to be compatible with 'gradle install' plugin.
1515
group=com.cloudinary
1616
version=1.25.0
17-
cloudinaryLibsVersion=1.19.0
18-
androidSupportVersion=27.1.1
17+
cloudinaryLibsVersion=1.21.0
18+
androidSupportVersion=28.0.0
1919
org.gradle.jvmargs=-Xmx1024m

gradle/wrapper/gradle-wrapper.jar

1.5 KB
Binary file not shown.
+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Thu Jul 20 11:40:28 IDT 2017
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip

gradlew

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ APP_NAME="Gradle"
2828
APP_BASE_NAME=`basename "$0"`
2929

3030
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31-
DEFAULT_JVM_OPTS=""
31+
DEFAULT_JVM_OPTS='"-Xmx64m"'
3232

3333
# Use the maximum available, or set MAX_FD != -1 to use that value.
3434
MAX_FD="maximum"
3535

36-
warn ( ) {
36+
warn () {
3737
echo "$*"
3838
}
3939

40-
die ( ) {
40+
die () {
4141
echo
4242
echo "$*"
4343
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
155155
fi
156156

157157
# Escape application args
158-
save ( ) {
158+
save () {
159159
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160160
echo " "
161161
}

gradlew.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
1414
set APP_HOME=%DIRNAME%
1515

1616
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17-
set DEFAULT_JVM_OPTS=
17+
set DEFAULT_JVM_OPTS="-Xmx64m"
1818

1919
@rem Find java.exe
2020
if defined JAVA_HOME goto findJavaFromJavaHome

lib/build.gradle

+21-17
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,51 @@
11
apply plugin: 'com.android.library'
22

3+
4+
35
android {
4-
compileSdkVersion 27
5-
buildToolsVersion "27.0.3"
6+
compileSdkVersion 28
67

78
defaultConfig {
89
minSdkVersion 14
9-
targetSdkVersion 27
10+
targetSdkVersion 28
1011
versionCode 1
1112
versionName "1.0"
12-
1313
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1414

15+
// filter in the api credentials before building but without changing original source
16+
// files - to make sure the credentials are not checked into source control.
17+
// The url is taken from a property or environment variable:
18+
manifestPlaceholders = [cloudinaryUrl: getCloudinaryUrl() ?: ""]
1519
}
20+
1621
buildTypes {
1722
release {
1823
minifyEnabled false
1924
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2025
consumerProguardFiles 'proguard-rules.pro'
2126
}
2227
}
28+
}
2329

24-
// filter in the api credentials before building but without changing original source files - to make sure the
25-
// credentials are not checked into source control. This is used by the tests only, the credentials
26-
// are taken from the CLOUDINARY_URL environment variable or the cloudinaryUrl property
27-
testVariants.all { variant ->
28-
variant.outputs.each { output ->
29-
output.processManifest.doLast {
30-
def url = System.getenv('CLOUDINARY_URL') ?: project.findProperty("cloudinary.url")
31-
if(!url) {
32-
throw new GradleException("Missing credentials: please set CLOUDINARY_URL environment variable or cloudianryUrl build property.")
33-
}
34-
filterManifest("${buildDir}/intermediates/manifest/${variant.dirName}/AndroidManifest.xml", url)
35-
}
30+
31+
task verifyCloudinaryCredentials {
32+
doFirst {
33+
if (!getCloudinaryUrl()) {
34+
throw new GradleException("Missing credentials: please set CLOUDINARY_URL environment variable or cloudianryUrl property.")
3635
}
3736
}
3837
}
3938

39+
// Force cloudinary credentials when running unit tests and connected device tests
40+
tasks.matching { it.name.startsWith("connected") || it.name.startsWith("test")}.all { task ->
41+
task.dependsOn verifyCloudinaryCredentials
42+
}
43+
4044
dependencies {
4145
api "com.cloudinary:cloudinary-core:${cloudinaryLibsVersion}"
4246

4347
implementation "com.android.support:support-compat:${androidSupportVersion}"
44-
implementation ('com.evernote:android-job:1.2.6', {
48+
implementation('com.evernote:android-job:1.2.6', {
4549
exclude group: 'com.android.support', module: 'support-compat'
4650
})
4751

lib/src/androidTest/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<uses-library android:name="android.test.runner" />
1717
<meta-data
1818
android:name="CLOUDINARY_URL"
19-
android:value="cloudinary_do_not_modify" />
19+
android:value="${cloudinaryUrl}" />
2020
</application>
2121

2222
</manifest>

lib/src/androidTest/java/com/cloudinary/android/UploaderTest.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.cloudinary.Transformation;
1111
import com.cloudinary.utils.ObjectUtils;
1212
import com.cloudinary.utils.Rectangle;
13+
import com.cloudinary.utils.StringUtils;
1314

1415
import junit.framework.Assert;
1516

@@ -48,9 +49,12 @@ public class UploaderTest extends AbstractTest {
4849
public static void setUp() throws Exception {
4950
String url = Utils.cloudinaryUrlFromContext(InstrumentationRegistry.getContext());
5051
cloudinary = new Cloudinary(url);
52+
if (StringUtils.isBlank(url)) {
53+
throw new IllegalArgumentException("UploaderTest - No cloudinary url configured");
54+
}
5155

52-
if (cloudinary.config.apiSecret == null) {
53-
Log.e("UploaderTest", "Please CLOUDINARY_URL in AndroidManifest for Upload test to run");
56+
if (!url.startsWith("cloudinary://")){
57+
throw new IllegalArgumentException("UploaderTest - malformed cloudinary url");
5458
}
5559
}
5660

sample-signed/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This samples demonstrates the mechanism of signed uploads using a Google cloud e
77
Once you clone this repository you need to open the advanced-samples folder (not the root!) and follow these steps:
88
1. Configure your Cloudinary cloud name for the sample app:
99
* Once you open the project a file named `gradle-local.properies` should be automatically created in the repository root (you can manually create it if it's not there). Note: This file is ignored by git and should never be checked in.
10-
* The file should contain a single property with your cloudinary url, stripped to cloud name only: `cloudinary.url=cloudinary://@myCloudName`
10+
* The file should contain a single property with your cloudinary url, stripped to cloud name only: `cloudinaryUrl=cloudinary://@myCloudName`
1111
* Run `./gradlew clean` (`gradlew clean` on Windows) from the repository root before proceeding.
1212
2. Configure the full credentials for the backend module. The best practice is to create an environment variable with your Cloudinary credentials:
1313

sample-signed/build.gradle

+11-19
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,31 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 27
5-
buildToolsVersion "27.0.2"
4+
compileSdkVersion 28
65
defaultConfig {
76
applicationId "com.cloudinary.android.sample.signed"
87
minSdkVersion 19
9-
targetSdkVersion 27
8+
targetSdkVersion 28
109
versionCode 1
1110
versionName "1.0"
1211
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12+
13+
// filter in the api credentials before building but without changing original source
14+
// files - to make sure the credentials are not checked into source control.
15+
// The url (without api secret!) is taken from a gradle property defined in
16+
// gradle-local.properties in the project root.
17+
manifestPlaceholders = [cloudinaryUrl:project.findProperty('cloudinaryUrl')]
1318
}
19+
1420
buildTypes {
1521
release {
1622
minifyEnabled false
1723
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1824
}
1925
}
20-
21-
applicationVariants.all { variant ->
22-
variant.outputs.each { output ->
23-
output.processManifest.doLast {
24-
println("configuring AndroidManifest.xml");
25-
26-
def manifestFile = new File("${buildDir}/intermediates/manifests/full/${variant.dirName}/AndroidManifest.xml")
27-
def content = manifestFile.getText()
28-
def updatedContent = content.replaceAll("cloudinary_do_not_modify", project.property("cloudinary.url"))
29-
manifestFile.write(updatedContent)
30-
}
31-
}
32-
}
3326
}
3427

3528
dependencies {
36-
// compile fileTree(dir: 'libs', include: ['*.jar'])
3729
compile project(':lib')
3830
compile project(path: ':backend', configuration: 'android-endpoints')
3931
compile('com.google.api-client:google-api-client-android:1.22.0') {
@@ -44,10 +36,10 @@ dependencies {
4436
}
4537

4638
compile "com.android.support:appcompat-v7:${androidSupportVersion}"
47-
compile "com.android.support.constraint:constraint-layout:1.0.2"
39+
compile "com.android.support.constraint:constraint-layout:1.1.3"
4840
compile "com.android.support:recyclerview-v7:${androidSupportVersion}"
4941
compile "com.android.support:design:${androidSupportVersion}"
50-
compile 'com.squareup.picasso:picasso:2.5.2'
42+
compile 'com.squareup.picasso:picasso:2.71828'
5143

5244
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
5345
exclude group: 'com.android.support', module: 'support-annotations'

sample-signed/src/main/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
</activity>
2929
<meta-data
3030
android:name="CLOUDINARY_URL"
31-
android:value="cloudinary_do_not_modify" />
31+
android:value="${cloudinaryUrl}" />
3232
</application>
3333
</manifest>

sample/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Cloudinary Sample App
66
Once you clone this repository there are two required steps to build the sample app:
77
1. Configure your Cloudinary cloud name for the app:
88
* Once you open the project (from the repository root) a file named `gradle-local.properies` should be automatically created in the repository root (you can manually create it if it's not there). Note: This file is ignored by git and should never be checked in.
9-
* The file should contain a single property with your cloudinary url, stripped to cloud name only: `cloudinary.url=cloudinary://@myCloudName`
9+
* The file should contain a single property with your cloudinary url, stripped to cloud name only: `cloudinaryUrl=cloudinary://@myCloudName`
1010
* Run `./gradlew clean` (`gradlew clean` on Windows) from the repository root before proceeding.
1111
2. Create an upload preset named 'sample_app_preset' in your cloudinary account console:
1212
* Login to your [Cloudinary console](https://cloudinary.com/console), go to settings>upload, scroll down

sample/build.gradle

+10-14
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,35 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 27
5-
buildToolsVersion "27.0.3"
4+
compileSdkVersion 28
65
defaultConfig {
76
applicationId "com.cloudinary.android.sample"
87
minSdkVersion 19
9-
targetSdkVersion 27
8+
targetSdkVersion 28
109
versionCode 1
1110
versionName "1.0"
1211
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12+
13+
// filter in the api credentials before building but without changing original source
14+
// files - to make sure the credentials are not checked into source control.
15+
// The url (without api secret!) is taken from a gradle property defined in
16+
// gradle-local.properties in the project root.
17+
manifestPlaceholders = [cloudinaryUrl: project.getCloudinaryUrl() ?: ""]
1318
}
19+
1420
buildTypes {
1521
release {
1622
minifyEnabled true
1723
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1824
}
1925
}
2026

21-
// filter in the api credentials before building but without changing original source files - to make sure the
22-
// credentials are not checked into source control. The url (without api secret!) is taken from a gradle property
23-
// defined in gradle-local.properties in the project root.
24-
applicationVariants.all { variant ->
25-
variant.outputs.each { output ->
26-
output.processManifest.doLast {
27-
filterManifest("${buildDir}/intermediates/manifests/full/${variant.dirName}/AndroidManifest.xml", project.property("cloudinary.url"))
28-
}
29-
}
30-
}
3127
}
3228

3329
dependencies {
3430
implementation project(':lib')
3531
implementation "com.android.support:appcompat-v7:${androidSupportVersion}"
36-
implementation "com.android.support.constraint:constraint-layout:1.1.0"
32+
implementation "com.android.support.constraint:constraint-layout:1.1.3"
3733
implementation "com.android.support:recyclerview-v7:${androidSupportVersion}"
3834
implementation "com.android.support:design:${androidSupportVersion}"
3935
implementation "com.android.support:cardview-v7:${androidSupportVersion}"

sample/src/main/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
<meta-data
4949
android:name="CLOUDINARY_URL"
50-
android:value="cloudinary_do_not_modify" />
50+
android:value="${cloudinaryUrl}" />
5151
</application>
5252

5353
</manifest>

0 commit comments

Comments
 (0)