Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ realm/realm-library/src/main/cpp/jni_include
realm/realm-library/distribution
# Cmake output
realm/realm-library/.externalNativeBuild

gen/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do these come from?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last time I saw gen it came from Eclipse things. 😮

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cmelchior @Zhuinden I am not sure from where It came, I have imported the whole project in IntelliJ Ultimate, and i guess the build generated the gen folder so I have added it in the .gitignore, to ignore then gen folder.

out/
12 changes: 3 additions & 9 deletions gradle-plugin/build.gradle → realm-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ dependencies {
compile gradleApi()
compile localGroovy()
compile "io.realm:realm-transformer:${version}"
/*Note: the latest Android Gradle plugin has now built in support for annotation processors and warns and/or blocks android-apt,
see this https://bitbucket.org/hvisser/android-apt/wiki/Migration page on how to migrate
and this https://www.littlerobots.nl/blog/Whats-next-for-android-apt/ for more info.
*/
compile 'com.neenbedankt.gradle.plugins:android-apt:1.8' //TODO: https://www.littlerobots.nl/blog/Whats-next-for-android-apt/
provided 'com.android.tools.build:gradle:3.1.0-alpha06'

provided 'com.android.tools.build:gradle:3.1.0-alpha07'
testCompile gradleTestKit()
testCompile 'junit:junit:4.12'
}
Expand Down Expand Up @@ -124,7 +118,7 @@ publishing {
accessKey project.hasProperty('s3AccessKey') ? s3AccessKey : 'noAccessKey'
secretKey project.hasProperty('s3SecretKey') ? s3SecretKey : 'noSecretKey'
}
if(project.version.endsWith('-SNAPSHOT')) {
if (project.version.endsWith('-SNAPSHOT')) {
url "s3://realm-ci-artifacts/maven/snapshots/"
} else {
url "s3://realm-ci-artifacts/maven/releases/"
Expand Down Expand Up @@ -163,7 +157,7 @@ artifactory {
password = project.hasProperty('bintrayKey') ? bintrayKey : 'noKey'
}
defaults {
publications ('realmPublication')
publications('realmPublication')
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package io.realm.gradle

import com.android.build.gradle.AppPlugin
import com.android.build.gradle.LibraryPlugin
import com.neenbedankt.gradle.androidapt.AndroidAptPlugin
import io.realm.transformer.RealmTransformer
import org.gradle.api.GradleException
import org.gradle.api.Plugin
Expand All @@ -42,30 +41,17 @@ class Realm implements Plugin<Project> {

def syncEnabledDefault = false
def dependencyConfigurationName = getDependencyConfigurationName(project)
def usesAptPlugin = project.plugins.findPlugin('com.neenbedankt.android-apt') != null
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I think we can remove support for this, we cannot do it in a patch release as it might be a breaking change, but if you direct this PR towards the branch next-major instead then it should be fine 👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(although technically AS 3.0 cannot run android-apt anymore, but maybe some legacy projects still use it with older version of IDE)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cmelchior I have changed the branch to next-major :)

def isKotlinProject = project.plugins.findPlugin('kotlin-android') != null
def useKotlinExtensionsDefault = isKotlinProject
def hasAnnotationProcessorConfiguration = project.getConfigurations().findByName('annotationProcessor') != null
// TODO add a parameter in 'realm' block if this should be specified by users
def preferAptOnKotlinProject = false


project.extensions.create('realm', RealmPluginExtension, project, syncEnabledDefault, useKotlinExtensionsDefault, dependencyConfigurationName)

if (shouldApplyAndroidAptPlugin(usesAptPlugin, isKotlinProject,
hasAnnotationProcessorConfiguration, preferAptOnKotlinProject)) {
project.plugins.apply(AndroidAptPlugin)
usesAptPlugin = true
}

project.android.registerTransform(new RealmTransformer(project))

project.repositories.add(project.getRepositories().jcenter())
project.dependencies.add(dependencyConfigurationName, "io.realm:realm-annotations:${Version.VERSION}")
if (usesAptPlugin) {
project.dependencies.add("apt", "io.realm:realm-annotations-processor:${Version.VERSION}")
project.dependencies.add("androidTestApt", "io.realm:realm-annotations-processor:${Version.VERSION}")
} else if (isKotlinProject && !preferAptOnKotlinProject) {
if (isKotlinProject) {
project.dependencies.add("kapt", "io.realm:realm-annotations-processor:${Version.VERSION}")
project.dependencies.add("kaptAndroidTest", "io.realm:realm-annotations-processor:${Version.VERSION}")
} else {
Expand Down Expand Up @@ -99,19 +85,4 @@ class Realm implements Plugin<Project> {
oldDependencyName
}
}

private static boolean shouldApplyAndroidAptPlugin(boolean usesAptPlugin, boolean isKotlinProject,
boolean hasAnnotationProcessorConfiguration,
boolean preferAptOnKotlinProject) {
if (usesAptPlugin) {
// for any projects that uses android-apt plugin already. No need to apply it twice.
return false
}
if (isKotlinProject) {
// for any Kotlin projects where user did not apply 'android-apt' plugin manually.
return preferAptOnKotlinProject && !hasAnnotationProcessorConfiguration
}
// for any Java Projects where user did not apply 'android-apt' plugin manually.
return !hasAnnotationProcessorConfiguration
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import org.gradle.api.Project

class RealmPluginExtension {
private Project project
def boolean syncEnabled
def boolean kotlinExtensionsEnabled
boolean syncEnabled
boolean kotlinExtensionsEnabled
private String dependencyConfigurationName

RealmPluginExtension(Project project, boolean syncEnabledDefault, boolean useKotlinExtensionsDefault, String dependencyConfigurationName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import org.junit.Before
import org.junit.Test

import static org.junit.Assert.assertEquals
import static org.junit.Assert.assertFalse
import static org.junit.Assert.assertTrue
import static org.junit.Assert.fail

Expand All @@ -53,8 +52,7 @@ class PluginTest {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha03'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
classpath 'com.android.tools.build:gradle:3.1.0-alpha07'
classpath "io.realm:realm-gradle-plugin:${currentVersion}"
}
}
Expand All @@ -71,15 +69,14 @@ class PluginTest {
}

@Test
public void pluginFailsWithoutAndroidPlugin() {
void pluginFailsWithoutAndroidPlugin() {
project.buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha03'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
classpath "io.realm:realm-gradle-plugin:${currentVersion}"
}
}
Expand Down
5 changes: 3 additions & 2 deletions realm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ buildscript {
mavenLocal()
google()
jcenter()
maven { url 'https://jitpack.io' }
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
maven { url "https://plugins.gradle.org/m2/" }
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha06'
classpath 'com.android.tools.build:gradle:3.1.0-alpha07'
classpath 'de.undercouch:gradle-download-task:3.3.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.novoda:gradle-android-command-plugin:1.7.1'
Expand Down Expand Up @@ -42,6 +42,7 @@ allprojects {
mavenLocal()
google()
jcenter()
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
}
}

Expand Down
5 changes: 3 additions & 2 deletions realm/kotlin-extensions/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ android {

dependencies {
implementation project(':realm-library')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure what impact this has on downstream projects?

androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test:rules:1.0.1'
Expand All @@ -70,7 +70,8 @@ dependencies {
}

repositories {
mavenCentral()
jcenter()
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
}

// enable @ParametersAreNonnullByDefault annotation. See https://blog.jetbrains.com/kotlin/2017/09/kotlin-1-1-50-is-out/
Expand Down
8 changes: 4 additions & 4 deletions realm/realm-library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ import io.realm.transformer.RealmTransformer
android.registerTransform(new RealmTransformer())

repositories {
maven { url "https://jitpack.io" }
mavenCentral()
jcenter()
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
}

dependencies {
Expand All @@ -207,11 +207,11 @@ dependencies {
androidTestImplementation 'com.google.dexmaker:dexmaker:1.2'
androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
androidTestImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

// specify error prone version to prevent sudden failure
errorprone 'com.google.errorprone:error_prone_core:2.1.2'
errorprone 'com.google.errorprone:error_prone_core:2.2.0'
}

task sourcesJar(type: Jar) {
Expand Down