Skip to content

Commit

Permalink
Add possiblity to build a FOSS version by passing -Pfoss=true to gradle
Browse files Browse the repository at this point in the history
args

closes #1
  • Loading branch information
fredszaq committed Oct 9, 2015
1 parent b4bdc64 commit c070275
Show file tree
Hide file tree
Showing 11 changed files with 260 additions and 6 deletions.
20 changes: 15 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ buildscript {
}
dependencies {
classpath "com.android.tools.build:gradle:1.3.0"
classpath "com.crashlytics.tools.gradle:crashlytics-gradle:1.+"

// add -Pfoss=true to gradlew args to build a version with no Crashlytics/Google analytics
if(!project.hasProperty('foss')) {
classpath "com.crashlytics.tools.gradle:crashlytics-gradle:1.+"
}
classpath "com.neenbedankt.gradle.plugins:android-apt:1.4"

// this plugin is provided as a jar as atm there is no relase with android support
Expand Down Expand Up @@ -64,7 +68,9 @@ repositories {
}

apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
if(!project.hasProperty('foss')) {
apply plugin: 'crashlytics'
}
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'checkstyle'

Expand Down Expand Up @@ -117,7 +123,6 @@ configurations {
dependencies {
compile project(':fab')
compile project(':navdrawer')
compile "com.google.android.gms:play-services-analytics:$playServicesVersion"
compile "com.android.support:appcompat-v7:$androidSupportVersion"
// Dependency injection
compile "com.google.dagger:dagger:$daggerVersion"
Expand All @@ -133,7 +138,12 @@ dependencies {
debugCompile "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"
debugCompile "im.dino:dbinspector:$dbinspectorVersion@aar"
compile "com.crashlytics.android:crashlytics:$crashlyticsVersion"
if(project.hasProperty('foss')) {
compile project(":fosstweaks")
} else {
compile "com.crashlytics.android:crashlytics:$crashlyticsVersion"
compile "com.google.android.gms:play-services-analytics:$playServicesVersion"
}
// network
compile "com.squareup.retrofit:retrofit:$retrofitVersion"
compile "com.squareup.okhttp:okhttp:$okhttpVersion"
Expand Down Expand Up @@ -272,4 +282,4 @@ preBuild.dependsOn('licenseFormat')
classifier flavor
}

}
}
23 changes: 23 additions & 0 deletions fosstweaks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# FossTweaks

This project is used to replace the Crashlytics and Google analytics dependencies when we want to
build a FOSS version of the app.

# Licence

Copyright 2015 eBusiness Information

This file is part of OSM Contributor.

OSM Contributor is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OSM Contributor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with OSM Contributor. If not, see <http://www.gnu.org/licenses/>.
6 changes: 6 additions & 0 deletions fosstweaks/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
}
24 changes: 24 additions & 0 deletions fosstweaks/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 eBusiness Information
This file is part of OSM Contributor.
OSM Contributor is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OSM Contributor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OSM Contributor. If not, see <http://www.gnu.org/licenses/>.
-->
<manifest package="io.mapsquare.fosstweaks">
<application/>
</manifest>
34 changes: 34 additions & 0 deletions fosstweaks/src/main/java/com/crashlytics/android/Crashlytics.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright (C) 2015 eBusiness Information
*
* This file is part of OSM Contributor.
*
* OSM Contributor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OSM Contributor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OSM Contributor. If not, see <http://www.gnu.org/licenses/>.
*/
package com.crashlytics.android;

import android.content.Context;


/**
* Just a no-op implementation of crashlytics used to disable it when we want a FOSS build
*/
public class Crashlytics {

public static void start(Context context) {
}

public static void log(int priority, String tag, String msg) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Copyright (C) 2015 eBusiness Information
*
* This file is part of OSM Contributor.
*
* OSM Contributor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OSM Contributor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OSM Contributor. If not, see <http://www.gnu.org/licenses/>.
*/

package com.google.android.gms.analytics;

import android.content.Context;

public class GoogleAnalytics {

public Tracker newTracker(String trackingId) {
return new Tracker();
}


public static GoogleAnalytics getInstance(Context context) {
return new GoogleAnalytics();
}

public void setDryRun(boolean dryRun) {
}

public void setLocalDispatchPeriod(int dispatchPeriodInSeconds) {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright (C) 2015 eBusiness Information
*
* This file is part of OSM Contributor.
*
* OSM Contributor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OSM Contributor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OSM Contributor. If not, see <http://www.gnu.org/licenses/>.
*/

package com.google.android.gms.analytics;

import java.util.HashMap;
import java.util.Map;

public class HitBuilders {

public static class EventBuilder{
public EventBuilder() {}

public HitBuilders.EventBuilder setCategory(String category) {
return this;
}

public HitBuilders.EventBuilder setAction(String action) {
return this;
}

public Map<String, String> build() {
return new HashMap<>();
}
}


public static class ScreenViewBuilder{
public ScreenViewBuilder() {}

public Map<String, String> build() {
return new HashMap<>();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright (C) 2015 eBusiness Information
*
* This file is part of OSM Contributor.
*
* OSM Contributor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OSM Contributor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OSM Contributor. If not, see <http://www.gnu.org/licenses/>.
*/

package com.google.android.gms.analytics;

import java.util.Map;

public class Tracker {
public void send(Map<String, String> params) {
}

public void enableAutoActivityTracking(boolean enabled) {
}

public void enableAdvertisingIdCollection(boolean enabled) {
}

public void setScreenName(String screenName) {
}

}


4 changes: 4 additions & 0 deletions fosstweaks/src/main/res/values/integers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="google_play_services_version">0</integer>
</resources>
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include 'navdrawer'
include 'fab'
include 'fab'
include 'fosstweaks'
20 changes: 20 additions & 0 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 eBusiness Information
This file is part of OSM Contributor.
OSM Contributor is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OSM Contributor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OSM Contributor. If not, see <http://www.gnu.org/licenses/>.
-->
<manifest
package="io.mapsquare.osmcontributor"
xmlns:android="http://schemas.android.com/apk/res/android"
Expand Down

0 comments on commit c070275

Please sign in to comment.