From 08c6335cd7324c6e72da536b0c6fffa5a798f6a2 Mon Sep 17 00:00:00 2001
From: Michael Pardo
Date: Tue, 7 Oct 2014 10:39:58 -0400
Subject: [PATCH] Maven publishing.
---
README.md | 20 +++
build.gradle | 16 +--
gradle-mvn-push.gradle | 115 ++++++++++++++++++
gradle.properties | 18 +++
src/com/activeandroid/util/IOUtils.java | 6 +-
.../activeandroid/widget/ModelAdapter.java | 6 +-
6 files changed, 163 insertions(+), 18 deletions(-)
create mode 100644 gradle-mvn-push.gradle
create mode 100644 gradle.properties
diff --git a/README.md b/README.md
index 7ba14fbaa..2e7c9e4de 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,26 @@ ActiveAndroid is an active record style ORM ([object relational mapper](http://e
ActiveAndroid does so much more than this though. Accessing the database is a hassle, to say the least, in Android. ActiveAndroid takes care of all the setup and messy stuff, and all with just a few simple steps of configuration.
+## Download
+
+Grab via Maven:
+```xml
+
+ com.michaelpardo
+ activeandroid
+ 3.1.0-SNAPSHOT
+
+```
+or Gradle:
+```groovy
+repositories {
+ mavenCentral()
+ maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
+}
+
+compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
+```
+
## Documentation
* [Getting started](http://github.com/pardom/ActiveAndroid/wiki/Getting-started)
diff --git a/build.gradle b/build.gradle
index 8e6986f2f..5594e43b5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,9 +1,8 @@
apply plugin: 'java'
+apply from: 'gradle-mvn-push.gradle'
-sourceCompatibility = 1.6
-
-jar.baseName = 'activeandroid'
-archivesBaseName = 'activeandroid'
+targetCompatibility = '1.6'
+sourceCompatibility = '1.6'
sourceSets {
main {
@@ -16,12 +15,3 @@ sourceSets {
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
-
-task sourcesJar(type: Jar) {
- classifier = 'sources'
- from sourceSets.main.allSource
-}
-
-artifacts {
- archives sourcesJar
-}
\ No newline at end of file
diff --git a/gradle-mvn-push.gradle b/gradle-mvn-push.gradle
new file mode 100644
index 000000000..8b88acd92
--- /dev/null
+++ b/gradle-mvn-push.gradle
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2013 Chris Banes
+ * Copyright 2014 Michael Pardo
+ *
+ * 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 javadocs(type: Javadoc) {
+ source = sourceSets.main.allJava
+ classpath = configurations.compile
+ }
+
+ task javadocsJar(type: Jar, dependsOn: javadocs) {
+ classifier = 'javadoc'
+ from javadocs.destinationDir
+ }
+
+ task sourcesJar(type: Jar) {
+ classifier = 'sources'
+ from sourceSets.main.allJava
+ }
+
+ artifacts {
+ archives sourcesJar
+ archives javadocsJar
+ }
+}
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 000000000..424d885af
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,18 @@
+VERSION_NAME=3.1.0-SNAPSHOT
+VERSION_CODE=1
+GROUP=com.michaelpardo
+
+POM_DESCRIPTION=Active record style SQLite persistence for Android.
+POM_URL=https://github.com/pardom/ActiveAndroid
+POM_SCM_URL=https://github.com/pardom/ActiveAndroid
+POM_SCM_CONNECTION=scm:git@github.com:pardom/ActiveAndroid.git
+POM_SCM_DEV_CONNECTION=scm:git@github.com:pardom/ActiveAndroid.git
+POM_LICENCE_NAME=The Apache Software License, Version 2.0
+POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
+POM_LICENCE_DIST=repo
+POM_DEVELOPER_ID=michaelpardo
+POM_DEVELOPER_NAME=Michael Pardo
+
+POM_NAME=ActiveAndroid
+POM_ARTIFACT_ID=activeandroid
+POM_PACKAGING=jar
diff --git a/src/com/activeandroid/util/IOUtils.java b/src/com/activeandroid/util/IOUtils.java
index 284d7bca8..b3005f857 100644
--- a/src/com/activeandroid/util/IOUtils.java
+++ b/src/com/activeandroid/util/IOUtils.java
@@ -28,8 +28,9 @@
public class IOUtils {
/**
+ *
* Unconditionally close a {@link Closeable}.
- *
+ *
* Equivalent to {@link Closeable#close()}, except any exceptions will be ignored. This is
* typically used in finally blocks.
* @param closeable A {@link Closeable} to close.
@@ -48,8 +49,9 @@ public static void closeQuietly(final Closeable closeable) {
}
/**
+ *
* Unconditionally close a {@link Cursor}.
- *
+ *
* Equivalent to {@link Cursor#close()}, except any exceptions will be ignored. This is
* typically used in finally blocks.
* @param cursor A {@link Cursor} to close.
diff --git a/src/com/activeandroid/widget/ModelAdapter.java b/src/com/activeandroid/widget/ModelAdapter.java
index 70e59913c..a38957636 100644
--- a/src/com/activeandroid/widget/ModelAdapter.java
+++ b/src/com/activeandroid/widget/ModelAdapter.java
@@ -27,8 +27,8 @@ public ModelAdapter(Context context, int resource, int textViewResourceId, List<
/**
* Clears the adapter and, if data != null, fills if with new Items.
- *
- * @param collection A Collection extends T> which members get added to the adapter.
+ *
+ * @param collection A Collection<? extends T> which members get added to the adapter.
*/
public void setData(Collection extends T> collection) {
clear();
@@ -54,4 +54,4 @@ public long getItemId(int position) {
return -1;
}
}
-}
\ No newline at end of file
+}