Skip to content

Commit 779e34a

Browse files
authored
Merge pull request #46 from Archinamon/patch-improvements
Small improvements
2 parents a3be577 + 9e1da26 commit 779e34a

File tree

7 files changed

+67
-34
lines changed

7 files changed

+67
-34
lines changed

AspectJ-gradle/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ dependencies {
3131
compile "org.aspectj:aspectjtools:$aspectjVersion"
3232

3333
testCompile 'junit:junit:4.10'
34-
testCompile 'org.easytesting:fest-assert-core:2.0M10'
34+
testCompile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
35+
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
3536
}
3637

3738
group = 'com.archinamon'
38-
version = '3.0.1'
39+
version = '3.0.2'
3940

4041
// local archive :: debug mode
4142
uploadArchives {

AspectJ-gradle/src/main/kotlin/com/archinamon/AspectJExtension.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ open class AspectJExtension {
66

77
open var includeAllJars = false
88
open var includeJar = mutableSetOf<String>()
9+
open var extendClasspath = true
910

1011
open var includeAspectsFromJar = mutableSetOf<String>()
1112
open var ajcArgs = mutableSetOf<String>()

AspectJ-gradle/src/main/kotlin/com/archinamon/plugin/PluginSetup.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ import org.gradle.api.Project
1616
import org.gradle.api.plugins.PluginContainer
1717

1818
internal fun configProject(project: Project, config: AndroidConfig, settings: AspectJExtension) {
19-
project.repositories.mavenCentral()
20-
project.dependencies.add("compile", "org.aspectj:aspectjrt:${settings.ajc}")
19+
if (settings.extendClasspath) {
20+
project.repositories.mavenCentral()
21+
project.dependencies.add("compile", "org.aspectj:aspectjrt:${settings.ajc}")
22+
}
23+
2124
project.afterEvaluate {
2225
prepareVariant(config)
2326
configureCompiler(project, config)

AspectJ-gradle/src/test/groovy/com/archinamon/AndroidAspectJTest.groovy

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.archinamon
2+
3+
import org.gradle.api.GradleException
4+
import org.gradle.testfixtures.ProjectBuilder
5+
import org.junit.Test
6+
7+
/**
8+
* TODO: Add description
9+
*
10+
* @author archinamon on 11/04/17.
11+
*/
12+
class AndroidPluginTest {
13+
14+
@Test
15+
fun detectAppPlugin() {
16+
val project = ProjectBuilder.builder().build()
17+
project.apply(mapOf(Pair("plugin", "com.android.application")))
18+
project.apply(mapOf(Pair("plugin", "com.archinamon.aspectj")))
19+
}
20+
21+
@Test
22+
fun detectAppExtPlugin() {
23+
val project = ProjectBuilder.builder().build()
24+
project.apply(mapOf(Pair("plugin", "com.android.application")))
25+
project.apply(mapOf(Pair("plugin", "com.archinamon.aspectj-ext")))
26+
}
27+
28+
@Test
29+
fun detectLibPlugin() {
30+
val project = ProjectBuilder.builder().build()
31+
project.apply(mapOf(Pair("plugin", "com.android.library")))
32+
project.apply(mapOf(Pair("plugin", "com.archinamon.aspectj")))
33+
}
34+
35+
@Test
36+
fun detectLibExtPlugin() {
37+
val project = ProjectBuilder.builder().build()
38+
project.apply(mapOf(Pair("plugin", "com.android.library")))
39+
project.apply(mapOf(Pair("plugin", "com.archinamon.aspectj-ext")))
40+
}
41+
42+
@Test(expected = GradleException::class)
43+
fun failsWithoutAndroidPlugin() {
44+
val project = ProjectBuilder.builder().build()
45+
project.apply(mapOf(Pair("plugin", "com.archinamon.aspectj")))
46+
}
47+
48+
@Test(expected = GradleException::class)
49+
fun failsExtWithoutAndroidPlugin() {
50+
val project = ProjectBuilder.builder().build()
51+
project.apply(mapOf(Pair("plugin", "com.archinamon.aspectj-ext")))
52+
}
53+
}

AspectJ-gradle/src/test/kotlin/com/archinamon/utils/AarExploringTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import org.junit.rules.TemporaryFolder
66
import java.io.File
77

88
class AarExploringTest {
9+
910
@Rule
1011
@JvmField
1112
val folder = TemporaryFolder()
@@ -14,5 +15,4 @@ class AarExploringTest {
1415
fun noNPEIfFileNotExist() {
1516
findPackageNameIfAar(File("/build-cache/this/file/not/exist"))
1617
}
17-
1818
}

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Supports writing code with AspectJ-lang in `.aj` files and in java-annotation st
66
Full support of Android product flavors and build types.
77
Support Kotlin, Groovy, Scala and any other languages that compiles into java bytecode.
88

9-
Actual version: `com.archinamon:android-gradle-aspectj:3.0.0`.
9+
Actual version: `com.archinamon:android-gradle-aspectj:3.0.2`.
1010
<br />
1111
Friendly with <a href="https://zeroturnaround.com/software/jrebel-for-android/" target="_blank">jRebel for Android</a>!
1212

@@ -48,7 +48,7 @@ Don't forget to add `mavenCentral()` due to some dependencies inside AspectJ-gra
4848

4949
Add the plugin to your `buildscript`'s `dependencies` section:
5050
```groovy
51-
classpath 'com.github.Archinamon:GradleAspectJ-Android:3.0.0'
51+
classpath 'com.github.Archinamon:GradleAspectJ-Android:3.0.2'
5252
```
5353

5454
Apply the `aspectj` plugin:
@@ -91,6 +91,7 @@ aspectj {
9191
/* @see Ext plugin config **/
9292
includeAllJars false
9393
includeJar 'design', 'support-v4', 'dagger'
94+
extendClasspath true
9495
9596
includeAspectsFromJar 'my-aj-logger-lib', 'any-other-libs-with-aspects'
9697
ajcArgs << '-referenceInfo' << '-warn:deprecation'
@@ -113,6 +114,7 @@ All the extension parameters are have default values (all of them are described
113114
So no need to define them manually.
114115

115116
- `ajc` Allows to define the aspectj runtime jar version manually (1.8.10 current)
117+
- `extendClasspath` Explicitly controls whether plugin should mutate the classpath with aspectj-runtime itself
116118

117119
- `includeAllJars` Explicitly include all available jar-files into -inpath to proceed by AJ-compiler
118120
- `includeJar` Name filter to include any jar/aar which name or path satisfies the filter

0 commit comments

Comments
 (0)