diff --git a/build.gradle b/build.gradle index 82ac351..82bcf80 100644 --- a/build.gradle +++ b/build.gradle @@ -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" } diff --git a/gradle.properties b/gradle.properties index c1479a3..f4fce71 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 \ No newline at end of file +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:git@github.com:iZettle/android-html2bitmap.git +POM_SCM_DEV_CONNECTION=scm:git@github.com: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 \ No newline at end of file diff --git a/gradle/gradle-mvn-push.gradle b/gradle/gradle-mvn-push.gradle new file mode 100644 index 0000000..58aaa11 --- /dev/null +++ b/gradle/gradle-mvn-push.gradle @@ -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 + } +} \ No newline at end of file diff --git a/html2bitmap/build.gradle b/html2bitmap/build.gradle index 2288ea4..0c15a94 100644 --- a/html2bitmap/build.gradle +++ b/html2bitmap/build.gradle @@ -1,5 +1,4 @@ apply plugin: 'com.android.library' -apply plugin: 'digital.wup.android-maven-publish' android { compileSdkVersion 27 @@ -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') \ No newline at end of file diff --git a/html2bitmap/gradle.properties b/html2bitmap/gradle.properties new file mode 100644 index 0000000..c8dfb98 --- /dev/null +++ b/html2bitmap/gradle.properties @@ -0,0 +1,3 @@ +POM_ARTIFACT_ID=html2bitmap +POM_NAME=Html2Bitmap +POM_PACKAGING=aar \ No newline at end of file diff --git a/html2bitmap/src/main/java/com/izettle/html2bitmap/Html2Bitmap.java b/html2bitmap/src/main/java/com/izettle/html2bitmap/Html2Bitmap.java index 0e986fe..56e8e20 100644 --- a/html2bitmap/src/main/java/com/izettle/html2bitmap/Html2Bitmap.java +++ b/html2bitmap/src/main/java/com/izettle/html2bitmap/Html2Bitmap.java @@ -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; @@ -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; }