Skip to content

Commit

Permalink
Rename package name to me.moallemi
Browse files Browse the repository at this point in the history
  • Loading branch information
moallemi committed Mar 25, 2020
1 parent 6e6bafa commit fe5d767
Show file tree
Hide file tree
Showing 23 changed files with 209 additions and 88 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@ classes
/.idea/libraries
.DS_Store
/build
/gradle.properties
bintray_push.gradle
maven_push.gradle
34 changes: 5 additions & 29 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ plugins {
id 'com.diffplug.gradle.spotless' version '3.27.2'
id 'com.adarshr.test-logger' version '2.0.0'

id "com.jfrog.bintray" version "1.8.4"
id "maven-publish"
id "signing"
}

apply from: 'configs/spotless.gradle'
Expand Down Expand Up @@ -33,41 +35,15 @@ compileKotlin {
}
}

test {
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
}
}

project.ext {
artifactId = 'gradle-plugin'
name = 'Gradle Advanced Build Version Plugin'
pluginId = 'org.moallemi.advanced-build-version'
}

project.description = "A plugin to generate the Android version code and version name automatically."
project.group = "org.moallemi.gradle.advanced-build-version"
project.version = "1.7.0-SNAPSHOT"

project.ext.pluginId = 'me.moallemi.advanced-build-version'
gradlePlugin {
plugins {
myPlugin {
id = project.pluginId
implementationClass = 'org.moallemi.gradle.advancedbuildversion.AdvancedBuildVersionPlugin'
}
}
}

publishing {
publications {
maven(MavenPublication) {
groupId = project.group
artifactId = project.artifactId
version = project.version

from components.java
implementationClass = 'me.moallemi.gradle.advancedbuildversion.AdvancedBuildVersionPlugin'
}
}
}

apply from: 'configs/test-setup.gradle'
apply from: 'gradle/publish.gradle'
10 changes: 10 additions & 0 deletions configs/test-setup.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@

apply plugin: 'com.adarshr.test-logger'

compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}

test {
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
}
}

testlogger {
showSimpleNames true
}
Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Empty properties to keep the build portable.
# Don't fill these with real values - override them in ~/.gradle
# or on the command line.

kotlin.code.style=official
116 changes: 116 additions & 0 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
project.description = "Generate Android version code and version name automatically from git tags, date,... ."
project.group = "me.moallemi.gradle"
project.version = "1.7.0-SNAPSHOT"
project.ext {
artifactId = 'advanced-build-version'
name = 'Gradle Advanced Build Version Plugin'
url = "https://github.com/moallemi/gradle-advanced-build-version"
scm = [
connectionUrl : "scm:[email protected]:moallemi/gradle-advanced-build-version.git",
developerConnectionUrl: "scm:[email protected]:moallemi/gradle-advanced-build-version.git"
]
}

task sourcesJar(type: Jar) {
from sourceSets.main.allSource
archiveClassifier.set("sources")
}

task javadocJar(type: Jar) {
from tasks.javadoc
archiveClassifier.set("javadoc")
}

publishing {
publications {
advancedBuildVersion(MavenPublication) {
groupId = project.group
artifactId = project.artifactId
version = project.version

from components.java
artifact tasks["sourcesJar"]
artifact tasks["javadocJar"]

pom {
name = project.name
packaging "jar"
description = project.description
url = project.url
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'moallemi'
name = 'Reza Moallemi'
}
}
scm {
url = project.url
connection = project.scm.connectionUrl
developerConnection = project.scm.developerConnectionUrl
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username System.getenv('SONATYPE_USERNAME')
password System.getenv('SONATYPE_PASSWORD')
}
}
}
}

signing {
required !version.endsWith('SNAPSHOT')
useInMemoryPgpKeys(System.getenv('SIGNING_KEY'), System.getenv('SIGNING_PASSWORD'))
sign(publishing.publications["advancedBuildVersion"])
}

