Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: mavenレポジトリへpublishできるように修正 #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 59 additions & 82 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,104 +1,81 @@
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'com.diffplug.spotless'
plugins {
id 'idea'
id 'eclipse'
id 'java'
id 'signing'
id 'com.diffplug.spotless' version '6.13.0'
id 'maven-publish'
}

group = 'com.kintone'
version = '0.0.1-SNAPSHOT'

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.+'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0'
}
}

repositories {
mavenCentral()
}
sourceSets {
main.java.srcDirs = ['src/main/java']
}

if(hasProperty('target') && target == 'android') {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

task javadocJar(type: Jar) {
archiveClassifier = 'javadoc'
from javadoc
}

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
task sourcesJar(type: Jar) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
}

android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 25
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
artifacts {
archives javadocJar, sourcesJar
}

// Rename the aar correctly
libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) {
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
output.outputFile = new File(outputFile.parent, fileName)
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'kintone-rest-client-java'
from components.java
pom {
name = 'kintone-rest-client-java'
description = 'API client library for Kintone REST APIs on Java.'
url = 'https://github.com/kintone/kintone-rest-client-java'
licenses {
license {
name = 'The MIT License'
url = 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
name = 'cybozu'
email = '[email protected]'
}
}
scm {
connection = 'https://github.com/kintone/kintone-rest-client-java.git'
url = 'https://github.com/kintone/kintone-rest-client-java'
}
}
}

dependencies {
provided "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
}
}

afterEvaluate {
android.libraryVariants.all { variant ->
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
task.description = "Create jar artifact for ${variant.name}"
task.dependsOn variant.javaCompile
task.from variant.javaCompile.destinationDirectory
task.destinationDirectory = project.file("${project.buildDir}/outputs/jar")
task.archiveFileName = "${project.name}-${variant.baseName}-${version}.jar"
artifacts.add('archives', task)
}
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

artifacts {
archives sourcesJar
}

} else {

apply plugin: 'java'
apply plugin: 'maven-publish'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

publishing {
publications {
maven(MavenPublication) {
artifactId = 'kintone-rest-client'
from components.java
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
if (project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')) {
credentials {
username = "${sonatypeUsername}"
password = "${sonatypePassword}"
}
}
}
}
}

task execute(type:JavaExec) {
main = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath
}
signing {
sign publishing.publications.mavenJava
}

ext {
Expand Down
27 changes: 0 additions & 27 deletions build.sbt

This file was deleted.

Empty file modified gradlew
100644 → 100755
Empty file.
Loading