diff --git a/jimu-core/bintrayv1.gradle b/jimu-core/bintrayv1.gradle new file mode 100644 index 0000000..001fc2b --- /dev/null +++ b/jimu-core/bintrayv1.gradle @@ -0,0 +1,59 @@ +apply plugin: 'com.jfrog.bintray' + +version = libraryVersion + +if (project.hasProperty("android")) { // Android libraries + task sourcesJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.srcDirs + } + + task javadoc(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + } +} else { // Java libraries + task sourcesJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource + } +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives javadocJar + archives sourcesJar +} + +// Bintray +Properties properties = new Properties() +properties.load(project.rootProject.file('local.properties').newDataInputStream()) + +bintray { + user = properties.getProperty("bintray.user") + key = properties.getProperty("bintray.apikey") + + configurations = ['archives'] + pkg { + repo = bintrayRepo + name = bintrayName + desc = libraryDescription + websiteUrl = siteUrl + vcsUrl = gitUrl + licenses = allLicenses + publish = true + publicDownloadNumbers = true + version { + desc = libraryDescription + gpg { + sign = true //Determines whether to GPG sign the files. The default is false + passphrase = properties.getProperty("bintray.gpg.password") + //Optional. The passphrase for GPG signing' + } + } + } +} diff --git a/jimu-core/build-gradle/build.gradle b/jimu-core/build-gradle/build.gradle index 014ec21..4524671 100644 --- a/jimu-core/build-gradle/build.gradle +++ b/jimu-core/build-gradle/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'groovy' def MAVEN_LOCAL_PATH = uri('../../local_repo') def ARTIFACT_ID = 'build-gradle' -def VERSION_NAME = '1.2.1' +def VERSION_NAME = '1.2.5' def GROUP_ID = 'com.github.jimu' ext { @@ -17,8 +17,8 @@ ext { licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' allLicenses = ["Apache-2.0"] } -apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' -apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle' +apply from: '../installv1.gradle' +apply from: '../bintrayv1.gradle' dependencies { compile 'com.android.tools.build:gradle:2.3.2' diff --git a/jimu-core/build-gradle/src/main/groovy/com.dd.buildgradle/ComCodeTransform.groovy b/jimu-core/build-gradle/src/main/groovy/com.dd.buildgradle/ComCodeTransform.groovy index d0e9607..c708acb 100644 --- a/jimu-core/build-gradle/src/main/groovy/com.dd.buildgradle/ComCodeTransform.groovy +++ b/jimu-core/build-gradle/src/main/groovy/com.dd.buildgradle/ComCodeTransform.groovy @@ -41,10 +41,10 @@ class ComCodeTransform extends Transform { } } for (CtClass ctClass : applications) { - System.out.println("application is " + ctClass.getName()) + System.out.println("Application is " + ctClass.getName()) } for (CtClass ctClass : activators) { - System.out.println("applicationlike is " + ctClass.getName()) + System.out.println("ApplicationLike will be auto register: " + ctClass.getName()) } transformInvocation.inputs.each { TransformInput input -> @@ -67,6 +67,18 @@ class ComCodeTransform extends Transform { //对类型为“文件夹”的input进行遍历 input.directoryInputs.each { DirectoryInput directoryInput -> boolean isRegisterCompoAuto = project.extensions.combuild.isRegisterCompoAuto + + System.out.println(">>>") + System.out.println(">>>") + System.out.println(">>>") + System.out.println(">>>") + + System.out.println("check isRegisterCompoAuto: " + + directoryInput.file.getPath() + + " ; isRegisterCompoAuto:" + + isRegisterCompoAuto) + + if (isRegisterCompoAuto) { String fileName = directoryInput.file.absolutePath File dir = new File(fileName) @@ -83,6 +95,7 @@ class ComCodeTransform extends Transform { } } } + def dest = transformInvocation.outputProvider.getContentLocation(directoryInput.name, directoryInput.contentTypes, directoryInput.scopes, Format.DIRECTORY) @@ -108,15 +121,17 @@ class ComCodeTransform extends Transform { CtMethod attachBaseContextMethod = ctClassApplication.getDeclaredMethod("onCreate", null) attachBaseContextMethod.insertAfter(getAutoLoadComCode(activators)) } catch (CannotCompileException | NotFoundException e) { + + System.out.println("could not found onCreate in Application; " + e.toString()) + StringBuilder methodBody = new StringBuilder() methodBody.append("protected void onCreate() {") methodBody.append("super.onCreate();") - methodBody. - append(getAutoLoadComCode(activators)) + methodBody.append(getAutoLoadComCode(activators)) methodBody.append("}") ctClassApplication.addMethod(CtMethod.make(methodBody.toString(), ctClassApplication)) } catch (Exception e) { - + System.out.println("could not create onCreate() in Application; " + e.toString()) } ctClassApplication.writeFile(patch) ctClassApplication.detach() @@ -145,15 +160,24 @@ class ComCodeTransform extends Transform { return false } + /** + * check if the class is implement of IApplication and isRegisterCompoAuto + * @param ctClass target class to be checked + * @return true if impl& isRegisterCompoAuto + */ private boolean isActivator(CtClass ctClass) { try { for (CtClass ctClassInter : ctClass.getInterfaces()) { if ("com.luojilab.component.componentlib.applicationlike.IApplicationLike".equals(ctClassInter.name)) { - return true +// todo judge isRegisterCompoAuto + boolean hasManualNotation = ctClass.hasAnnotation(Class.forName("com.luojilab.component.componentlib.applicationlike.RegisterCompManual")) +// return true + System.out.println(">>>> " + ctClass + " manual register?" + hasManualNotation) + return !hasManualNotation } } } catch (Exception e) { - println "class not found exception class name: " + ctClass.getName() + println "isActivator got exception :" + ctClass.getName() + " ; " + e.toString() } return false diff --git a/jimu-core/build-gradle/src/main/groovy/com/luojilab/component/componentlib/applicationlike/RegisterCompManual.java b/jimu-core/build-gradle/src/main/groovy/com/luojilab/component/componentlib/applicationlike/RegisterCompManual.java new file mode 100644 index 0000000..64f69ab --- /dev/null +++ b/jimu-core/build-gradle/src/main/groovy/com/luojilab/component/componentlib/applicationlike/RegisterCompManual.java @@ -0,0 +1,17 @@ +package com.luojilab.component.componentlib.applicationlike; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + *

Package: com.dd.buildgradle.exten

+ *

Project: jimu-core

+ *

Classname: RegisterCompManual

+ *

Description: annotate the Applike with this annotation + * represent to register it manual. + * it will never auto register

+ * Created by leobert on 2018/5/10. + */ +@Retention(RetentionPolicy.CLASS) +public @interface RegisterCompManual { +} diff --git a/jimu-core/componentlib/build.gradle b/jimu-core/componentlib/build.gradle index 0ad3667..64a9a96 100644 --- a/jimu-core/componentlib/build.gradle +++ b/jimu-core/componentlib/build.gradle @@ -7,7 +7,7 @@ targetCompatibility = "1.7" def MAVEN_LOCAL_PATH = uri('../../local_repo') def ARTIFACT_ID = 'componentlib' -def VERSION_NAME = '1.3.1' +def VERSION_NAME = '1.3.2' def GROUP_ID = 'com.github.jimu' ext { @@ -57,8 +57,8 @@ dependencies { } -apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' -apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle' +apply from: '../installv1.gradle' +apply from: '../bintrayv1.gradle' uploadArchives() { repositories { diff --git a/jimu-core/componentlib/src/main/java/com/luojilab/component/componentlib/applicationlike/RegisterCompManual.java b/jimu-core/componentlib/src/main/java/com/luojilab/component/componentlib/applicationlike/RegisterCompManual.java new file mode 100644 index 0000000..64f69ab --- /dev/null +++ b/jimu-core/componentlib/src/main/java/com/luojilab/component/componentlib/applicationlike/RegisterCompManual.java @@ -0,0 +1,17 @@ +package com.luojilab.component.componentlib.applicationlike; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + *

Package: com.dd.buildgradle.exten

+ *

Project: jimu-core

+ *

Classname: RegisterCompManual

+ *

Description: annotate the Applike with this annotation + * represent to register it manual. + * it will never auto register

+ * Created by leobert on 2018/5/10. + */ +@Retention(RetentionPolicy.CLASS) +public @interface RegisterCompManual { +} diff --git a/jimu-core/installv1.gradle b/jimu-core/installv1.gradle new file mode 100644 index 0000000..0396115 --- /dev/null +++ b/jimu-core/installv1.gradle @@ -0,0 +1,42 @@ +apply plugin: 'com.github.dcendents.android-maven' + +group = publishedGroupId // Maven Group ID for the artifact + +install { + repositories.mavenInstaller { + // This generates POM.xml with proper parameters + pom { + project { + packaging 'aar' + groupId publishedGroupId + artifactId artifact + + // Add your description here + name libraryName + description libraryDescription + url siteUrl + + // Set your license + licenses { + license { + name licenseName + url licenseUrl + } + } + developers { + developer { + id developerId + name developerName + email developerEmail + } + } + scm { + connection gitUrl + developerConnection gitUrl + url siteUrl + + } + } + } + } +} diff --git a/jimu-core/router-anno-compiler/build.gradle b/jimu-core/router-anno-compiler/build.gradle index 4427451..4d93797 100644 --- a/jimu-core/router-anno-compiler/build.gradle +++ b/jimu-core/router-anno-compiler/build.gradle @@ -18,8 +18,8 @@ ext { allLicenses = ["Apache-2.0"] } -apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' -apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle' +apply from: '../installv1.gradle' +apply from: '../bintrayv1.gradle' dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') diff --git a/jimu-core/router-annotation/build.gradle b/jimu-core/router-annotation/build.gradle index c232a77..aa75a20 100644 --- a/jimu-core/router-annotation/build.gradle +++ b/jimu-core/router-annotation/build.gradle @@ -29,8 +29,8 @@ compileJava { targetCompatibility = '1.7' } -apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' -apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle' +apply from: '../installv1.gradle' +apply from: '../bintrayv1.gradle' uploadArchives() { repositories { diff --git a/jimu-sample-project/build.gradle b/jimu-sample-project/build.gradle index 8977d8e..62fb6e7 100644 --- a/jimu-sample-project/build.gradle +++ b/jimu-sample-project/build.gradle @@ -61,10 +61,10 @@ buildscript { ], jimu : [ - 'componentLib' : 'com.github.jimu:componentlib:1.3.1', + 'componentLib' : 'com.github.jimu:componentlib:1.3.2', 'router_anno' : 'com.github.jimu:router-annotation:1.0.1', 'router_anno_compiler': 'com.github.jimu:router-anno-compiler:1.0.1', - 'gradle_plugin' : 'com.github.jimu:build-gradle:1.2.1' + 'gradle_plugin' : 'com.github.jimu:build-gradle:1.2.5' ], gson : 'com.google.code.gson:gson:2.8.2', @@ -74,10 +74,6 @@ buildscript { repositories { jcenter() maven { url "https://jitpack.io" } - maven { - url 'https://maven.google.com/' - name 'Google' - } maven { url 'https://dl.bintray.com/leobert-lan-oss/maven/' } @@ -85,6 +81,10 @@ buildscript { url uri('../local_repo') name 'local-repo' } + maven { + url 'https://maven.google.com/' + name 'Google' + } } dependencies { classpath 'com.android.tools.build:gradle:2.3.3' @@ -105,12 +105,12 @@ allprojects { url 'https://dl.bintray.com/leobert-lan-oss/maven/' } maven { - url 'https://maven.google.com/' - name 'Google' + url uri('../../local_repo') + name 'local-repo' } maven { - url uri('../local_repo') - name 'local-repo' + url 'https://maven.google.com/' + name 'Google' } } } \ No newline at end of file diff --git a/jimu-sample-project/gradlew b/jimu-sample-project/gradlew old mode 100644 new mode 100755 diff --git a/jimu-sample-project/readercomponent/src/main/java/com/luojilab/reader/applike/ReaderAppLike.java b/jimu-sample-project/readercomponent/src/main/java/com/luojilab/reader/applike/ReaderAppLike.java index 84239af..e2d7a2d 100644 --- a/jimu-sample-project/readercomponent/src/main/java/com/luojilab/reader/applike/ReaderAppLike.java +++ b/jimu-sample-project/readercomponent/src/main/java/com/luojilab/reader/applike/ReaderAppLike.java @@ -1,6 +1,7 @@ package com.luojilab.reader.applike; import com.luojilab.component.componentlib.applicationlike.IApplicationLike; +import com.luojilab.component.componentlib.applicationlike.RegisterCompManual; import com.luojilab.component.componentlib.router.Router; import com.luojilab.component.componentlib.router.ui.UIRouter; import com.luojilab.componentservice.readerbook.ReadBookService; @@ -9,7 +10,7 @@ /** * Created by mrzhang on 2017/6/15. */ - +@RegisterCompManual public class ReaderAppLike implements IApplicationLike { Router router = Router.getInstance();