bintray {
user = System.getenv('BINTRAY_USERNAME')
key = System.getenv('BINTRAY_API_KEY')
publications = ['advancedBuildVersion']
dryRun = false
pkg {
repo = 'maven'
name = project.artifactId
desc = project.description
websiteUrl = project.url
issueTrackerUrl = 'https://github.com/moallemi/gradle-advanced-build-version/issues'
vcsUrl = 'https://github.com/moallemi/gradle-advanced-build-version.git'
licenses = ['Apache-2.0']
labels = ['kotlin', 'android', 'gradle', 'advanced-build-version', 'versionCode', 'versionName']
publicDownloadNumbers = false
githubRepo = 'moallemi/gradle-advanced-build-version' //Optional Github repository
githubReleaseNotesFile = 'README.md' //Optional Github readme file
version {
name = project.version
//desc = 'optional, version-specific description'
//released = 'optional, date of the version release' //2 possible values: date in the format of 'yyyy-MM-dd'T'HH:mm:ss.SSSZZ' OR a java.util.Date instance
//vcsTag = '1.3.0'
// attributes = [] //Optional version-level attributes
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = System.getenv('BINTRAY_SIGNING_PASSWORD') //Optional. The passphrase for GPG signing'
}
mavenCentralSync {
sync = false //Optional (true by default). Determines whether to sync the version to Maven Central.
user = System.getenv('SONATYPE_USERNAME') //OSS user token
password = System.getenv('SONATYPE_PASSWORD') //OSS user password
close = '1'
//Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
}
}
}

}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Wed Mar 11 19:03:10 CET 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
* limitations under the License.
*/

package org.moallemi.gradle.advancedbuildversion
package me.moallemi.gradle.advancedbuildversion

import com.android.build.gradle.AppExtension
import com.android.build.gradle.AppPlugin
import com.android.build.gradle.FeaturePlugin
import com.android.build.gradle.LibraryPlugin
import me.moallemi.gradle.advancedbuildversion.gradleextensions.AdvancedBuildVersionConfig
import me.moallemi.gradle.advancedbuildversion.utils.checkAndroidGradleVersion
import me.moallemi.gradle.advancedbuildversion.utils.checkMinimumGradleVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.internal.impldep.org.eclipse.jgit.errors.NotSupportedException
import org.moallemi.gradle.advancedbuildversion.gradleextensions.AdvancedBuildVersionConfig
import org.moallemi.gradle.advancedbuildversion.utils.checkAndroidGradleVersion
import org.moallemi.gradle.advancedbuildversion.utils.checkMinimumGradleVersion

class AdvancedBuildVersionPlugin : Plugin<Project> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,27 @@
* limitations under the License.
*/

package org.moallemi.gradle.advancedbuildversion.gradleextensions
package me.moallemi.gradle.advancedbuildversion.gradleextensions

import com.android.build.gradle.api.ApplicationVariant
import groovy.lang.Closure
import me.moallemi.gradle.advancedbuildversion.utils.GitWrapper
import org.gradle.api.DomainObjectSet
import org.gradle.api.Project
import org.moallemi.gradle.advancedbuildversion.utils.GitWrapper

