Skip to content

Update tools versions and improve project setup #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Dec 21, 2018
Merged
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ android:
components:
- tools
- platform-tools
- build-tools-27.0.3
- build-tools-28.0.3
- android-21
- android-27
- android-28
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- addon-google_apis-google-25
- sys-img-armeabi-v7a-android-21

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

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
Expand Down
8 changes: 4 additions & 4 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.42'
compile group: 'com.cloudinary', name: 'cloudinary-http44', version: '1.13.0'
compile 'com.google.appengine:appengine-endpoints:1.9.42'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.42'
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.69'
compile group: 'com.cloudinary', name: 'cloudinary-http44', version: '1.19.0'
compile 'com.google.appengine:appengine-endpoints:1.9.69'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.69'
compile 'javax.servlet:servlet-api:2.5'
}

Expand Down
21 changes: 7 additions & 14 deletions gradle-scripts/common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ allprojects {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.android.tools.build:gradle:3.2.1'
}
}

Expand All @@ -32,18 +32,7 @@ allprojects {
project.ext.set("publishGroupId", group)
}

task wrapper(type: Wrapper) {
gradleVersion = '4.5'
}

ext.filterManifest = {manifestPath, newValue ->
def manifestFile = new File(manifestPath)
def content = manifestFile.getText()
def updatedContent = content.replaceAll("cloudinary_do_not_modify", newValue)
manifestFile.write(updatedContent)
}

ext.loadExtraProperties = {fileName ->
ext.loadExtraProperties = { fileName ->
def props = new Properties()
props.load(new FileInputStream(fileName))

Expand All @@ -52,11 +41,15 @@ ext.loadExtraProperties = {fileName ->
}
}

ext.getCloudinaryUrl = { ->
return findProperty("cloudinaryUrl") ?: System.getenv('CLOUDINARY_URL')
}

ext.generateAndLoadLocalGradleProperties = { rootPath ->
// Create default local gradle properties (ignored by git)
def file = new File(rootPath + 'gradle-local.properties')
if (file.createNewFile()) {
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'
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'
}
loadExtraProperties file.absoluteFile
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ developerEmail=info@cloudinary.com
# These two properties must use these exact names to be compatible with 'gradle install' plugin.
group=com.cloudinary
version=1.25.0
cloudinaryLibsVersion=1.19.0
androidSupportVersion=27.1.1
cloudinaryLibsVersion=1.21.0
androidSupportVersion=28.0.0
org.gradle.jvmargs=-Xmx1024m
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Thu Jul 20 11:40:28 IDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip
8 changes: 4 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

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

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

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
Expand Down Expand Up @@ -155,7 +155,7 @@ if $cygwin ; then
fi

# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
Expand Down
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

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

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down
38 changes: 21 additions & 17 deletions lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,47 +1,51 @@
apply plugin: 'com.android.library'



android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
compileSdkVersion 28

defaultConfig {
minSdkVersion 14
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

// filter in the api credentials before building but without changing original source
// files - to make sure the credentials are not checked into source control.
// The url is taken from a property or environment variable:
manifestPlaceholders = [cloudinaryUrl: getCloudinaryUrl() ?: ""]
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
consumerProguardFiles 'proguard-rules.pro'
}
}
}

