easyfire 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.byebug_history +256 -0
  3. data/.gitignore +12 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +5 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +6 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +43 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +14 -0
  12. data/bin/easyfire +5 -0
  13. data/bin/setup +8 -0
  14. data/easyfire.gemspec +40 -0
  15. data/lib/easyfire/cli.rb +23 -0
  16. data/lib/easyfire/easyfire_model.rb +140 -0
  17. data/lib/easyfire/renders/helpers.rb +68 -0
  18. data/lib/easyfire/renders/model.rb +32 -0
  19. data/lib/easyfire/renders/service.rb +30 -0
  20. data/lib/easyfire/renders/templates/model.java.erb +220 -0
  21. data/lib/easyfire/renders/templates/model.swift.erb +62 -0
  22. data/lib/easyfire/renders/templates/service.java.erb +43 -0
  23. data/lib/easyfire/renders/templates/service.swift.erb +92 -0
  24. data/lib/easyfire/renders.rb +7 -0
  25. data/lib/easyfire/thor/android/build.gradle.tt +100 -0
  26. data/lib/easyfire/thor/android/build.sbt.tt +17 -0
  27. data/lib/easyfire/thor/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  28. data/lib/easyfire/thor/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  29. data/lib/easyfire/thor/android/gradle.properties +2 -0
  30. data/lib/easyfire/thor/android/gradlew +160 -0
  31. data/lib/easyfire/thor/android/gradlew.bat +90 -0
  32. data/lib/easyfire/thor/android/pom.xml.tt +76 -0
  33. data/lib/easyfire/thor/android/settings.gradle.tt +1 -0
  34. data/lib/easyfire/thor/android/src/main/AndroidManifest.xml.tt +3 -0
  35. data/lib/easyfire/thor/android.rb +56 -0
  36. data/lib/easyfire/thor/android_helper/EasyfireDelegate.java.tt +10 -0
  37. data/lib/easyfire/thor/android_helper/EasyfireListDelegate.java.tt +11 -0
  38. data/lib/easyfire/thor/android_helper/ModelEF.java.tt +10 -0
  39. data/lib/easyfire/thor/android_helper/ServiceEF.java.tt +370 -0
  40. data/lib/easyfire/version.rb +3 -0
  41. data/lib/easyfire.rb +22 -0
  42. metadata +170 -0
