bluelinelabs / LoganSquare

Screaming fast JSON parsing and serialization library for Android.
Apache License 2.0
3.21k stars 306 forks source link

Build for server, not Android #166

Closed fabienrenaud closed 8 years ago

fabienrenaud commented 8 years ago

Could we get this project compilable for server and independent from all the android dependencies?

mannodermaus commented 8 years ago

LoganSquare doesn't have any Android compile dependencies, you can just plug it into pure-Java projects without any problems. Just make sure to use an apt plugin other than android-apt to hook in the annotation processor!

fabienrenaud commented 8 years ago

Well, that plugin has limitations...

First, if i only add what's listed on the readme to my project:

diff --git a/build.gradle b/build.gradle
index 6226cca..3233357 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,8 +1,19 @@
-plugins {
-    id 'com.github.johnrengelman.shadow' version '1.2.3'
+buildscript {
+    repositories {
+        jcenter()
+        maven {
+            url "https://plugins.gradle.org/m2/"
+        }
+    }
+    dependencies {
+        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
+        classpath "com.github.jengelman.gradle.plugins:shadow:1.2.3"
+    }
 }

 apply plugin: 'java'
+apply plugin: 'com.neenbedankt.android-apt'
+apply plugin: "com.github.johnrengelman.shadow"

@@ -42,6 +53,9 @@ dependencies {
     compile group: 'com.alibaba', name: 'fastjson', version: '1.2.12'
     // json-io
     compile group: 'com.cedarsoftware', name: 'json-io', version: '4.4.0'
+    // LoganSquare
+    apt 'com.bluelinelabs:logansquare-compiler:1.3.6'
+    compile 'com.bluelinelabs:logansquare:1.3.6'

i get:

> gradle build

FAILURE: Build failed with an exception.

* Where:
Build file 'path/to/build.gradle' line: 15

* What went wrong:
A problem occurred evaluating root project.
> Failed to apply plugin [id 'com.neenbedankt.android-apt']
   > The android or android-library plugin must be applied to the project

so i add the com.android.application plugin to my build.gradle, then i get:

> Failed to apply plugin [id 'com.android.application']
   > Gradle version 2.2 is required. Current version is 2.12. If using the gradle wrapper, try editing the distributionUrl in /Users/frenaud/projects/me/benchson/gradle/wrapper/gradle-wrapper.properties to gradle-2.2-all.zip

and i don't like the idea of being stuck on v2.2.

EricKuck commented 8 years ago

Why are you trying to use the android-apt plugin if you're not targeting Android? Just use the normal apt.

fabienrenaud commented 8 years ago

Indeed. Thanks. The readme should provide the different configs imo.

EricKuck commented 8 years ago

This isn't really designed for anything other than Android, even if it does work. I don't have any interest in trying to support other configurations.

mannodermaus commented 8 years ago

I usually use this one for annotation processing in my pure-Java projects, and it works well with LoganSquare. If you change to that it will work!