Skip to content

Commit

Permalink
Refactor: new way to initialize apt classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
chenenyu committed Nov 10, 2021
1 parent e1d0365 commit 69cc877
Show file tree
Hide file tree
Showing 21 changed files with 400 additions and 541 deletions.
8 changes: 6 additions & 2 deletions Sample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
versionCode 1
versionName "1.0"
}

// viewBinding.enabled = true
buildFeatures {
viewBinding true
}
Expand All @@ -28,12 +28,16 @@ android {
checkReleaseBuilds false
abortOnError false
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:1.3.0"
implementation project(':module1')
implementation project(':module2')
testImplementation 'junit:junit:4.12'
}

This file was deleted.

7 changes: 6 additions & 1 deletion Sample/module1/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
versionCode 1
versionName "1.0"
}

// viewBinding.enabled = true
buildFeatures {
viewBinding true
}
Expand All @@ -31,6 +31,11 @@ android {
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
Expand Down
7 changes: 6 additions & 1 deletion Sample/module2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
versionCode 1
versionName "1.0"
}

// viewBinding.enabled = true
buildFeatures {
viewBinding true
}
Expand All @@ -31,6 +31,11 @@ android {
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
Expand Down
9 changes: 4 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
buildscript {
ext.kotlin_version = '1.5.20'
ext.kotlin_version = '1.5.31'
repositories {
// maven { url 'repo' }
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
if (Boolean.valueOf(applyRemotePlugin)) {
classpath "com.chenenyu.router:gradle-plugin:${PLUGIN_VERSION}"
Expand All @@ -26,9 +25,9 @@ task clean(type: Delete) {
}

ext {
compileSdkVersion = 29
compileSdkVersion = 30
minSdkVersion = 16
targetSdkVersion = 29
targetSdkVersion = 30
// compilerLoggable = false
// androidxVersion = "1.1.0"
}
8 changes: 5 additions & 3 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ if (!Boolean.valueOf(applyRemotePlugin)) {
}

dependencies {
compile gradleApi()
compile localGroovy()
compile 'com.android.tools.build:gradle:4.2.2'
implementation gradleApi()
implementation localGroovy()
implementation 'com.android.tools.build:gradle:4.0.0'
compileOnly 'com.android.tools:common:30.0.0'
compileOnly 'com.android.tools:repository:30.0.0'
}

sourceSets {
Expand Down
8 changes: 4 additions & 4 deletions compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.squareup:javapoet:1.13.0'
// compile project(':annotation')
compile "com.chenenyu.router:annotation:${ANNOTATION_VERSION}"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.squareup:javapoet:1.13.0'
// implementation project(':annotation')
implementation "com.chenenyu.router:annotation:${ANNOTATION_VERSION}"
}

ext {
Expand Down
4 changes: 3 additions & 1 deletion gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ repositories {
dependencies {
implementation gradleApi()
implementation localGroovy()
compileOnly 'com.android.tools.build:gradle:4.2.2'
compileOnly 'com.android.tools.build:gradle:4.0.0'
compileOnly 'com.android.tools:common:30.0.0'
compileOnly 'com.android.tools:repository:30.0.0'
}

ext {
Expand Down
145 changes: 0 additions & 145 deletions gradle-plugin/src/main/groovy/com/chenenyu/router/Knife.groovy

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.chenenyu.router

//import groovy.xml.XmlParser // Added in gradle7.0(groovy 3.0.0)
import groovy.xml.XmlUtil
import org.gradle.api.Project

class ManifestTransformer {
static void transform(Project project, File input, File output) {
Node xml = new XmlParser().parse(input)
Node applicationNode = xml.get('application')[0]
applicationNode.appendNode('meta-data', ['android:name': project.name, 'android:value': 'com.chenenyu.router.moduleName'])
def result = XmlUtil.serialize(xml)
output.write(result)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.chenenyu.router

import org.gradle.api.DefaultTask
import org.gradle.api.Project
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction

import javax.inject.Inject

abstract class ManifestTransformerTask extends DefaultTask {
private Project project

@Inject
ManifestTransformerTask(Project project) {
this.project = project
}

@InputFile
abstract RegularFileProperty getMergedManifest()

@OutputFile
abstract RegularFileProperty getUpdatedManifest()

@TaskAction
void taskAction() {
File input = getMergedManifest().get().asFile
File output = getUpdatedManifest().get().asFile
// project.logger.warn("input: ${input.absolutePath}")
// project.logger.warn("output: ${output.absolutePath}")

ManifestTransformer.transform(project, input, output)
}
}
14 changes: 0 additions & 14 deletions gradle-plugin/src/main/groovy/com/chenenyu/router/Record.groovy

This file was deleted.

Loading

0 comments on commit 69cc877

Please sign in to comment.