Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit e9db1b5

Browse files
authored
Merge pull request #11 from iZettle/feature/maven_central_publish
Move publish to maven central
2 parents df0af28 + 16fe63e commit e9db1b5

File tree

6 files changed

+148
-47
lines changed

6 files changed

+148
-47
lines changed

build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ buildscript {
1616
}
1717

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

gradle.properties

+13-6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,16 @@ org.gradle.jvmargs=-Xmx1536m
1111
# This option should only be used with decoupled projects. More details, visit
1212
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1313
# org.gradle.parallel=true
14-
CIVersionCode=5
15-
CIVersionName=1.4
16-
CIVersionNameSufix=
17-
artifactory_user=deployer
18-
artifactory_password=PASSWORD
19-
artifactory_repository=android-snapshot-local
14+
VERSION_CODE=5
15+
VERSION_NAME=1.4
16+
GROUP=com.izettle
17+
POM_DESCRIPTION=Html2Bitmap
18+
POM_URL=https://github.com/iZettle/android-html2bitmap
19+
POM_SCM_URL=https://github.com/iZettle/android-html2bitmap
20+
POM_SCM_CONNECTION=scm:[email protected]:iZettle/android-html2bitmap.git
21+
POM_SCM_DEV_CONNECTION=scm:[email protected]:iZettle/android-html2bitmap.git
22+
POM_LICENCE_NAME=MIT License
23+
POM_LICENCE_URL=https://github.com/iZettle/android-html2bitmap/master/develop/LICENSE
24+
POM_LICENCE_DIST=repo
25+
POM_DEVELOPER_ID=erikeelde, warting
26+
POM_DEVELOPER_NAME=Erik Eelde, Stefan Wärting

gradle/gradle-mvn-push.gradle

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
* Copyright 2013 Chris Banes
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
apply plugin: 'maven'
18+
apply plugin: 'signing'
19+
20+
def isReleaseBuild() {
21+
return VERSION_NAME.contains("SNAPSHOT") == false
22+
}
23+
24+
def getReleaseRepositoryUrl() {
25+
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
26+
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
27+
}
28+
29+
def getSnapshotRepositoryUrl() {
30+
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
31+
: "https://oss.sonatype.org/content/repositories/snapshots/"
32+
}
33+
34+
def getRepositoryUsername() {
35+
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
36+
}
37+
38+
def getRepositoryPassword() {
39+
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
40+
}
41+
42+
afterEvaluate { project ->
43+
uploadArchives {
44+
repositories {
45+
mavenDeployer {
46+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
47+
48+
pom.groupId = GROUP
49+
pom.artifactId = POM_ARTIFACT_ID
50+
pom.version = VERSION_NAME
51+
52+
repository(url: getReleaseRepositoryUrl()) {
53+
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
54+
}
55+
snapshotRepository(url: getSnapshotRepositoryUrl()) {
56+
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
57+
}
58+
59+
pom.project {
60+
name POM_NAME
61+
packaging POM_PACKAGING
62+
description POM_DESCRIPTION
63+
url POM_URL
64+
65+
scm {
66+
url POM_SCM_URL
67+
connection POM_SCM_CONNECTION
68+
developerConnection POM_SCM_DEV_CONNECTION
69+
}
70+
71+
licenses {
72+
license {
73+
name POM_LICENCE_NAME
74+
url POM_LICENCE_URL
75+
distribution POM_LICENCE_DIST
76+
}
77+
}
78+
79+
developers {
80+
developer {
81+
id POM_DEVELOPER_ID
82+
name POM_DEVELOPER_NAME
83+
}
84+
}
85+
}
86+
}
87+
}
88+
}
89+
90+
signing {
91+
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
92+
sign configurations.archives
93+
}
94+
95+
task androidJavadocs(type: Javadoc) {
96+
source = android.sourceSets.main.java.srcDirs
97+
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
98+
failOnError false
99+
}
100+
101+
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
102+
classifier = 'javadoc'
103+
from androidJavadocs.destinationDir
104+
}
105+
106+
task androidSourcesJar(type: Jar) {
107+
classifier = 'sources'
108+
from android.sourceSets.main.java.sourceFiles
109+
}
110+
111+
artifacts {
112+
archives androidSourcesJar
113+
archives androidJavadocsJar
114+
}
115+
}