@@ -0,0 +1,68 @@
1
+ module Easyfire
2
+ module Renders
3
+ module Helpers
4
+
5
+ attr_accessor :base_package, :version
6
+
7
+ @@java_data_types = {
8
+ String: "String",
9
+ Long: "Long",
10
+ Boolean: "Boolean"
11
+ }
12
+
13
+ @@swift_data_types = {
14
+ String: "String?",
15
+ Long: "CLong?",
16
+ Boolean: "Bool?"
17
+ }
18
+
19
+ @@java_defaults = {
20
+ String: "\"\"",
21
+ Long: "0L",
22
+ Boolean: "false"
23
+ }
24
+
25
+ @@swift_defaults = {
26
+ String: "\"\"",
27
+ Long: "0",
28
+ Boolean: "false"
29
+ }
30
+
31
+ def type_to_java_value(data_type)
32
+ @@java_data_types[data_type] || data_type.to_s
33
+ end
34
+ def type_to_swift_value(data_type)
35
+ @@swift_data_types[data_type]
36
+ end
37
+
38
+
39
+ def java_default_value(data_type)
40
+ @@java_defaults[data_type] || "null"
41
+ end
42
+
43
+ def swift_default_value(data_type)
44
+ @@swift_defaults[data_type]
45
+ end
46
+
47
+ def extract_spec(spec)
48
+ @spec = spec
49
+ @name = spec.model_name.to_s
50
+ @class_name_ef = spec.model_name.to_s + "EF"
51
+ @service_class = spec.model_name.to_s + "ServiceEF"
52
+ @object_name_ef = spec.model_name.to_s.uncapitalize + "EF"
53
+ @collection_name = spec.model_name.to_s.underscore
54
+ @declaration = "#{@class_name_ef} #{@object_name_ef}"
55
+ @description = spec.description
56
+ @attributes = spec.attributes
57
+ @belongs_to = spec.associations
58
+ @parents = spec.parents
59
+ end
60
+
61
+ def generate(template)
62
+ ERB.new(template).result(binding)
63
+ end
64
+
65
+
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,32 @@
1
+ require 'erb'
2
+ require 'byebug'
3
+
4
+ module Easyfire
5
+
6
+
7
+ module Renders
8
+
9
+ class Model
10
+
11
+ include Easyfire::Renders::Helpers
12
+
13
+ def initialize
14
+ @java = File.read("#{Renders::GEM_ROOT}/easyfire/renders/templates/model.java.erb")
15
+ @swift = File.read("#{Renders::GEM_ROOT}/easyfire/renders/templates/model.swift.erb")
16
+ end
17
+
18
+ def to_java(spec)
19
+ extract_spec(spec)
20
+ generate(@java)
21
+ end
22
+
23
+ def to_swift(spec)
24
+ extract_spec(spec)
25
+ generate(@swift)
26
+ end
27
+
28
+ private
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,30 @@
1
+ require 'erb'
2
+ require 'byebug'
3
+
4
+ module Easyfire
5
+
6
+ module Renders
7
+
8
+ class Service
9
+
10
+ include Easyfire::Renders::Helpers
11
+
12
+
13
+ def initialize
14
+ @java = File.read("#{Renders::GEM_ROOT}/easyfire/renders/templates/service.java.erb")
15
+ @swift = File.read("#{Renders::GEM_ROOT}/easyfire/renders/templates/service.swift.erb")
16
+ end
17
+
18
+ def to_java(spec)
19
+ extract_spec(spec)
20
+ generate(@java)
21
+ end
22
+
23
+ def to_swift(spec)
24
+ extract_spec(spec)
25
+ generate(@swift)
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,220 @@
1
+
2
+ /**********************************************************
3
+ * <%=@class_name_ef%>.java
4
+ * <%=@description%>
5
+ * Version: <%=@version%>
6
+ * Generated by Easyfire. Do not modify this code
7
+ **********************************************************/
8
+
9
+ package <%=@base_package%>.models;
10
+
11
+ import <%=@base_package%>.base.ModelEF;
12
+ import <%=@base_package%>.services.<%=@service_class%>;
13
+ <% @attributes.each do |key,value| %><% if value[:association] %>import <%=@base_package%>.models.<%=value[:association]%>EF;
14
+ import <%=@base_package%>.services.<%=value[:association]%>ServiceEF;
15
+ <%end%><%end%>
16
+ import <%=@base_package%>.delegates.EasyfireDelegate;
17
+
18
+
19
+
20
+ import com.google.firebase.database.Exclude;
21
+ import com.google.firebase.database.IgnoreExtraProperties;
22
+ import android.databinding.BaseObservable;
23
+ import android.support.annotation.NonNull;
24
+ import java.util.List;
25
+ import java.util.ArrayList;
26
+
27
+ import android.text.TextUtils;
28
+
29
+ @IgnoreExtraProperties
30
+ public class <%= @class_name_ef %> implements ModelEF, Comparable<<%= @class_name_ef %>>{
31
+
32
+ public static final String COLLECTION = "<%=@collection_name%>";
33
+
34
+ //Firebase attributes
35
+ @Exclude
36
+ private String key;
37
+
38
+ @Exclude
39
+ private List<Class> parents = new ArrayList<>();
40
+
41
+ @Exclude
42
+ private String[] parentKeys = new String[]{<%=@parents.map{|e| "\"\""}.join(",")%>};
43
+
44
+
45
+ <%@attributes.each do |key,value|%>
46
+ <%="//#{value[:description]}" unless value[:description].blank? %>
47
+ <%="\n @Exclude " if value[:options].include?(:transient)%>private <%=type_to_java_value(value[:type])%> <%=key%> = <%=java_default_value(value[:type])%>;
48
+ <%end%>
49
+
50
+ //Construtores
51
+ public <%=@class_name_ef%>(){}
52
+
53
+ public <%=@class_name_ef%>(String key){
54
+ this.key = key;
55
+ }
56
+
57
+ //Getters e Setters
58
+
59
+ @Exclude
60
+ public String getKey(){
61
+ return this.key;
62
+ }
63
+
64
+ @Exclude
65
+ public void setKey(String key){
66
+ this.key = key;
67
+ }
68
+
69
+ @Exclude
70
+ public List<Class> getParents(){
71
+ return this.parents;
72
+ }
73
+
74
+ @Exclude
75
+ public void setParents(List<Class> parents){
76
+ this.parents = parents;
77
+ }
78
+
79
+ @Exclude
80
+ public String[] getParentKeys(){
81
+ return this.parentKeys;
82
+ }
83
+
84
+ @Exclude
85
+ public void setParentKeys(String[] parentKeys){
86
+ this.parentKeys = parentKeys;
87
+ }
88
+
89
+ @Exclude
90
+ public void addParentKey(Class clazz,String parentKey){
91
+ this.parentKeys[getParentLevel(clazz)] = parentKey;
92
+ }
93
+
94
+ @Exclude
95
+ public int getParentLevel(Class clazz){
96
+ return this.parents.indexOf(clazz);
97
+ }
98
+
99
+
100
+
101
+ @Exclude
102
+ public String getPath(){
103
+
104
+ String path = COLLECTION.concat("/").concat(TextUtils.join("/",parentKeys));
105
+ if(!path.endsWith("/")){
106
+ path.concat("/");
107
+ }
108
+
109
+ return path.concat(key);
110
+
111
+ }
112
+
113
+
114
+
115
+ <%@attributes.each do |key,value|%>
116
+ <%if value[:association] == nil %>
117
+ <%="@Exclude" if value[:options].include?(:transient)%>
118
+ public <%=type_to_java_value(value[:type])%> get<%=key.to_s.camelcase%>(){
119
+ return this.<%=key%>;
120
+ }
121
+ <%elsif type_to_java_value(value[:type]) != @name%>
122
+ @Exclude
123
+ public void get<%=key.to_s.camelcase%>(final EasyfireDelegate<<%=type_to_java_value(value[:type])%>> delegate) {
124
+
125
+ if (this.<%=type_to_java_value(value[:type]).uncapitalize%> == null) {
126
+ new <%=type_to_java_value(value[:type]).gsub(/EF/,"ServiceEF")%>().retrieve(this.<%=type_to_java_value(value[:type]).uncapitalize.gsub(/EF/,"EFPath")%>, new EasyfireDelegate<<%=type_to_java_value(value[:type])%>>() {
127
+ @Override
128
+ public void changed(<%=type_to_java_value(value[:type])%> o) {
129
+ <%=type_to_java_value(value[:type]).uncapitalize%> = o;
130
+ delegate.changed(o);
131
+ }
132
+
133
+ @Override
134
+ public void error(Object object) {
135
+ delegate.error(object);
136
+ }
137
+ });
138
+ } else {
139
+ delegate.changed(this.<%=type_to_java_value(value[:type]).uncapitalize%>);
140
+ }
141
+ }
142
+ <%end%>
143
+
144
+
145
+ public void set<%=key.to_s.camelcase%>(<%=type_to_java_value(value[:type])%> <%=key%>){
146
+ this.<%=key%> = <%=key%>;
147
+ <%if @parents.include?(value[:type].to_s.gsub("EF","").to_sym)%>
148
+ this.parentKeys[<%=@parents.index(value[:type].to_s.gsub("EF","").to_sym)%>] = this.<%=key%>.getKey();
149
+ this.<%=key.to_s.gsub(/EF/,"EFPath")%> = this.<%=key%>.getPath();
150
+ <%end %>
151
+ <%if key.to_s.end_with?("EFPath") and @belongs_to[key.to_s.gsub(/EFPath/,'').camelcase.to_sym][:load] == :eager %>
152
+ this.get<%=key.to_s.camelcase%>();
153
+ <%end%>
154
+ }
155
+
156
+ <%end%>
157
+
158
+ @Override
159
+ public String toString() {
160
+ return "<%=@class_name_ef%>{" +
161
+ "key='" + key + '\'' +
162
+ <%@attributes.keys.each do |a|%>", <%=a%>='" + <%=a%> + '\'' +
163
+ <%end%>"}";
164
+ }
165
+
166
+ @Override
167
+ public boolean equals(Object o) {
168
+ if (this == o) return true;
169
+ if (o == null || getClass() != o.getClass()) return false;
170
+
171
+ <%=@declaration%> = (<%=@class_name_ef%> ) o;
172
+
173
+ return key != null ? key.equals(<%=@object_name_ef%>.key) : <%=@object_name_ef%>.key == null;
174
+
175
+ }
176
+
177
+ public boolean equalsContent(Object o) {
178
+ if (this == o) return true;
179
+ if (o == null || getClass() != o.getClass()) return false;
180
+ if (!super.equals(o)) return false;
181
+
182
+ <%=@declaration%> = (<%=@class_name_ef%> ) o;
183
+
184
+ <%@attributes.keys.each do |a|%>
185
+ if (<%=a%> != null ? !<%=a%>.equals(<%=@object_name_ef%>.<%=a%>) : <%=@object_name_ef%>.<%=a%> != null) {
186
+ return false;
187
+ }
188
+ <%end%>
189
+
190
+ return true;
191
+
192
+ }
193
+
194
+ @Override
195
+ public int hashCode() {
196
+ return key != null ? key.hashCode() : 0;
197
+ }
198
+
199
+
200
+ public boolean isChild(){
201
+ return parents != null;
202
+ }
203
+
204
+ @Override
205
+ public int compareTo(@NonNull <%=@declaration%>) {
206
+ return this.key.compareTo(<%=@object_name_ef%>.getKey());
207
+ }
208
+
209
+ public void store(EasyfireDelegate<<%=@class_name_ef%>> delegate){
210
+ new <%=@service_class%>().store(this,delegate);
211
+ }
212
+
213
+ public void delete(EasyfireDelegate<Boolean> delegate){
214
+ new <%=@service_class%>().delete(this,delegate);
215
+ }
216
+
217
+
218
+
219
+
220
+ }
@@ -0,0 +1,62 @@
1
+ /**********************************************************
2
+ * <%=@name%>EM.swift
3
+ * <%=@description%>
4
+ * Version: <%=@version%>
5
+ * Generated by Easyfire. Do not modify this code
6
+ **********************************************************/
7
+
8
+ import Foundation
9
+ import Firebase
10
+
11
+ struct <%= @name %> : Equatable {
12
+
13
+ let key: String?
14
+
15
+ <%@attributes.each do |key,value|%>
16
+ //<%=value[:description]%>
17
+ let <%=key%>: <%=type_to_swift_value(value[:type])%>;
18
+ <%end%>
19
+
20
+ init( <%=@attributes.to_a.map{|e| "#{e[0].to_s}: #{type_to_swift_value(e[1][:type])}"}.join(",\n ")%> ) {
21
+
22
+ <%=@attributes.to_a.map{|e| "self.#{e[0].to_s} = #{e[0].to_s}"}.join("\n ")%>
23
+
24
+ }
25
+
26
+
27
+ init( snapshot: DataSnapshot ) {
28
+
29
+ key = snapshot.key
30
+ let snapshotValue = snapshot.value as! [String: AnyObject]
31
+
32
+ <%=@attributes.to_a.map{|e| "self.#{e[0].to_s} = snapshotValue[\"#{e[0].to_s}\"] as? #{type_to_swift_value(e[1][:type])} ?? #{swift_default_value(e[1][:type])}" }.join("\n ")%>
33
+
34
+ }
35
+
36
+
37
+ init( snapshot: DataSnapshot ) {
38
+
39
+ key = snapshot.key
40
+ let snapshotValue = snapshot.value as! [String: AnyObject]
41
+
42
+ <%=@attributes.to_a.map{|e| "self.#{e[0].to_s} = snapshotValue[\"#{e[0].to_s}\"] as? #{type_to_swift_value(e[1][:type])} ?? #{swift_default_value(e[1][:type])}" }.join("\n ")%>
43
+
44
+ }
45
+
46
+ init( key: String ) {
47
+
48
+ self.key = key
49
+ <%=@attributes.to_a.map{|e| "self.#{e[0].to_s} = #{swift_default_value(e[1][:type])}" }.join("\n ")%>
50
+ }
51
+
52
+ func toAnyObject() -> Any {
53
+ return [
54
+ <%=@attributes.to_a.map{|e| "\"#{e[0].to_s}\" : #{e[0].to_s} ?? #{swift_default_value(e[1][:type])}" }.join(",\n ")%>
55
+ ]
56
+ }
57
+
58
+ static func ==(lhs: <%= @name %>, rhs: <%= @name %>) -> Bool {
59
+ return lhs.key == rhs.key
60
+ }
61
+
62
+ }
@@ -0,0 +1,43 @@
1
+ /**********************************************************
2
+ * <%=@service_class%>.java
3
+ * Firebase Services
4
+ * Version: <%=@version%>
5
+ * Generated by Easyfire. Do not modify this code
6
+ **********************************************************/
7
+ package <%=@base_package%>.services;
8
+
9
+ import <%=@base_package%>.base.ServiceEF;
10
+
11
+ import android.net.Uri;
12
+ import android.support.annotation.NonNull;
13
+ import android.util.Log;
14
+
15
+ import <%=@base_package%>.models.<%=@class_name_ef%>;
16
+ import com.google.firebase.database.DatabaseReference;
17
+ import com.google.firebase.database.FirebaseDatabase;
18
+
19
+ public class <%=@service_class%> extends ServiceEF {
20
+
21
+ private final FirebaseDatabase database;
22
+ private final DatabaseReference ref;
23
+
24
+ public <%=@service_class%>(){
25
+ this.database = FirebaseDatabase.getInstance();
26
+ this.ref = database.getReference("<%=@collection_name%>");
27
+ }
28
+
29
+ @Override
30
+ public DatabaseReference getRef() {
31
+ return this.ref;
32
+ }
33
+
34
+ @Override
35
+ protected Class<<%=@class_name_ef%>> getRuntimeClass() {
36
+ return <%=@class_name_ef%>.class;
37
+ }
38
+
39
+ @Override
40
+ public <%=@class_name_ef%> createInstanceWithKey(String key) {
41
+ return new <%=@class_name_ef%>(key);
42
+ }
43
+ }
@@ -0,0 +1,92 @@
1
+ /**********************************************************
2
+ * <%=@name%>ServiceEM.java
3
+ * Firebase Services
4
+ * Version: <%=@version%>
5
+ * Generated by Easyfire. Do not modify this code
6
+ **********************************************************/
7
+
8
+ import android.net.Uri;
9
+ import android.support.annotation.NonNull;
10
+ import android.util.Log;
11
+
12
+
13
+ public class <%=@name%>ServiceEM {
14
+
15
+ private final FirebaseDatabase database;
16
+ private final DatabaseReference ref;
17
+
18
+ private ValueEventListener buscaQuantidadeParticipantesHandle;
19
+ private ValueEventListener buscaStatusMeuConviteHandler;
20
+
21
+ public <%=@name%>ServiceEM(){
22
+ this.database = FirebaseDatabase.getInstance();
23
+ this.ref = database.getReference(<%=@collection_name%>)
24
+ }
25
+
26
+ <% if parent %>
27
+ public void findBy(final String parentKey, final String key, final EasyfireDelegate delegate){
28
+ this.ref.child(parentKey).child(key).addListenerForSingleValueEvent(new ValueEventListener() {
29
+ <% else %>
30
+ public void findBy(final String key, final EasyfireDelegate delegate){
31
+ this.ref.child(key).addListenerForSingleValueEvent(new ValueEventListener() {
32
+ <%end%>
33
+ @Override
34
+ public void onDataChange(DataSnapshot dataSnapshot) {
35
+ if(dataSnapshot.exists()){
36
+ <%=@name%> <%=@name.uncapitalize%> = dataSnapshot.getValue(<%=@name%>.class);
37
+ <%=@name.uncapitalize%>.key = dataSnapshot.getKey();
38
+ delegate.changed(<%=@name.uncapitalize%>);
39
+ }else{
40
+ delegate.changed(null);
41
+ }
42
+ }
43
+ @Override
44
+ public void onCancelled(DatabaseError databaseError) {
45
+ delegate.error(databaseError);
46
+ }
47
+ });
48
+ }
49
+
50
+
51
+
52
+ public void store(final <%=@name%> <%=@name.uncapitalize%>,
53
+ final EasyfireDelegate delegate) {
54
+
55
+ final DatabaseReference localRef;
56
+
57
+ if(<%=@name.uncapitalize%>.key == null){
58
+ localRef = <%=@name.uncapitalize%>.isChild() ?
59
+ ref.child(<%=@name.uncapitalize%>.getParentKey()).push() :
60
+ ref.push()
61
+
62
+ }else{
63
+ localRef = <%=@name.uncapitalize%>.isChild() ?
64
+ ref.child(<%=@name.uncapitalize%>.getParentKey()).child(<%=@name.uncapitalize%>.getKey()) :
65
+ ref(<%=@name.uncapitalize%>.getKey())
66
+
67
+ }
68
+
69
+
70
+
71
+ Task<Void> task = localRef.setValue(<%=@name.uncapitalize%>);
72
+ task.addOnCompleteListener(new OnCompleteListener<Void>() {
73
+ @Override
74
+ public void onComplete(@NonNull Task<Void> task) {
75
+ delegate.changed(true);
76
+ }
77
+ }).addOnFailureListener(new OnFailureListener() {
78
+ @Override
79
+ public void onFailure(@NonNull Exception e) {
80
+ delegate.error(e);
81
+ }
82
+ });
83
+ }
84
+
85
+ public void delete(final <%=@name%> <%=@name.uncapitalize%>, final EasyfireDelegate delegate) {
86
+
87
+
88
+ ref.child(camera.uid).child(camera.key).removeValue();
89
+ delegate.changed();
90
+ }
91
+
92
+ }
@@ -0,0 +1,7 @@
1
+ module Easyfire
2
+
3
+ module Renders
4
+
5
+ GEM_ROOT = File.expand_path("../..", __FILE__)
6
+ end
7
+ end
@@ -0,0 +1,100 @@
1
+ apply plugin: 'idea'
2
+ apply plugin: 'eclipse'
3
+
4
+ group = '<%=@group%>'
5
+ version = '<%=@version%>'
6
+
7
+ buildscript {
8
+ repositories {
9
+ jcenter()
10
+ }
11
+ dependencies {
12
+ classpath 'com.android.tools.build:gradle:2.3.+'
13
+ classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
14
+ }
15
+ }
16
+
17
+ repositories {
18
+ jcenter()
19
+ }
20
+
21
+
22
+ if(hasProperty('target') && target == 'android') {
23
+
24
+ apply plugin: 'com.android.library'
25
+ apply plugin: 'com.github.dcendents.android-maven'
26
+
27
+ android {
28
+ compileSdkVersion 25
29
+ buildToolsVersion '25.0.2'
30
+ defaultConfig {
31
+ minSdkVersion 14
32
+ targetSdkVersion 25
33
+ }
34
+ compileOptions {
35
+ sourceCompatibility JavaVersion.VERSION_1_7
36
+ targetCompatibility JavaVersion.VERSION_1_7
37
+ }
38
+
39
+ // Rename the aar correctly
40
+ libraryVariants.all { variant ->
41
+ variant.outputs.each { output ->
42
+ def outputFile = output.outputFile
43
+ if (outputFile != null && outputFile.name.endsWith('.aar')) {
44
+ def fileName = "${project.name}-${variant.baseName}-${version}.aar"
45
+ output.outputFile = new File(outputFile.parent, fileName)
46
+ }
47
+ }
48
+ }
49
+
50
+ dependencies {
51
+ provided 'javax.annotation:jsr250-api:1.0'
52
+ }
53
+ }
54
+
55
+ afterEvaluate {
56
+ android.libraryVariants.all { variant ->
57
+ def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
58
+ task.description = "Create jar artifact for ${variant.name}"
59
+ task.dependsOn variant.javaCompile
60
+ task.from variant.javaCompile.destinationDir
61
+ task.destinationDir = project.file("${project.buildDir}/outputs/jar")
62
+ task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
63
+ artifacts.add('archives', task);
64
+ }
65
+ }
66
+
67
+ task sourcesJar(type: Jar) {
68
+ from android.sourceSets.main.java.srcDirs
69
+ classifier = 'sources'
70
+ }
71
+
72
+ artifacts {
73
+ archives sourcesJar
74
+ }
75
+
76
+ } else {
77
+
78
+ apply plugin: 'java'
79
+ apply plugin: 'maven'
80
+
81
+ sourceCompatibility = JavaVersion.VERSION_1_7
82
+ targetCompatibility = JavaVersion.VERSION_1_7
83
+
84
+ install {
85
+ repositories.mavenInstaller {
86
+ pom.artifactId = 'api'
87
+ }
88
+ }
89
+
90
+ task execute(type:JavaExec) {
91
+ main = System.getProperty('mainClass')
92
+ classpath = sourceSets.main.runtimeClasspath
93
+ }
94
+ }
95
+
96
+ dependencies {
97
+ compile 'com.google.firebase:firebase-core:11.2.2'
98
+ compile 'com.google.firebase:firebase-database:11.2.2'
99
+ testCompile 'junit:junit:4.12'
100
+ }
@@ -0,0 +1,17 @@
1
+ lazy val root = (project in file(".")).
2
+ settings(
3
+ organization := "<%=@group%>",
4
+ name := "<%=@artifact%>",
5
+ version := "<%=@version%>",
6
+ scalaVersion := "2.11.4",
7
+ scalacOptions ++= Seq("-feature"),
8
+ javacOptions in compile ++= Seq("-Xlint:deprecation"),
9
+ publishArtifact in (Compile, packageDoc) := false,
10
+ resolvers += Resolver.mavenLocal,
11
+ libraryDependencies ++= Seq(
12
+ "com.google.firebase" % "firebase-core" % "11.2.2"
13
+ "com.google.firebase" % "firebase-database" % "11.2.2"
14
+ "junit" % "junit" % "4.12" % "test",
15
+ "com.novocode" % "junit-interface" % "0.10" % "test"
16
+ )
17
+ )
@@ -0,0 +1,6 @@
1
+ #Tue May 17 23:08:05 CST 2016
2
+ distributionBase=GRADLE_USER_HOME
3
+ distributionPath=wrapper/dists
4
+ zipStoreBase=GRADLE_USER_HOME
5
+ zipStorePath=wrapper/dists
6
+ distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-bin.zip
@@ -0,0 +1,2 @@
1
+ # Uncomment to build for Android
2
+ #target = android