X-Git-Url: http://nitlanguage.org diff --git a/src/android_annotations.nit b/src/android_annotations.nit index 680cab7..0ae0078 100644 --- a/src/android_annotations.nit +++ b/src/android_annotations.nit @@ -35,6 +35,15 @@ class AndroidProject # Version of the Android application and APK var version: nullable String = null + # Numerical version code of the Android application and APK + var version_code: Int = 0 + + # Custom lines to add to the AndroidManifest.xml in the node + var manifest_lines = new Array[String] + + # Custom lines to add to the AndroidManifest.xml in the node + var manifest_application_lines = new Array[String] + redef fun to_s do return """ name: {{{name or else "null"}}} namespace: {{{java_package or else "null"}}} @@ -56,11 +65,37 @@ redef class ModelBuilder annot = priority_annotation_on_modules("java_package", mmodule) if annot != null then project.java_package = annot.arg_as_string(self) + var annots = collect_annotations_on_modules("android_manifest", mmodule) + for an in annots do project.manifest_lines.add an.arg_as_string(self) + + annots = collect_annotations_on_modules("android_manifest_application", mmodule) + for an in annots do project.manifest_application_lines.add an.arg_as_string(self) + + # Get the date and time (down to the minute) as string + var local_time = new Tm.localtime + var local_time_s = local_time.strftime("%y%m%d%H%M") + project.version_code = local_time_s.to_i + toolcontext.check_errors return project end + # Recursively collect all annotations by name in `mmodule` and its importations (direct and indirect) + private fun collect_annotations_on_modules(name: String, mmodule: MModule): Array[AAnnotation] + do + var annotations = new Array[AAnnotation] + for mmod in mmodule.in_importation.greaters do + if not mmodule2nmodule.keys.has(mmod) then continue + var amod = mmodule2nmodule[mmod] + var module_decl = amod.n_moduledecl + if module_decl == null then continue + var aas = module_decl.collect_annotations_by_name(name) + annotations.add_all aas + end + return annotations + end + # Get an annotation by name from `mmodule` and its super modules. Will recursively search # in imported module to find the "latest" declaration and detects priority conflicts. private fun priority_annotation_on_modules(name: String, mmodule: MModule): nullable AAnnotation