Skip to content

Commit

Permalink
Merge pull request #11 from iZettle/feature/maven_central_publish
Browse files Browse the repository at this point in the history
Move publish to maven central
  • Loading branch information
warting authored Apr 12, 2018
2 parents df0af28 + 16fe63e commit e9db1b5
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 47 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ buildscript {
}

plugins {
id 'digital.wup.android-maven-publish' version '3.3.0'
id "com.github.ben-manes.versions" version "0.17.0"
}

Expand Down
19 changes: 13 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
CIVersionCode=5
CIVersionName=1.4
CIVersionNameSufix=
artifactory_user=deployer
artifactory_password=PASSWORD
artifactory_repository=android-snapshot-local
VERSION_CODE=5
VERSION_NAME=1.4
GROUP=com.izettle
POM_DESCRIPTION=Html2Bitmap
POM_URL=https://github.com/iZettle/android-html2bitmap
POM_SCM_URL=https://github.com/iZettle/android-html2bitmap
POM_SCM_CONNECTION=scm:[email protected]:iZettle/android-html2bitmap.git
POM_SCM_DEV_CONNECTION=scm:[email protected]:iZettle/android-html2bitmap.git
POM_LICENCE_NAME=MIT License
POM_LICENCE_URL=https://github.com/iZettle/android-html2bitmap/master/develop/LICENSE
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=erikeelde, warting
POM_DEVELOPER_NAME=Erik Eelde, Stefan Wärting
115 changes: 115 additions & 0 deletions gradle/gradle-mvn-push.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* Copyright 2013 Chris Banes
*
* 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.
*/

apply plugin: 'maven'
apply plugin: 'signing'

def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}

def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}

def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
}

def getRepositoryUsername() {
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
}

def getRepositoryPassword() {
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
}

afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME

repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}

pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL

scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}

licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}

developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
}
}
}
}

signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}

task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
failOnError false
}

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

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

artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
}
39 changes: 3 additions & 36 deletions html2bitmap/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: 'com.android.library'
apply plugin: 'digital.wup.android-maven-publish'

android {
compileSdkVersion 27
Expand All @@ -16,45 +15,13 @@ android {
minifyEnabled false
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

publishing {
repositories {
maven {
url "https://devtools.izettle.net/artifactory/${artifactory_repository}"
credentials {
username = "${artifactory_user}" // The publisher user name
password = "${artifactory_password}" // The publisher password
}
}
}

publications {
aar(MavenPublication) {
groupId = 'com.izettle'
artifactId = project.name
version = CIVersionName + CIVersionNameSufix

from components.android

artifact sourceJar
}
}
}

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

dependencies {
implementation 'com.android.support:support-annotations:27.1.0'
implementation 'com.android.support:support-annotations:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
3 changes: 3 additions & 0 deletions html2bitmap/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POM_ARTIFACT_ID=html2bitmap
POM_NAME=Html2Bitmap
POM_PACKAGING=aar
18 changes: 14 additions & 4 deletions html2bitmap/src/main/java/com/izettle/html2bitmap/Html2Bitmap.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class Html2Bitmap {
private WebView webView;

@AnyThread
private Html2Bitmap(@NonNull final Context context, @NonNull String html, int paperWidth, @NonNull Callback callback) {
private Html2Bitmap(@NonNull final Context context, @NonNull String html, final int paperWidth, @NonNull final Callback callback) {
this.context = context;
this.html = html;
this.paperWidth = paperWidth;
Expand Down Expand Up @@ -128,17 +128,27 @@ public static Bitmap getBitmap(Context context, String html, int width, int time
ExecutorService executor = Executors.newFixedThreadPool(1);
executor.execute(bitmapFutureTask);

Html2Bitmap html2Bitmap = new Html2Bitmap(context, html, width, bitmapCallable);
final Html2Bitmap html2Bitmap = new Html2Bitmap(context, html, width, bitmapCallable);

Handler mainHandler = new Handler(context.getMainLooper());
mainHandler.post(html2Bitmap::load);
mainHandler.post(new Runnable() {
@Override
public void run() {
html2Bitmap.load();
}
});

try {
return bitmapFutureTask.get(timeout, TimeUnit.SECONDS);
} catch (InterruptedException | TimeoutException | ExecutionException e) {
Log.e(TAG, "", e);
} finally {
mainHandler.post(html2Bitmap::cleanup);
mainHandler.post(new Runnable() {
@Override
public void run() {
html2Bitmap.cleanup();
}
});
}
return null;
}
Expand Down

0 comments on commit e9db1b5

Please sign in to comment.