Other Support for Eclipse development tools will end this year.

corwin42

Expert
Licensed User

corwin42

Expert
Licensed User
Maybe its time to learn how to make libs in Android Studio.
As long as there is quickfix and auto complete should be fine.
Will the B4A Doclet work with Android Studio to create the libraries XML files? I think I will have to make some tests.

B4A doesn't use these features.
Ok, then I hope B4A is not affected by the end of the eclipse support for some time. Thats good news.

The question is if it is possible to create libraries in Android Studio as simple as with Eclipse.
 

cimperia

Active Member
Licensed User
I have been using Android Studio and it's possible to extract jar files (out of aar) and generate the correct xml file using B4A DOCLET. Here the code I used for generating the xml file, it's far from being perfect, but it works (in my environment) and could give you guys a headstart. It won't work as is as it has some dependencies on creating a jar etc... but the interesting bit is how to set the doclet options to generate the xml.

B4X:
//------------------------ JAVADOC Processing ------------------------------------------------------
configurations {
  BADoclet
}

dependencies {
  def BALibs = "C:/Program Files (x86)/Anywhere Software/Basic4android/Libraries/"

  BADoclet (fileTree(dir: "$BALibs",includes: ["**/Core.jar", "**/B4AShared.jar"]))
  BADoclet (fileTree(dir: "../build/libs/RangeSeekBar.jar"))
}

task javadoc(type: Javadoc, dependsOn: [makeJars] ) {
  def docXML = file("../javadoc/RangeSeekBar.xml")
  def BADocletPath = file("C:/Users/Claude/Desktop/SimpleLibraryCompiler/Doclet/")
  def javadocDir = file("../javadoc/")

  doFirst {
     if (file(docXML).exists()) {
     docXML.delete()
     println("Deleted doc file: " + docXML.name)
    }
  }

  source = android.sourceSets.main.java.srcDirs
  classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
  classpath += configurations.BADoclet

  destinationDir = javadocDir
  println("Destination Dir:" + destinationDir)
  options.doclet("BADoclet")
  options.docletpath = BADocletPath.listFiles().asType(List)
  options.addStringOption("B4atarget", "$docXML")
  options.addStringOption("B4aignore", "com.yahoo")
  options.setMemberLevel(JavadocMemberLevel.PUBLIC)

  doLast {
    def s = docXML.text.replaceAll("<type>T</type>","<type>double</type>")
    s = s.replaceAll("<version>1.0</version>","<version>1.01</version>")
    docXML.text = s

    copy {
      from docXML
      into BASharedLibrary
    }

    copy {
      from outJar
      into BASharedLibrary
    }

    println ("**** Remember to refresh your libraries ****")
  }

  failOnError true
}
 
Last edited:

thedesolatesoul

Expert
Licensed User
This is the Gradle script?
Pretty insane you got this to work, thanks a lot man.
The doLast part seems to be doing some weird hack at the end, but still this is pretty cool.
It seems the idea is to setup the 'options' object which is doing everything.
I'll try it I havent really touched gradle but it looks extremely cool in what it can do.
 

cimperia

Active Member
Licensed User
This is the Gradle script?
Pretty insane you got this to work, thanks a lot man.
The doLast part seems to be doing some weird hack at the end, but still this is pretty cool.
It seems the idea is to setup the 'options' object which is doing everything.
I'll try it I havent really touched gradle but it looks extremely cool in what it can do.
The 3 first lines of the doLast are just some editing of the XML files that I needed to do and was really specific to that particular project. I should have removed them from the posted code.

The 2 copy commands in doLast, copy the xml and jar files to my BA4 shared library

Gradle is very powerful once you know how to use it, but I hasten to add that I am no expert as I've been learning it by reading the doc :)
 
Last edited:

thedesolatesoul

Expert
Licensed User
Gradle is very powerful once you know how to use it, but I hasten to add that I am no expert as I've been learning it by reading the doc :)
Well that is the best way to learn it. And currently you seem to be the only expert about it here on the forums. From what I'm seeing I'll throw out my batch files and use Gradle.
 

lonleystar

Well-Known Member
Licensed User
I have been using Android Studio and it's possible to extract jar files (out of aar) and generate the correct xml file using B4A DOCLET. Here the code I used for generating the xml file, it's far from being perfect, but it works (in my environment) and could give you guys a headstart. It won't work as is as it has some dependencies on creating a jar etc... but the interesting bit is how to set the doclet options to generate the xml.

B4X:
//------------------------ JAVADOC Processing ------------------------------------------------------
configurations {
  BADoclet
}

dependencies {
  def BALibs = "C:/Program Files (x86)/Anywhere Software/Basic4android/Libraries/"

  BADoclet (fileTree(dir: "$BALibs",includes: ["**/Core.jar", "**/B4AShared.jar"]))
  BADoclet (fileTree(dir: "../build/libs/RangeSeekBar.jar"))
}

task javadoc(type: Javadoc, dependsOn: [makeJars] ) {
  def docXML = file("../javadoc/RangeSeekBar.xml")
  def BADocletPath = file("C:/Users/Claude/Desktop/SimpleLibraryCompiler/Doclet/")
  def javadocDir = file("../javadoc/")

  doFirst {
     if (file(docXML).exists()) {
     docXML.delete()
     println("Deleted doc file: " + docXML.name)
    }
  }

  source = android.sourceSets.main.java.srcDirs
  classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
  classpath += configurations.BADoclet

  destinationDir = javadocDir
  println("Destination Dir:" + destinationDir)
  options.doclet("BADoclet")
  options.docletpath = BADocletPath.listFiles().asType(List)
  options.addStringOption("B4atarget", "$docXML")
  options.addStringOption("B4aignore", "com.yahoo")
  options.setMemberLevel(JavadocMemberLevel.PUBLIC)

  doLast {
    def s = docXML.text.replaceAll("<type>T</type>","<type>double</type>")
    s = s.replaceAll("<version>1.0</version>","<version>1.01</version>")
    docXML.text = s

    copy {
      from docXML
      into BASharedLibrary
    }

    copy {
      from outJar
      into BASharedLibrary
    }

    println ("**** Remember to refresh your libraries ****")
  }

  failOnError true
}

Hi I tried with this code but I get an error [
task javadoc(type: Javadoc, dependsOn: [makeJars] )] some help?
 
Top