html2bitmap/build.gradle

+3-36
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
apply plugin: 'com.android.library'
2-
apply plugin: 'digital.wup.android-maven-publish'
32

43
android {
54
compileSdkVersion 27
@@ -16,45 +15,13 @@ android {
1615
minifyEnabled false
1716
}
1817
}
19-
20-
compileOptions {
21-
sourceCompatibility JavaVersion.VERSION_1_8
22-
targetCompatibility JavaVersion.VERSION_1_8
23-
}
24-
}
25-
26-
publishing {
27-
repositories {
28-
maven {
29-
url "https://devtools.izettle.net/artifactory/${artifactory_repository}"
30-
credentials {
31-
username = "${artifactory_user}" // The publisher user name
32-
password = "${artifactory_password}" // The publisher password
33-
}
34-
}
35-
}
36-
37-
publications {
38-
aar(MavenPublication) {
39-
groupId = 'com.izettle'
40-
artifactId = project.name
41-
version = CIVersionName + CIVersionNameSufix
42-
43-
from components.android
44-
45-
artifact sourceJar
46-
}
47-
}
48-
}
49-
50-
task sourceJar(type: Jar) {
51-
classifier = 'sources'
52-
from android.sourceSets.main.java.sourceFiles
5318
}
5419

5520
dependencies {
56-
implementation 'com.android.support:support-annotations:27.1.0'
21+
implementation 'com.android.support:support-annotations:27.1.1'
5722
testImplementation 'junit:junit:4.12'
5823
androidTestImplementation 'com.android.support.test:runner:1.0.1'
5924
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
6025
}
26+
27+
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')

html2bitmap/gradle.properties

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
POM_ARTIFACT_ID=html2bitmap
2+
POM_NAME=Html2Bitmap
3+
POM_PACKAGING=aar

html2bitmap/src/main/java/com/izettle/html2bitmap/Html2Bitmap.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class Html2Bitmap {
5959
private WebView webView;
6060

6161
@AnyThread
62-
private Html2Bitmap(@NonNull final Context context, @NonNull String html, int paperWidth, @NonNull Callback callback) {
62+
private Html2Bitmap(@NonNull final Context context, @NonNull String html, final int paperWidth, @NonNull final Callback callback) {
6363
this.context = context;
6464
this.html = html;
6565
this.paperWidth = paperWidth;
@@ -128,17 +128,27 @@ public static Bitmap getBitmap(Context context, String html, int width, int time
128128
ExecutorService executor = Executors.newFixedThreadPool(1);
129129
executor.execute(bitmapFutureTask);
130130

131-
Html2Bitmap html2Bitmap = new Html2Bitmap(context, html, width, bitmapCallable);
131+
final Html2Bitmap html2Bitmap = new Html2Bitmap(context, html, width, bitmapCallable);
132132

133133
Handler mainHandler = new Handler(context.getMainLooper());
134-
mainHandler.post(html2Bitmap::load);
134+
mainHandler.post(new Runnable() {
135+
@Override
136+
public void run() {
137+
html2Bitmap.load();
138+
}
139+
});
135140

136141
try {
137142
return bitmapFutureTask.get(timeout, TimeUnit.SECONDS);
138143
} catch (InterruptedException | TimeoutException | ExecutionException e) {
139144
Log.e(TAG, "", e);
140145
} finally {
141-
mainHandler.post(html2Bitmap::cleanup);
146+
mainHandler.post(new Runnable() {
147+
@Override
148+
public void run() {
149+
html2Bitmap.cleanup();
150+
}
151+
});
142152
}
143153
return null;
144154
}

0 commit comments

Comments
 (0)