This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34f0841
commit 95a16b6
Showing
5 changed files
with
88 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,14 @@ | ||
import com.jfrog.bintray.gradle.BintrayExtension | ||
import com.jfrog.bintray.gradle.BintrayPlugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.JavaPlugin | ||
import org.gradle.api.plugins.JavaPluginExtension | ||
import org.gradle.api.publish.PublishingExtension | ||
import org.gradle.api.publish.maven.MavenPublication | ||
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin | ||
import org.gradle.kotlin.dsl.apply | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.create | ||
import org.gradle.kotlin.dsl.get | ||
import org.gradle.kotlin.dsl.extra | ||
|
||
fun Project.configurePublishing( | ||
name: String, | ||
version: String, | ||
artifactId: String | ||
) { | ||
configureJavaPlugin() | ||
val publication = "${artifactId}Publication" | ||
configureMavenPublishing( | ||
version = version, | ||
artifactId = artifactId, | ||
publication = publication | ||
) | ||
configureBintrayPlugin( | ||
version = version, | ||
artifactId = artifactId, | ||
publication = publication | ||
) | ||
} | ||
|
||
private fun Project.configureJavaPlugin() { | ||
apply<JavaPlugin>() | ||
configure<JavaPluginExtension> { withSourcesJar() } | ||
} | ||
|
||
private fun Project.configureMavenPublishing( | ||
version: String, | ||
artifactId: String, | ||
publication: String | ||
) { | ||
apply<MavenPublishPlugin>() | ||
configure<PublishingExtension> { | ||
publications { | ||
create<MavenPublication>(publication) { | ||
groupId = "com.github.erikhuizinga" | ||
this.artifactId = artifactId | ||
this.version = version | ||
from(components["java"]) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun Project.configureBintrayPlugin( | ||
version: String, | ||
artifactId: String, | ||
publication: String | ||
) { | ||
apply<BintrayPlugin>() | ||
configure<BintrayExtension> { | ||
configure<BintrayExtension> { | ||
dryRun = true | ||
publish = true | ||
user = properties["bintrayUser"] as? String | ||
key = properties["bintrayKey"] as? String | ||
pkg.apply { | ||
this.version.apply { | ||
name = version | ||
vcsTag = "${artifactId}v$version" | ||
} | ||
repo = "maven" | ||
name = artifactId | ||
userOrg = "erikhuizinga" | ||
setLicenses("Apache-2.0") | ||
vcsUrl = "https://github.com/erikhuizinga/mockk-patterns.git" | ||
} | ||
setPublications(publication) | ||
} | ||
} | ||
extra["NAME"] = name | ||
extra["VERSION"] = version | ||
extra["ARTIFACT_ID"] = artifactId | ||
apply(from = "${rootProject.rootDir}/ossrh-publishing.gradle") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
apply plugin: 'java' | ||
apply plugin: 'maven' | ||
apply plugin: 'signing' | ||
|
||
def theArtifactID = ext.ARTIFACT_ID | ||
def theName = ext.NAME | ||
def theVersion = ext.VERSION | ||
|
||
java { | ||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
|
||
javadocJar { | ||
archiveClassifier.set('javadoc') | ||
from javadoc | ||
} | ||
|
||
sourcesJar { | ||
archiveClassifier.set('sources') | ||
from sourceSets.main.allSource | ||
} | ||
|
||
artifacts { | ||
archives sourcesJar, javadocJar | ||
} | ||
|
||
signing { | ||
sign configurations.archives | ||
} | ||
|
||
group = "com.github.erikhuizinga" | ||
archivesBaseName = theArtifactID | ||
version = theVersion | ||
|
||
uploadArchives { | ||
repositories { | ||
mavenDeployer { | ||
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } | ||
|
||
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { | ||
authentication(userName: ossrhUsername, password: ossrhPassword) | ||
} | ||
|
||
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { | ||
authentication(userName: ossrhUsername, password: ossrhPassword) | ||
} | ||
|
||
pom.project { | ||
name = theName | ||
artifactId theArtifactID | ||
description theName | ||
url 'https://github.com/erikhuizinga/mockk-patterns' | ||
|
||
packaging 'jar' | ||
|
||
scm { | ||
connection 'scm:git:git://github.com/erikhuizinga/mockk-patterns.git' | ||
developerConnection 'scm:git:ssh://github.com/erikhuizinga/mockk-patterns.git' | ||
url 'https://github.com/erikhuizinga/mockk-patterns/tree/master' | ||
} | ||
|
||
licenses { | ||
license { | ||
name 'The Apache License, Version 2.0' | ||
url 'http://www.apache.org/licenses/LICENSE-2.0' | ||
} | ||
} | ||
|
||
developers { | ||
developer { | ||
id 'erikhuizinga' | ||
name 'Erik Huizinga' | ||
email '[email protected]' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |