Skip to content

Commit

Permalink
feat: configure jitpack release
Browse files Browse the repository at this point in the history
  • Loading branch information
JailedBird committed Mar 9, 2023
1 parent 2a01490 commit eef425c
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ dependencies {
implementation("com.squareup:kotlinpoet-metadata:1.11.0")
}

//apply from: rootProject.file('gradle/publish.gradle')
apply from: rootProject.file("gradle/maven-publish.gradle")
3 changes: 3 additions & 0 deletions compiler/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GROUP_ID=com.github.JailedBird
ARTIFACT_ID=ArouterKspCompiler
VERSION=0.0.1-beta01
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.google.devtools.ksp.symbol.KSPropertyDeclaration
* */
internal fun KSPropertyDeclaration.typeExchange(): Int {
val type = this.type.resolve()
@Suppress("KotlinConstantConditions")
return when (type.declaration.qualifiedName?.asString()) {
Consts.KBYTE -> TypeKind.BYTE.ordinal
Consts.KSHORT -> TypeKind.SHORT.ordinal
Expand Down
75 changes: 75 additions & 0 deletions gradle/maven-publish.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
apply plugin: "maven-publish"
/**
* Reference doc:
* https://docs.gradle.org/current/dsl/org.gradle.api.publish.maven.MavenPublication.html#org.gradle.api.publish.maven.MavenPublication:artifact(java.lang.Object)
* https://docs.gradle.org/current/userguide/publishing_setup.html
* */
afterEvaluate { project ->
if (plugins.hasPlugin('com.android.application') || plugins.hasPlugin('com.android.library')) {
/** Android doc*/
task androidJavadocs(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.source
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
/** Android doc jar*/
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
getArchiveClassifier().convention('javadoc')
getArchiveClassifier().set('javadoc')
from androidJavadocs.destinationDir
}
/** Android source jar*/
task androidSourcesJar(type: Jar) {
getArchiveClassifier().convention('sources')
getArchiveClassifier().set('sources')
from android.sourceSets.main.java.source
}
} else if (plugins.hasPlugin("java")) {
/** Java source jar*/
task sourcesJar(type: Jar, dependsOn: classes) {
getArchiveClassifier().convention('sources')
getArchiveClassifier().set('sources')
from sourceSets.main.allSource
}
/** Java doc jar*/
task javadocJar(type: Jar, dependsOn: javadoc) {
getArchiveClassifier().convention('javadoc')
getArchiveClassifier().set('javadoc')
from javadoc.destinationDir
}
}

if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
/** publish library with doc and source code */
publishing {
publications {
maven(MavenPublication) {
groupId = GROUP_ID
artifactId = ARTIFACT_ID
version = VERSION
afterEvaluate {
if (plugins.hasPlugin('com.android.application') || plugins.hasPlugin('com.android.library')) {
from components.release
} else if (plugins.hasPlugin("java")) {
from components.java
}
}
if (plugins.hasPlugin('com.android.application') || plugins.hasPlugin('com.android.library')) {
artifact androidSourcesJar
artifact androidJavadocsJar
} else if (plugins.hasPlugin("java")) {
artifact sourcesJar
artifact javadocJar
}

}
}
}

}
3 changes: 3 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://github.com/jitpack/jitpack.io/issues/4474
jdk:
- openjdk11

0 comments on commit eef425c

Please sign in to comment.