Skip to content

Commit

Permalink
Try to publish to internal Maven repository
Browse files Browse the repository at this point in the history
  • Loading branch information
roedll committed Mar 16, 2021
1 parent 2934ba7 commit 8d2eeb6
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 7 deletions.
13 changes: 13 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@ECHO OFF

SET WD=%CD%
SET SD=%~dp0
SET PARAMS=%*

cd "%SD%"

call gradlew clean build %PARAMS%

cd "%WD%"

PAUSE
15 changes: 15 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

SD=$(cd $(dirname $0); pwd -P)
WD="`pwd`"
SCRIPT=$(basename $0)
SCRIPT_NAME=${SCRIPT%.*}
SCRIPT_EXTENSION=${SCRIPT##*.}
SELF=$SD/$SCRIPT

cd $SD/

echo "Building..."
./gradlew clean build $@

cd $WD/
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private const val bintrayApiKeyKey = "bintray_apikey"

fun Project.configureLibraryPublication() {
configureSourcesJarTaskIfNecessary()
configureCheckCiTagTaskIfNecessary()
//configureCheckCiTagTaskIfNecessary()
configureLibraryAarPublication()
configureBintrayForLibraryPublication()
configurePublishTask()
Expand Down
13 changes: 13 additions & 0 deletions deploy.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@ECHO OFF

SET WD=%CD%
SET SD=%~dp0
SET PARAMS=%*

cd "%SD%"

call gradlew clean publish %PARAMS%

cd "%WD%"

PAUSE
15 changes: 15 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

SD=$(cd $(dirname $0); pwd -P)
WD="`pwd`"
SCRIPT=$(basename $0)
SCRIPT_NAME=${SCRIPT%.*}
SCRIPT_EXTENSION=${SCRIPT##*.}
SELF=$SD/$SCRIPT

cd $SD/

echo "Building..."
./gradlew clean publish $@

cd $WD/
24 changes: 24 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# Maven stuff
GROUP=at.ac.ait.hbs.android.surveykit

POM_URL=https://github.com/roedll/SurveyKit

POM_SCM_URL=https://github.com/roedll/SurveyKit
POM_SCM_CONNECTION=scm:[email protected]/roedll/SurveyKit.git
POM_SCM_DEV_CONNECTION=scm:[email protected]/roedll/SurveyKit.git
POM_SCM_URL_ISSUES=https://github.com/roedll/SurveyKit/issues

POM_LICENCE_NAME=
POM_LICENCE_URL=
POM_LICENCE_DIST=repo

POM_ORG_NAME=AIT Austrian Institute of Technology GmbH / Biomedical Systems
POM_ORG_URL=http://www.ait.ac.at

POM_DEVELOPER_ID=roedll
POM_DEVELOPER_NAME=
POM_DEVELOPER_MAIL=

NEXUS_REPO_URL=https://nexus.arcsmed.at/content/repositories/android
NEXUS_REPO_URL_SNAPSHOT=https://nexus.arcsmed.at/content/repositories/android-snapshots

org.gradle.jvmargs=-Xmx1536m
kotlin.code.style=official
org.gradle.parallel=true
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Apr 01 15:38:24 CEST 2019
#Thu Sep 17 09:56:59 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
198 changes: 198 additions & 0 deletions maven_publish_helper.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
apply plugin: 'maven-publish'

def isAndroidSdkPresent() {
try {
android.getSdkDirectory()
return true
} catch(RuntimeException ex) {
return false
}
}

task androidJavadocs(type: Javadoc) {
// Check if Android SDK is initialized at all
if (isAndroidSdkPresent()) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))

def propVariants = null
if (android.hasProperty('applicationVariants')) {
propVariants = android.getProperty('applicationVariants')
} else if (android.hasProperty('libraryVariants')) {
propVariants = android.getProperty('libraryVariants')
}

if (propVariants != null) {
propVariants.all { variant ->
if (variant.name == 'release') {
owner.classpath += variant.javaCompileProvider.get().classpath
}
}
}
}

exclude '**/R.html', '**/R.*.html', '**/index.html', '**/*.kt'
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
archiveClassifier.set('javadoc')
from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
// Check if Android SDK is initialized at all
if (isAndroidSdkPresent()) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
}
}

/*
void halt() {
try {
throw new RuntimeException('Break');
} catch (RuntimeException e) {
print('Paused')
}
}
task iterateDeclaredDependencies {
doLast {
Object configs = configurations.all
halt();
print(configs)
}
}
*/

