Skip to content

Commit

Permalink
add publish.gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
sasakitomohiro committed Jul 26, 2021
1 parent ae47ff1 commit c53a30d
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 25 deletions.
22 changes: 20 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.21"
ext.configs = [
versionName: "0.1.0",
versionCode: 1,
compileSdkVersion: 30,
minSdkVersion: 24,
targetSdkVersion: 30,
groupId: "com.github.sasakitomohiro",
artifactId: "rvtablayoutmediator",
description: "RvTabLayoutMediator",
siteUrl: "https://github.com/sasakitomohiro/RvTabLayoutMediator",
gitUrl: "https://github.com/sasakitomohiro/RvTabLayoutMediator.git",
developerId: "sasakitomohiro",
developerName: "TomohiroSasaki",
developerEmail: "[email protected]",
licenseName: "The Apache Software License, Version 2.0",
licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0.txt"
]
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.0-rc01'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -15,4 +33,4 @@ buildscript {

task clean(type: Delete) {
delete rootProject.buildDir
}
}
82 changes: 82 additions & 0 deletions publish.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

def sonatypeUsername = rootProject.hasProperty('sonatypeUsername')? rootProject.sonatypeUsername : ''
def sonatypePassword = rootProject.hasProperty('sonatypePassword')? rootProject.sonatypePassword : ''

version configs.versionName
group configs.groupId

task sourcesJar(type: Jar) {
archiveClassifier.set("sources")
from android.sourceSets.getByName("main").java.srcDirs
}

task javadoc(type: Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
source = android.sourceSets.getByName("main").java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
excludes = ['**/*.kt']
}

task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set("javadoc")
from javadoc.destinationDir
}

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
artifactId = configs.artifactId
from components.release
artifact javadocJar
artifact sourcesJar
pom {
name = configs.artifactId
description = configs.description
url = configs.siteUrl
licenses {
license {
name = configs.licenseName
url = configs.licenseUrl
}
}
developers {
developer {
id = configs.developerId
name = configs.developerName
email = configs.developerEmail
}
}
scm {
connection = configs.gitUrl
developerConnection = configs.gitUrl
url = configs.siteUrl
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = "${sonatypeUsername}"
password = "${sonatypePassword}"
}
}
}
}
}

signing {
sign publishing.publications
}

javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
30 changes: 7 additions & 23 deletions rvtablayoutmediator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,24 @@ plugins {
}

android {
compileSdk 30
compileSdkVersion configs.compileSdkVersion
buildToolsVersion "30.0.3"

defaultConfig {
minSdk 24
targetSdk 30
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
minSdkVersion configs.minSdkVersion
targetSdkVersion configs.targetSdkVersion
versionCode configs.versionCode
versionName configs.versionName
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

apply from: "../publish.gradle"

0 comments on commit c53a30d

Please sign in to comment.