forked from HujiangTechnology/AspectJX-Demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a28c62
commit 7364205
Showing
61 changed files
with
5,645 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,6 @@ proguard/ | |
|
||
# Android Studio captures folder | ||
captures/ | ||
|
||
*.iml | ||
.idea |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,39 @@ | ||
# AspectJ-Demo | ||
[gradle_plugin_android_aspectjx]:https://github.com/HujiangTechnology/gradle_plugin_android_aspectjx | ||
|
||
gradle_plugin_android_aspectjx | ||
============================== | ||
|
||
一个[gradle_plugin_android_aspectjx]插件的应用示例 | ||
|
||
|
||
示例包括kotlin代码,AOP代码,AOP代码可以放在app项目里面,也可以放在library项目里面以aar的方式依赖 | ||
|
||
AspectJ相关内容可以参考如下引用: | ||
|
||
[AspectJ官网](https://eclipse.org/aspectj/) | ||
|
||
[AspectJ Programming Guide](https://eclipse.org/aspectj/doc/released/progguide/index.html) | ||
|
||
[AspectJ Development Environment Guide](https://eclipse.org/aspectj/doc/released/devguide/index.html) | ||
|
||
[AspectJ NoteBook](https://eclipse.org/aspectj/doc/released/adk15notebook/index.html) | ||
|
||
|
||
License | ||
------- | ||
|
||
``` | ||
Copyright 2016 hujiang, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License.gradle_plugin_android_aspectjx | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,278 @@ | ||
import com.android.build.api.transform.Context | ||
import com.android.build.api.transform.DirectoryInput | ||
import com.android.build.api.transform.Format | ||
import com.android.build.api.transform.JarInput | ||
import com.android.build.api.transform.QualifiedContent | ||
import com.android.build.api.transform.Transform | ||
import com.android.build.api.transform.TransformException | ||
import com.android.build.api.transform.TransformInput | ||
import com.android.build.api.transform.TransformOutputProvider | ||
import com.android.build.gradle.internal.TaskContainerAdaptor | ||
import com.android.build.gradle.internal.TaskFactory | ||
import com.android.build.gradle.internal.pipeline.TransformManager | ||
import com.android.build.gradle.internal.variant.BaseVariantData | ||
import com.android.build.gradle.internal.variant.BaseVariantOutputData | ||
import com.google.common.collect.ImmutableSet | ||
import com.google.common.collect.Lists | ||
import org.apache.commons.io.FileUtils | ||
|
||
apply plugin: 'com.android.application' | ||
apply plugin: 'kotlin-android' | ||
apply plugin: 'android-aspectjx' | ||
|
||
android { | ||
compileSdkVersion 22 | ||
buildToolsVersion "22.0.0" | ||
|
||
defaultConfig { | ||
applicationId "com.hujiang.hujiangsdk.demo" | ||
minSdkVersion 14 | ||
targetSdkVersion 22 | ||
versionCode 1 | ||
versionName "1.0" | ||
multiDexEnabled true | ||
} | ||
|
||
buildTypes { | ||
release { | ||
zipAlignEnabled true | ||
shrinkResources false | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
sourceSets { | ||
main.java.srcDirs += 'src/main/kotlin' | ||
} | ||
|
||
lintOptions { | ||
quiet true | ||
abortOnError false | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = "1.7" | ||
targetCompatibility = "1.7" | ||
} | ||
|
||
// registerTransform(new AspectTransform(project)) | ||
// registerTransform(new HelloTransform()) | ||
} | ||
|
||
//afterEvaluate { | ||
// android.applicationVariants.each { variant -> | ||
// def dx = tasks.findByName("dex${variant.name.capitalize()}") | ||
// def hello = "hello${variant.name.capitalize()}" | ||
// task(hello) << { | ||
// println "hello" | ||
// } | ||
// tasks.findByName(hello).dependsOn dx.taskDependencies.getDependencies(dx) | ||
// dx.dependsOn tasks.findByName(hello) | ||
// } | ||
//} | ||
|
||
//project.afterEvaluate { | ||
// tasks.getByName("preDebugBuild") { | ||
// it.doFirst { | ||
// | ||
// } | ||
// } | ||
// tasks.getByName("preReleaseBuild") { | ||
// it.doFirst { | ||
// | ||
// } | ||
// } | ||
|
||
// project.android.applicationVariants.each { variant -> | ||
|
||
// def sourceSets = new ArrayList() | ||
// variant.variantData.extraGeneratedSourceFolders.each { | ||
// sourceSets << it | ||
// println "${it.path}:${it.exists()}" | ||
// } | ||
// variant.variantData.javaSources.each { | ||
// if (it instanceof File) { | ||
// sourceSets << it | ||
// println "${it.path}:${it.exists()}" | ||
// } else { | ||
// it.asFileTrees.each { | ||
// | ||
// sourceSets << it.dir | ||
// println "${it.dir.path}:${it.dir.exists()}" | ||
// } | ||
// } | ||
// } | ||
// | ||
// println "++++++++++${sourceSets.join(File.pathSeparator)}" | ||
// | ||
// println "variant.name.capitalize::${variant.name.capitalize()}" | ||
// variant | ||
// def transformJarTask = project.tasks.findByName("transformClassesWithJarMergingFor${variant.name.capitalize()}") | ||
// if (transformJarTask) { | ||
// println "transformJarMergin =====>${variant.name.capitalize()}" | ||
// | ||
// transformJarTask.inputs.files.files.each { File file -> | ||
// println "transformJarMergin inputs=====>${file.absolutePath}" | ||
// } | ||
// | ||
// transformJarTask.outputs.files.files.each { File file -> | ||
// println "transformJarMergin outputs=====>${file.absolutePath}" | ||
// } | ||
// } | ||
// | ||
// def transformAspectTask = project.tasks.findByName("transformClassesWithAspectTransformFor${variant.name.capitalize()}") | ||
// if (transformAspectTask) { | ||
// println "transformAspect========>${variant.name.capitalize()}" | ||
// transformAspectTask.inputs.files.files.each { File file -> | ||
// println "transformAspect inputs=====>${file.absolutePath}" | ||
// } | ||
// | ||
// transformAspectTask.outputs.files.files.each { File file -> | ||
// println("transformAspect output=====>${file.absolutePath}") | ||
// } | ||
// } | ||
// | ||
// def transformDexTask = project.tasks.findByName("transformClassesWithDexFor${variant.name.capitalize()}") | ||
// if (transformDexTask) { | ||
// println("transformDex======>${variant.name.capitalize()}") | ||
// transformDexTask.inputs.files.files.each { File file -> | ||
// println("transformDex inputs=====>${file.absolutePath}") | ||
// } | ||
// transformDexTask.outputs.files.files.each { File file -> | ||
// println("transformDex outouts=====>${file.absolutePath}") | ||
// } | ||
// } | ||
// | ||
// def proguardTask = project.tasks.findByName("transformClassesAndResourcesWithProguardFor${variant.name.capitalize()}") | ||
// if (proguardTask) { | ||
// println "proguardTransform======>${variant.name.capitalize()}" | ||
// | ||
// proguardTask.inputs.files.files.each { File file-> | ||
// println "proguardTransform inputs=======>${file.absolutePath}" | ||
// } | ||
// | ||
// proguardTask.outputs.files.files.each { File file-> | ||
// println "proguardTransform outputs=======>${file.absolutePath}" | ||
// } | ||
// } | ||
|
||
// def transformHelloTask = project.tasks.findByName("transformClassesWithHelloTransformFor${variant.name.capitalize()}") | ||
// if (transformHelloTask) { | ||
// println "transformHello========>${variant.name.capitalize()}" | ||
// transformHelloTask.inputs.files.files.each { File file -> | ||
// println "transformHello inputs=====>${file.absolutePath}" | ||
// } | ||
// | ||
// transformHelloTask.outputs.files.files.each { File file -> | ||
// println("transformHello output=====>${file.absolutePath}") | ||
// } | ||
// } | ||
// } | ||
//} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
testCompile 'junit:junit:4.12' | ||
compile 'com.android.support:appcompat-v7:22.0.0' | ||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | ||
// compile 'com.hujiang.account:account:1.2.3' | ||
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3' | ||
// compile 'com.hujiang.share:sharesdk:1.2.2' | ||
// compile 'com.hujiang.restvolley:restvolley:1.0.1' | ||
// compile 'com.android.support:multidex:1.0.1' | ||
// compile 'com.taobao.android:dexposed:0.1.8' | ||
compile project(':library') | ||
// compile 'com.hujiang.common:commonlib:1.0.8' | ||
// compile 'com.hujiang.hujiangsdk:hujiangsdk:0.0.1-SNAPSHOT' | ||
// compile 'com.android.tools.build:transform-api:2.0.+' | ||
} | ||
|
||
//class AspectTransform extends Transform { | ||
// | ||
// Project p | ||
// public AspectTransform(Project project) { | ||
// p = project | ||
// } | ||
// | ||
// @Override | ||
// String getName() { | ||
// return "AspectTransform" | ||
// } | ||
// | ||
// @Override | ||
// Set<QualifiedContent.ContentType> getInputTypes() { | ||
// return ImmutableSet.<QualifiedContent.ContentType>of(QualifiedContent.DefaultContentType.CLASSES) | ||
// } | ||
// | ||
// @Override | ||
// Set<QualifiedContent.Scope> getScopes() { | ||
// return ImmutableSet.<QualifiedContent.Scope>of(QualifiedContent.Scope.PROJECT, QualifiedContent.Scope.PROJECT_LOCAL_DEPS | ||
// , QualifiedContent.Scope.EXTERNAL_LIBRARIES, com.android.build.api.transform.QualifiedContent.Scope.SUB_PROJECTS | ||
// , QualifiedContent.Scope.SUB_PROJECTS_LOCAL_DEPS) | ||
// } | ||
// | ||
// @Override | ||
// boolean isIncremental() { | ||
// return false | ||
// } | ||
// | ||
// @Override | ||
// Set<QualifiedContent.ContentType> getOutputTypes() { | ||
// return super.getOutputTypes() | ||
// } | ||
// | ||
// @Override | ||
// void transform(Context context, Collection<TransformInput> inputs, Collection<TransformInput> referencedInputs, TransformOutputProvider outputProvider, boolean isIncremental) throws IOException, TransformException, InterruptedException { | ||
// | ||
//// println "********************project.tasks***********" | ||
//// List<Task> ts = p.tasks.asList() | ||
//// for (Task task : ts) { | ||
//// println "task-name:" + task.name | ||
//// } | ||
//// | ||
//// println "****************project.defaultTasks**************" | ||
//// List<String> dts = p.defaultTasks | ||
//// for (String t : dts) { | ||
//// println "default Task:" + t | ||
//// } | ||
//// | ||
//// println "*******************endddddddddd********************" | ||
// | ||
// println "*******************************************transform start********************************" | ||
// for (TransformInput transformInput : inputs) { | ||
// for (DirectoryInput directoryInput : transformInput.directoryInputs) { | ||
// println "dir file*********" + directoryInput.file.absolutePath | ||
// | ||
// File dest = outputProvider.getContentLocation(directoryInput.name, directoryInput.contentTypes, directoryInput.scopes, Format.DIRECTORY) | ||
// | ||
// println "dest:" + dest.absolutePath | ||
// FileUtils.copyDirectory(directoryInput.getFile(), dest) | ||
// | ||
// def sourceRoots = [] | ||
// sourceRoots << directoryInput.file | ||
// sourceRoots << dest | ||
// | ||
// println "fileCollection:" + sourceRoots.join(File.pathSeparator) | ||
// } | ||
// | ||
// for (JarInput jarInput : transformInput.jarInputs) { | ||
// println jarInput.file.absolutePath | ||
// | ||
// String jarName = jarInput.name | ||
// if (jarName.endsWith(".jar")) { | ||
// jarName = jarName.substring(0, jarName.length() - 4) | ||
// } | ||
// | ||
// File dest = outputProvider.getContentLocation(jarName, jarInput.contentTypes, jarInput.scopes, Format.JAR) | ||
// println "dest:" + dest.absolutePath | ||
// FileUtils.copyFile(jarInput.file, dest) | ||
// } | ||
// | ||
//// final TaskFactory tasks = new TaskContainerAdaptor(project.getTasks()); | ||
//// List<BaseVariantData<? extends BaseVariantOutputData>> variantDataList = Lists.newArrayList(); | ||
//// TransformManager transformManager = variantScope.getTransformManager(); | ||
// } | ||
// | ||
// println "*******************transform end*******************" | ||
// } | ||
//} |
Oops, something went wrong.