def mavenNexusArcsmed = { RepositoryHandler handler, String repoUrl ->
handler.maven {
url repoUrl
credentials {
username project.findProperty("mavenUserArcsmed") ?: System.getenv('CI_MAVEN_USER_ARCSMED')
password project.findProperty("mavenPasswordArcsmed") ?: System.getenv('CI_MAVEN_PASS_ARCSMED')
}
}
}

// Because the components are created only during the afterEvaluate phase, you must
// configure your publications using the afterEvaluate() lifecycle method.
afterEvaluate {

allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
}
}




/*
def propVariants = null
if (android.hasProperty('applicationVariants')) {
propVariants = android.getProperty('applicationVariants')
} else if (android.hasProperty('libraryVariants')) {
propVariants = android.getProperty('libraryVariants')
}
if (propVariants != null) {
propVariants.all { variant ->
println("VARIANT: " + variant + "\n\n")
println("VARIANT NAME: " + variant.name + "\n\n")
println("VARIANT PROPS: " + variant.properties + "\n\n")
println("VARIANT DATA: " + variant.variantData.properties + "\n\n")
}
}
*/

println("COMPONENTS: " + project.components.properties + "\n\n")

publishing {
// Check if Android SDK is initialized at all
if (isAndroidSdkPresent()) {
publications {
// Creates a Maven publication called "mavenRelease"
mavenRelease(MavenPublication) {
// Check for Android configuration and apply the component for the release build variant
// See https://developer.android.com/studio/build/maven-publish-plugin

//println("COMPONENTS: " + components.properties)

if (components.hasProperty('release_apk')) {
project.logger.info('Prepare to publish APK')
from components.release_apk
} else if (components.hasProperty('release_aab')) {
project.logger.info('Prepare to publish AAB')
from components.release_aab
} else if (components.hasProperty('release')) {
project.logger.info('Prepare to publish AAR')
from components.release
}
//from components.release

// Adds javadocs and sources as separate jars
artifact androidJavadocsJar
artifact androidSourcesJar



println("ANDROID: " + android.properties + "\n\n")
println("ANDROID DEF PUB: " + android.defaultPublishConfig.properties + "\n\n")
//from components.aar

// You can customize attributes of the publication here or in module's build.gradle file
groupId GROUP
artifactId POM_ARTIFACT_ID
version android.defaultConfig.versionName

// Other artifacts are added dynamically
pom.withXml {
final root = asNode()
root.appendNode('name', POM_NAME)
root.appendNode('description', POM_DESCRIPTION)
root.appendNode('url', POM_SCM_URL)

// Append some additional properties
root.children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST

licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}
organization {
name POM_ORG_NAME
url POM_ORG_URL
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
email POM_DEVELOPER_MAIL
}
}
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
}
}
}
}
repositories {
def releasesRepoUrl = NEXUS_REPO_URL
def snapshotsRepoUrl = NEXUS_REPO_URL_SNAPSHOT
def repoUrl = android.defaultConfig.versionName.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl

mavenNexusArcsmed(delegate, repoUrl)
}
}
}

}
19 changes: 15 additions & 4 deletions survey/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@file:Suppress("SuspiciousCollectionReassignment")

import com.quickbirdstudios.surveykit.configureLibraryPublication
//import com.quickbirdstudios.surveykit.configureLibraryPublication

plugins {
id("com.android.library")
kotlin("android")
id("org.jetbrains.kotlin.android.extensions")
id("com.jfrog.bintray")
`maven-publish`
//id("com.jfrog.bintray")
//`maven-publish`
}

androidExtensions { isExperimental = true }
Expand All @@ -18,12 +18,19 @@ android {
defaultConfig {
minSdkVersion(Project.Android.minSdkVersion)
targetSdkVersion(Project.Android.targetSdkVersion)

versionName = "v2.0.0-ait-SNAPSHOT"

testInstrumentationRunner = Project.Android.testInstrumentationRunner
}

testOptions {
animationsDisabled = true
}

lintOptions {
isAbortOnError = false
}
}

dependencies {
Expand All @@ -40,4 +47,8 @@ dependencies {
testImplementation(Deps.Test.jUnitPlatform)
}

project.configureLibraryPublication()
//project.configureLibraryPublication()

apply {
from("../maven_publish_helper.gradle")
}
4 changes: 4 additions & 0 deletions survey/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
POM_NAME=SurveyKit - Library
POM_DESCRIPTION=
POM_ARTIFACT_ID=surveykit.library
POM_PACKAGING=aar

0 comments on commit 8d2eeb6

Please sign in to comment.