open class AdvancedBuildVersionConfig(private val project: Project) {

internal var versionNameConfig = VersionNameConfig()
internal var versionNameConfig =
VersionNameConfig()

internal var versionCodeConfig = VersionCodeConfig(project, GitWrapper(project))
internal var versionCodeConfig =
VersionCodeConfig(
project,
GitWrapper(project)
)

internal var outputConfig = FileOutputConfig(project)
internal var outputConfig =
FileOutputConfig(project)

val versionName by lazy {
versionNameConfig.versionName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.moallemi.gradle.advancedbuildversion.gradleextensions
package me.moallemi.gradle.advancedbuildversion.gradleextensions

import com.android.build.gradle.api.ApplicationVariant
import com.android.build.gradle.internal.api.BaseVariantOutputImpl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.moallemi.gradle.advancedbuildversion.gradleextensions
package me.moallemi.gradle.advancedbuildversion.gradleextensions

import java.io.File
import java.io.FileInputStream
Expand All @@ -23,13 +23,13 @@ import java.util.Calendar
import java.util.Date
import java.util.Locale
import java.util.Properties
import me.moallemi.gradle.advancedbuildversion.gradleextensions.VersionCodeType.AUTO_INCREMENT_DATE
import me.moallemi.gradle.advancedbuildversion.gradleextensions.VersionCodeType.AUTO_INCREMENT_ONE_STEP
import me.moallemi.gradle.advancedbuildversion.gradleextensions.VersionCodeType.DATE
import me.moallemi.gradle.advancedbuildversion.gradleextensions.VersionCodeType.GIT_COMMIT_COUNT
import me.moallemi.gradle.advancedbuildversion.utils.GitWrapper
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.moallemi.gradle.advancedbuildversion.gradleextensions.VersionCodeType.AUTO_INCREMENT_DATE
import org.moallemi.gradle.advancedbuildversion.gradleextensions.VersionCodeType.AUTO_INCREMENT_ONE_STEP
import org.moallemi.gradle.advancedbuildversion.gradleextensions.VersionCodeType.DATE
import org.moallemi.gradle.advancedbuildversion.gradleextensions.VersionCodeType.GIT_COMMIT_COUNT
import org.moallemi.gradle.advancedbuildversion.utils.GitWrapper

class VersionCodeConfig(
private val project: Project,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.moallemi.gradle.advancedbuildversion.gradleextensions
package me.moallemi.gradle.advancedbuildversion.gradleextensions

import org.gradle.api.GradleException

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
* limitations under the License.
*/

package org.moallemi.gradle.advancedbuildversion.utils
package me.moallemi.gradle.advancedbuildversion.utils

import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.gradle.util.GradleVersion

fun checkAndroidGradleVersion(project: Project) {
val androidGradlePlugin = getAndroidPluginVersion(project)
val androidGradlePlugin =
getAndroidPluginVersion(project)
if (androidGradlePlugin == null) {
throw IllegalStateException(
"The Android Gradle plugin not found. " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.moallemi.gradle.advancedbuildversion.utils
package me.moallemi.gradle.advancedbuildversion.utils

import org.eclipse.jgit.api.Git
import org.eclipse.jgit.lib.Repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.moallemi.gradle.advancedbuildversion
package me.moallemi.gradle.advancedbuildversion

import com.android.build.gradle.AppExtension
import com.android.build.gradle.AppPlugin
Expand All @@ -28,6 +28,10 @@ import io.mockk.mockkStatic
import io.mockk.runs
import io.mockk.slot
import io.mockk.verifyOrder
import me.moallemi.gradle.advancedbuildversion.AdvancedBuildVersionPlugin.Companion.EXTENSION_NAME
import me.moallemi.gradle.advancedbuildversion.gradleextensions.AdvancedBuildVersionConfig
import me.moallemi.gradle.advancedbuildversion.utils.checkAndroidGradleVersion
import me.moallemi.gradle.advancedbuildversion.utils.checkMinimumGradleVersion
import org.gradle.api.Action
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand All @@ -37,10 +41,6 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertThrows
import org.junit.Before
import org.junit.Test
import org.moallemi.gradle.advancedbuildversion.AdvancedBuildVersionPlugin.Companion.EXTENSION_NAME
import org.moallemi.gradle.advancedbuildversion.gradleextensions.AdvancedBuildVersionConfig
import org.moallemi.gradle.advancedbuildversion.utils.checkAndroidGradleVersion
import org.moallemi.gradle.advancedbuildversion.utils.checkMinimumGradleVersion

class AdvancedBuildVersionPluginTest {

Expand All @@ -50,7 +50,7 @@ class AdvancedBuildVersionPluginTest {

@Before
fun setUp() {
mockkStatic("org.moallemi.gradle.advancedbuildversion.utils.CompatibilityManagerKt")
mockkStatic("me.moallemi.gradle.advancedbuildversion.utils.CompatibilityManagerKt")
every { checkAndroidGradleVersion(any()) } just runs

every { project.extensions } returns mockk()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.moallemi.gradle.advancedbuildversion.gradleextensions
package me.moallemi.gradle.advancedbuildversion.gradleextensions

import groovy.lang.Closure
import groovy.lang.GroovyShell
Expand Down Expand Up @@ -44,7 +44,9 @@ class AdvancedBuildVersionConfigTest {
fun setUp() {
every { project.buildFile } returns File("file.tmp")

config = AdvancedBuildVersionConfig(project)
config = AdvancedBuildVersionConfig(
project
)
}

@After
Expand Down
Loading

0 comments on commit fe5d767

Please sign in to comment.