samedi 28 mars 2015

Android Studio Gradle - JavaExec classpath configuration - Java Reflection - class access

Im currently working on an android project where i have to process .java-files to possibly generate another .java-files which should then be compiled and packed into the .apk-file.


Lets assume i have 2 files which will be processed by my library, FILE_A.java and FILE_B.java.


Now i need to access these files within my library via reflection, e.g. with:



Class.forName("com.test.entities.FILE_A");
Class.forName("com.test.entities.FILE_B");


The problem is that i'm not able to access the class files, i think because of the missing classpath configuration. Currently i use this task to call my .jar-file:



task (mytask, type: org.gradle.api.tasks.JavaExec) {
classpath(files('libs/myjar.jar'))
main('com.test.TestMain')
}

preBuild.dependsOn mytask


I found some ressources on the web, but they all don't work.


I tried to add the following to the classpath:


sourceSets.main.runtimeClasspath (main is unknown) android.sourceSets.main.runtimeClasspath (runtimeClasspath is unkown).


So how can i access the class files in my library?






Aucun commentaire:

Enregistrer un commentaire