Files
2026-07-03 15:56:07 +08:00

191 lines
5.2 KiB
Groovy

/*
* Copyright 2015 AndroidPlot.com
*
* 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.
*/
plugins {
id 'com.android.library'
id 'com.dicedmelon.gradle.jacoco-android'
id 'maven-publish'
id 'signing'
}
class AttrMarkdown extends DefaultTask {
def inFile
def outFile
@TaskAction
def generate() {
def input = project.file(inFile)
def output = project.file(outFile)
if(output.exists()) {
output.delete()
}
output.parentFile.mkdirs()
input.text.findAll(/<!--\n?([\s\S]*?)\n?-->/) { match, g1 -> g1
if(!g1.startsWith("NODOC")) {
output.append(g1)
output.append "\n\n"
}
}
}
}
/**
* Generates xml attrs markdown docs. To run:
* at the command line from the project root dir type:
* ./gradlew generateAttrsMarkdown
*
* The generated doc will appear in / replace androidplot/docs/attrs.md
*/
task generateAttrsMarkdown(type: AttrMarkdown) {
inFile = { "src/main/res/values/attrs.xml"}
outFile = { "../docs/attrs.md" }
}
android {
compileSdkVersion theCompileSdkVersion
defaultConfig {
minSdkVersion theMinSdkVersion
targetSdkVersion theTargetSdkVersion
testApplicationId "com.androidplot.test"
}
testOptions {
unitTests.all {
jacoco {
includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
}
}
}
lint {
abortOnError false
}
}
group = 'com.androidplot'
version = theVersionName
def siteUrl = 'http://androidplot.com'
def gitUrl = 'https://github.com/halfhp/androidplot.git'
dependencies {
implementation 'com.halfhp.fig:figlib:1.0.11'
implementation 'com.android.support:support-annotations:28.0.0'
testImplementation "org.mockito:mockito-core:4.0.0"
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
testImplementation "org.robolectric:robolectric:4.7.3"
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
failOnError false
options {
links "http://docs.oracle.com/javase/7/docs/api/"
linksOffline "http://d.android.com/reference","${android.sdkDirectory}/docs/reference"
}
exclude '**/BuildConfig.java'
exclude '**/R.java'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
javadoc {
options.overview = "src/main/java/overview.html"
}
afterEvaluate {
publishing {
repositories {
maven {
name = "Maven Central"
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = System.getenv("OSSRH_ACTOR")
password = System.getenv("OSSRH_TOKEN")
}
}
}
publications {
release(MavenPublication) {
from components.release
// You can then customize attributes of the publication as shown below.
groupId = 'com.androidplot'
artifactId = 'androidplot-core'
version = theVersionName
pom {
packaging 'aar'
name = 'Androidplot'
description = "Configure any object from XML."
url = gitUrl
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'halfhp'
name = 'Nick Fellows'
email = 'halfhp@gmail.com'
}
}
scm {
connection = gitUrl
developerConnection = gitUrl
url = gitUrl
}
}
}
}
}
}
afterEvaluate {
signing {
def signingKey = System.getenv("SIGNING_KEY")
def signingPassword = System.getenv("SIGNING_PASSWORD")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.release
}
}
artifacts {
archives javadocJar
archives sourcesJar
}