Skip to content

Commit

Permalink
[jack] add test project to ensure jack can compile. Fix bug that prev…
Browse files Browse the repository at this point in the history
…ented compilation.
  • Loading branch information
agrosner committed Mar 4, 2017
1 parent 4a946dc commit 26c1e1f
Show file tree
Hide file tree
Showing 17 changed files with 263 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -3,7 +3,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0-beta3'
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.2'
}
Expand Down
1 change: 1 addition & 0 deletions dbflow-jack-tests/.gitignore
@@ -0,0 +1 @@
/build
32 changes: 32 additions & 0 deletions dbflow-jack-tests/build.gradle
@@ -0,0 +1,32 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
applicationId "com.grosner.dbflow.jack.tests"
minSdkVersion 9
targetSdkVersion 25
versionCode 1
versionName "1.0"

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

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

dependencies {
annotationProcessor project("${dbflow_project_prefix}dbflow-processor")
compile project("${dbflow_project_prefix}dbflow-core")
compile project("${dbflow_project_prefix}dbflow")
}
25 changes: 25 additions & 0 deletions dbflow-jack-tests/proguard-rules.pro
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/andrewgrosner/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
5 changes: 5 additions & 0 deletions dbflow-jack-tests/src/main/AndroidManifest.xml
@@ -0,0 +1,5 @@
<manifest package="com.grosner.dbflow.jack.tests">

<application/>

</manifest>
@@ -0,0 +1,33 @@
package com.grosner.dbflow.jack.tests;

import com.raizlabs.android.dbflow.annotation.Column;
import com.raizlabs.android.dbflow.annotation.ForeignKey;
import com.raizlabs.android.dbflow.annotation.ForeignKeyReference;
import com.raizlabs.android.dbflow.annotation.PrimaryKey;
import com.raizlabs.android.dbflow.annotation.Table;
import com.raizlabs.android.dbflow.structure.BaseModel;

import java.util.Date;

/**
* Description:
*/
@Table(database = AppDatabase.class)
public class AModel extends BaseModel {

@Column
@PrimaryKey
String name;

@Column
long time;

@ForeignKey(references =
{@ForeignKeyReference(columnName = "otherModel",
foreignKeyColumnName = "name")})
OtherModel model;

@Column
Date date;

}
@@ -0,0 +1,22 @@
package com.grosner.dbflow.jack.tests;

import com.raizlabs.android.dbflow.annotation.Column;
import com.raizlabs.android.dbflow.annotation.ModelView;
import com.raizlabs.android.dbflow.annotation.ModelViewQuery;
import com.raizlabs.android.dbflow.sql.Query;
import com.raizlabs.android.dbflow.sql.language.Select;
import com.raizlabs.android.dbflow.structure.BaseModelView;

/**
* Description:
*/
@ModelView(database = AppDatabase.class)
public class AModelView extends BaseModelView {

@ModelViewQuery
public static final Query QUERY = new Select(AModel_Table.time)
.from(AModel.class).where(AModel_Table.time.greaterThan(0l));

@Column
long time;
}
@@ -0,0 +1,14 @@
package com.grosner.dbflow.jack.tests;

import com.raizlabs.android.dbflow.annotation.Database;

/**
* Description:
*/
@Database(name = AppDatabase.NAME, version = AppDatabase.VERSION, foreignKeyConstraintsEnforced = true)
public class AppDatabase {

public static final String NAME = "App";

public static final int VERSION = 1;
}
@@ -0,0 +1,43 @@
package com.grosner.dbflow.jack.tests;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import com.raizlabs.android.dbflow.config.FlowConfig;
import com.raizlabs.android.dbflow.config.FlowManager;


public class DemoActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_demo);

FlowManager.init(new FlowConfig.Builder(getApplicationContext()).build());
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
//getMenuInflater().inflate(R.menu.menu_demo, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
//if (id == R.id.action_settings) {
// return true;
//}

return super.onOptionsItemSelected(item);
}
}
@@ -0,0 +1,22 @@
package com.grosner.dbflow.jack.tests;

import com.raizlabs.android.dbflow.annotation.Migration;
import com.raizlabs.android.dbflow.sql.SQLiteType;
import com.raizlabs.android.dbflow.sql.migration.AlterTableMigration;