// filter in the api credentials before building but without changing original source files - to make sure the
// credentials are not checked into source control. This is used by the tests only, the credentials
// are taken from the CLOUDINARY_URL environment variable or the cloudinaryUrl property
testVariants.all { variant ->
variant.outputs.each { output ->
output.processManifest.doLast {
def url = System.getenv('CLOUDINARY_URL') ?: project.findProperty("cloudinary.url")
if(!url) {
throw new GradleException("Missing credentials: please set CLOUDINARY_URL environment variable or cloudianryUrl build property.")
}
filterManifest("${buildDir}/intermediates/manifest/${variant.dirName}/AndroidManifest.xml", url)
}

task verifyCloudinaryCredentials {
doFirst {
if (!getCloudinaryUrl()) {
throw new GradleException("Missing credentials: please set CLOUDINARY_URL environment variable or cloudianryUrl property.")
}
}
}

// Force cloudinary credentials when running unit tests and connected device tests
tasks.matching { it.name.startsWith("connected") || it.name.startsWith("test")}.all { task ->
task.dependsOn verifyCloudinaryCredentials
}

dependencies {
api "com.cloudinary:cloudinary-core:${cloudinaryLibsVersion}"

implementation "com.android.support:support-compat:${androidSupportVersion}"
implementation ('com.evernote:android-job:1.2.6', {
implementation('com.evernote:android-job:1.2.6', {
exclude group: 'com.android.support', module: 'support-compat'
})

Expand Down
2 changes: 1 addition & 1 deletion lib/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<uses-library android:name="android.test.runner" />
<meta-data
android:name="CLOUDINARY_URL"
android:value="cloudinary_do_not_modify" />
android:value="${cloudinaryUrl}" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.cloudinary.Transformation;
import com.cloudinary.utils.ObjectUtils;
import com.cloudinary.utils.Rectangle;
import com.cloudinary.utils.StringUtils;

import junit.framework.Assert;

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

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

Expand Down
2 changes: 1 addition & 1 deletion sample-signed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This samples demonstrates the mechanism of signed uploads using a Google cloud e
Once you clone this repository you need to open the advanced-samples folder (not the root!) and follow these steps:
1. Configure your Cloudinary cloud name for the sample app:
* 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.
* The file should contain a single property with your cloudinary url, stripped to cloud name only: `cloudinary.url=cloudinary://@myCloudName`
* The file should contain a single property with your cloudinary url, stripped to cloud name only: `cloudinaryUrl=cloudinary://@myCloudName`
* Run `./gradlew clean` (`gradlew clean` on Windows) from the repository root before proceeding.
2. Configure the full credentials for the backend module. The best practice is to create an environment variable with your Cloudinary credentials:

Expand Down
30 changes: 11 additions & 19 deletions sample-signed/build.gradle
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
compileSdkVersion 28
defaultConfig {
applicationId "com.cloudinary.android.sample.signed"
minSdkVersion 19
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

// filter in the api credentials before building but without changing original source
// files - to make sure the credentials are not checked into source control.
// The url (without api secret!) is taken from a gradle property defined in
// gradle-local.properties in the project root.
manifestPlaceholders = [cloudinaryUrl:project.findProperty('cloudinaryUrl')]
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

applicationVariants.all { variant ->
variant.outputs.each { output ->
output.processManifest.doLast {
println("configuring AndroidManifest.xml");

def manifestFile = new File("${buildDir}/intermediates/manifests/full/${variant.dirName}/AndroidManifest.xml")
def content = manifestFile.getText()
def updatedContent = content.replaceAll("cloudinary_do_not_modify", project.property("cloudinary.url"))
manifestFile.write(updatedContent)
}
}
}
}

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

compile "com.android.support:appcompat-v7:${androidSupportVersion}"
compile "com.android.support.constraint:constraint-layout:1.0.2"
compile "com.android.support.constraint:constraint-layout:1.1.3"
compile "com.android.support:recyclerview-v7:${androidSupportVersion}"
compile "com.android.support:design:${androidSupportVersion}"
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.picasso:picasso:2.71828'

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
Expand Down
2 changes: 1 addition & 1 deletion sample-signed/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
</activity>
<meta-data
android:name="CLOUDINARY_URL"
android:value="cloudinary_do_not_modify" />
android:value="${cloudinaryUrl}" />
</application>
</manifest>
2 changes: 1 addition & 1 deletion sample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Cloudinary Sample App
Once you clone this repository there are two required steps to build the sample app:
1. Configure your Cloudinary cloud name for the app:
* 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.
* The file should contain a single property with your cloudinary url, stripped to cloud name only: `cloudinary.url=cloudinary://@myCloudName`
* The file should contain a single property with your cloudinary url, stripped to cloud name only: `cloudinaryUrl=cloudinary://@myCloudName`
* Run `./gradlew clean` (`gradlew clean` on Windows) from the repository root before proceeding.
2. Create an upload preset named 'sample_app_preset' in your cloudinary account console:
* Login to your [Cloudinary console](https://cloudinary.com/console), go to settings>upload, scroll down
Expand Down
24 changes: 10 additions & 14 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
compileSdkVersion 28
defaultConfig {
applicationId "com.cloudinary.android.sample"
minSdkVersion 19
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

// filter in the api credentials before building but without changing original source
// files - to make sure the credentials are not checked into source control.
// The url (without api secret!) is taken from a gradle property defined in
// gradle-local.properties in the project root.
manifestPlaceholders = [cloudinaryUrl: project.getCloudinaryUrl() ?: ""]
}

buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

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

dependencies {
implementation project(':lib')
implementation "com.android.support:appcompat-v7:${androidSupportVersion}"
implementation "com.android.support.constraint:constraint-layout:1.1.0"
implementation "com.android.support.constraint:constraint-layout:1.1.3"
implementation "com.android.support:recyclerview-v7:${androidSupportVersion}"
implementation "com.android.support:design:${androidSupportVersion}"
implementation "com.android.support:cardview-v7:${androidSupportVersion}"
Expand Down
2 changes: 1 addition & 1 deletion sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

<meta-data
android:name="CLOUDINARY_URL"
android:value="cloudinary_do_not_modify" />
android:value="${cloudinaryUrl}" />
</application>

</manifest>
Loading