Skip to content

Commit

Permalink
Merge pull request #50 from infinum/feature/move-to-maven-central
Browse files Browse the repository at this point in the history
Update project for Maven central publishing
  • Loading branch information
novakmarijan authored Apr 6, 2021
2 parents 1c7ddf7 + dc6ccbf commit ec7c19f
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 67 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,8 @@ gradle-app.setting

# End of https://www.gitignore.io/api/java,macos,linux,gradle,android,intellij,androidstudio

.idea/
.idea/

# Maven central publishing ignores
publish.properties
*.gpg
11 changes: 6 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
buildscript {

apply from: "maven.gradle"

ext.sdk = [
min : 14,
target: 28,
target: 28
]

ext.versions = [
goldeneye: '1.1.2',
google : '28.0.0',
kotlin : '1.3.10'
kotlin : '1.4.32'
]

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:4.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.17"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.4.20"
}
}

Expand Down
1 change: 1 addition & 0 deletions buildSrc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
3 changes: 3 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id "groovy"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.infinum.maven

import com.infinum.maven.shared.Configuration

class SonatypeConfiguration implements Configuration {

private Properties properties = new Properties()

@Override
void load() {
File file = new File("publish.properties")
if (file.exists()) {
properties.load(new FileInputStream(file))
} else {
properties.setProperty("sonatype.name", "")
properties.setProperty("sonatype.url", "")
properties.setProperty("sonatype.user", "")
properties.setProperty("sonatype.password", "")
}
}

@Override
String name() {
return properties.getProperty("sonatype.name").toString()
}

@Override
String url() {
return properties.getProperty("sonatype.url").toString()
}

@Override
String username() {
return properties.getProperty("sonatype.user").toString()
}

@Override
String password() {
return properties.getProperty("sonatype.password").toString()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.infinum.maven.shared

interface Configuration {

void load()

String name()

String url()

String username()

String password()
}
43 changes: 0 additions & 43 deletions goldeneye/bintray.gradle

This file was deleted.

2 changes: 1 addition & 1 deletion goldeneye/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ dependencies {
}

apply from: '../tasks.gradle'
apply from: 'bintray.gradle'
apply from: 'publish.gradle'

preBuild.dependsOn ':goldeneye:generateReadme'
76 changes: 76 additions & 0 deletions goldeneye/publish.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
apply plugin: "maven-publish"
apply plugin: "signing"

task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.kotlin.srcDirs
}

task javadocsJar(type: Jar, dependsOn: "dokkaJavadoc") {
archiveClassifier.set("javadoc")
from dokkaJavadoc.outputDirectory
}

afterEvaluate {
publishing {
repositories {
maven {
name sonatype.name()
url sonatype.url()
credentials {
username sonatype.username()
password sonatype.password()
}
}
}
publications {
release(MavenPublication) {
groupId = 'co.infinum'
version = versions.goldeneye

artifactId = 'goldeneye'

artifact bundleReleaseAar
artifact sourcesJar
artifact javadocsJar

pom {
name = 'GoldenEye'
description = 'A wrapper for Camera1 and Camera2 API which exposes simple to use interface.'
url = 'https://github.com/infinum/Android-GoldenEye'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'novakmarijan'
name = 'Marijan Novak'
email = 'marijan.novak@infinum.com'
}
}
scm {
connection = 'https://github.com/infinum/Android-GoldenEye.git'
developerConnection = 'https://github.com/infinum/Android-GoldenEye.git'
url = 'https://github.com/infinum/Android-GoldenEye'
}
}
pom.withXml {
def root = asNode()
def dependenciesNode = root.appendNode('dependencies')
configurations.implementation.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
signing {
sign publishing.publications.release
}
}
}
}
}
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 @@
#Tue Sep 25 13:16:57 CEST 2018
#Fri Apr 02 14:00:41 CEST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
12 changes: 12 additions & 0 deletions maven.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import com.infinum.maven.SonatypeConfiguration

SonatypeConfiguration.metaClass.constructor = { ->
def constructor = SonatypeConfiguration.class.getConstructor()
def instance = constructor.newInstance()
instance.load()
instance
}

ext {
sonatype = new SonatypeConfiguration()
}
15 changes: 0 additions & 15 deletions tasks.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@ afterEvaluate {
})
}

dokka {
outputFormat = 'html'
outputDirectory = "$buildDir/javadoc"
}

task javadocsJar(type: Jar, dependsOn: dokka) {
classifier = 'javadoc'
from dokka.outputDirectory
}

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

task generateReadme {
doFirst {
def readmeFile = new File("${project.rootDir}/README.md")
Expand Down

0 comments on commit ec7c19f

Please sign in to comment.