/**
* Description:
*/
@Migration(version = 2, database = AppDatabase.class)
public class Migration1 extends AlterTableMigration<AModel> {

public Migration1(Class<AModel> table) {
super(table);
}

@Override
public void onPreMigrate() {
addColumn(SQLiteType.TEXT, "myColumn");
addColumn(SQLiteType.REAL, "anotherColumn");
}
}
@@ -0,0 +1,16 @@
package com.grosner.dbflow.jack.tests;

import com.raizlabs.android.dbflow.annotation.Migration;
import com.raizlabs.android.dbflow.sql.migration.BaseMigration;
import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper;

/**
* Description:
*/
@Migration(version = 3, database = AppDatabase.class)
public class Migration2 extends BaseMigration {
@Override
public void migrate(DatabaseWrapper database) {

}
}
@@ -0,0 +1,17 @@
package com.grosner.dbflow.jack.tests;

import com.raizlabs.android.dbflow.annotation.Column;
import com.raizlabs.android.dbflow.annotation.PrimaryKey;
import com.raizlabs.android.dbflow.annotation.Table;
import com.raizlabs.android.dbflow.structure.BaseModel;

/**
* Description:
*/
@Table(name = "OtherModel", database = AppDatabase.class)
public class OtherModel extends BaseModel {

@Column
@PrimaryKey
String name;
}
@@ -0,0 +1,10 @@
package com.grosner.dbflow.jack.tests;

import com.raizlabs.android.dbflow.annotation.Database;

/**
* Description:
*/
@Database(version = 1, name = "SecondApp", foreignKeyConstraintsEnforced = true)
public class SecondAppDatabase {
}
@@ -0,0 +1,17 @@
package com.grosner.dbflow.jack.tests;

import com.raizlabs.android.dbflow.annotation.Column;
import com.raizlabs.android.dbflow.annotation.PrimaryKey;
import com.raizlabs.android.dbflow.annotation.Table;
import com.raizlabs.android.dbflow.structure.BaseModel;

/**
* Description:
*/
@Table(database = SecondAppDatabase.class)
public class SecondModel extends BaseModel {

@Column
@PrimaryKey
String name;
}
Expand Up @@ -34,7 +34,7 @@ abstract class BaseDefinition : TypeDefinition {
constructor(element: ExecutableElement, processorManager: ProcessorManager) {
this.manager = processorManager
this.element = element
packageName = manager.elements.getPackageOf(element).toString()
packageName = manager.elements.getPackageOf(element)?.qualifiedName?.toString()?: ""
elementName = element.simpleName.toString()

try {
Expand All @@ -55,7 +55,7 @@ abstract class BaseDefinition : TypeDefinition {
constructor(element: Element, processorManager: ProcessorManager) {
this.manager = processorManager
this.element = element
packageName = manager.elements.getPackageOf(element).toString()
packageName = manager.elements.getPackageOf(element)?.qualifiedName?.toString()?: ""
try {
val typeMirror: TypeMirror
if (element is ExecutableElement) {
Expand Down Expand Up @@ -89,7 +89,7 @@ abstract class BaseDefinition : TypeDefinition {
elementClassName = ClassName.get(typeElement)
elementTypeName = TypeName.get(element.asType())
elementName = element.simpleName.toString()
packageName = manager.elements.getPackageOf(element).toString()
packageName = manager.elements.getPackageOf(element)?.qualifiedName?.toString()?: ""
}

protected open fun getElementClassName(element: Element): ClassName? {
Expand Down
Expand Up @@ -30,7 +30,7 @@ public class Set<TModel> extends BaseQueriable<TModel> implements WhereBase<TMod
conditionGroup.setAllCommaSeparated(true);
}

/**
/**`
* Specifies a varg of conditions to append to this SET
*
* @param conditions The varg of conditions
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
@@ -1 +1 @@
include ':dbflow', ':dbflow-processor', ':dbflow-core', ':dbflow-sqlcipher', ':dbflow-tests', ':dbflow-kotlinextensions'
include ':dbflow', ':dbflow-processor', ':dbflow-core', ':dbflow-sqlcipher', ':dbflow-tests', ':dbflow-kotlinextensions', ':dbflow-jack-tests'

0 comments on commit 26c1e1f

Please sign in to comment.