-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shade antlr dependency for partiql-parser and partiql-lang (#1439)
- Loading branch information
Showing
13 changed files
with
196 additions
and
79 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 |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
|
||
package org.partiql.gradle.plugin.publish | ||
|
||
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin | ||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.JavaPlugin | ||
|
@@ -38,7 +40,7 @@ import java.io.File | |
|
||
/** | ||
* Gradle plugin to consolidates the following publishing logic | ||
* - Maven Publising | ||
* - Maven Publishing | ||
* - Signing | ||
* - SourcesJar | ||
* - Dokka + JavadocJar | ||
|
@@ -51,6 +53,7 @@ abstract class PublishPlugin : Plugin<Project> { | |
pluginManager.apply(MavenPublishPlugin::class.java) | ||
pluginManager.apply(SigningPlugin::class.java) | ||
pluginManager.apply(DokkaPlugin::class.java) | ||
pluginManager.apply(ShadowPlugin::class.java) | ||
extensions.getByType(KotlinJvmProjectExtension::class.java).explicitApi = ExplicitApiMode.Strict | ||
val ext = extensions.create("publish", PublishExtension::class.java) | ||
target.afterEvaluate { publish(ext) } | ||
|
@@ -85,58 +88,98 @@ abstract class PublishPlugin : Plugin<Project> { | |
from(tasks.named("dokkaHtml")) | ||
} | ||
|
||
tasks.getByName<ShadowJar>("shadowJar") { | ||
// Use the default name for published shadow jar | ||
archiveClassifier.set("") | ||
} | ||
|
||
tasks.getByName<Jar>("jar") { | ||
// Rename jar for `project` dependencies; not published to Maven | ||
archiveClassifier.set("original") | ||
} | ||
|
||
// Setup Maven Central Publishing | ||
val publishing = extensions.getByType(PublishingExtension::class.java).apply { | ||
publications { | ||
create<MavenPublication>("maven") { | ||
artifactId = ext.artifactId | ||
from(components["java"]) | ||
pom { | ||
packaging = "jar" | ||
name.set(ext.name) | ||
description.set(ext.description) | ||
url.set(ext.url) | ||
scm { | ||
connection.set("scm:[email protected]:partiql/partiql-lang-kotlin.git") | ||
developerConnection.set("scm:[email protected]:partiql/partiql-lang-kotlin.git") | ||
url.set("[email protected]:partiql/partiql-lang-kotlin.git") | ||
} | ||
licenses { | ||
license { | ||
name.set("The Apache License, Version 2.0") | ||
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") | ||
afterEvaluate { | ||
val publishing = extensions.getByType(PublishingExtension::class.java).apply { | ||
publications { | ||
create<MavenPublication>("maven") { | ||
// Publish the shadow jar; create dependencies separately since `ShadowExtension.component` | ||
// does not include non-shadowed in POM dependencies | ||
artifact(tasks["shadowJar"]) | ||
artifact(tasks["sourcesJar"]) | ||
artifact(tasks["javadocJar"]) | ||
artifactId = ext.artifactId | ||
pom { | ||
packaging = "jar" | ||
name.set(ext.name) | ||
description.set(ext.description) | ||
url.set(ext.url) | ||
scm { | ||
connection.set("scm:[email protected]:partiql/partiql-lang-kotlin.git") | ||
developerConnection.set("scm:[email protected]:partiql/partiql-lang-kotlin.git") | ||
url.set("[email protected]:partiql/partiql-lang-kotlin.git") | ||
} | ||
} | ||
developers { | ||
developer { | ||
name.set("PartiQL Team") | ||
email.set("[email protected]") | ||
organization.set("PartiQL") | ||
organizationUrl.set("https://github.com/partiql") | ||
licenses { | ||
license { | ||
name.set("The Apache License, Version 2.0") | ||
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") | ||
} | ||
} | ||
developers { | ||
developer { | ||
name.set("PartiQL Team") | ||
email.set("[email protected]") | ||
organization.set("PartiQL") | ||
organizationUrl.set("https://github.com/partiql") | ||
} | ||
} | ||
// Publish the dependencies | ||
withXml { | ||
val dependenciesNode = asNode().appendNode("dependencies") | ||
val apiDeps = project.configurations["api"].allDependencies | ||
.filter { it.name !in ext.excludedDependencies } | ||
val implDeps = project.configurations["implementation"].allDependencies | ||
.filter { it !in apiDeps && it.name !in ext.excludedDependencies } | ||
// Add Gradle 'api' dependencies; mapped to Maven 'compile' | ||
apiDeps.forEach { dependency -> | ||
val dependencyNode = dependenciesNode.appendNode("dependency") | ||
dependencyNode.appendNode("groupId", dependency.group) | ||
dependencyNode.appendNode("artifactId", dependency.name) | ||
dependencyNode.appendNode("version", dependency.version) | ||
dependencyNode.appendNode("scope", "compile") | ||
} | ||
// Add Gradle 'implementation' dependencies; mapped to Maven 'runtime' | ||
implDeps.forEach { dependency -> | ||
val dependencyNode = dependenciesNode.appendNode("dependency") | ||
dependencyNode.appendNode("groupId", dependency.group) | ||
dependencyNode.appendNode("artifactId", dependency.name) | ||
dependencyNode.appendNode("version", dependency.version) | ||
dependencyNode.appendNode("scope", "runtime") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
repositories { | ||
maven { | ||
url = uri("https://aws.oss.sonatype.org/service/local/staging/deploy/maven2") | ||
credentials { | ||
val ossrhUsername: String by rootProject | ||
val ossrhPassword: String by rootProject | ||
username = ossrhUsername | ||
password = ossrhPassword | ||
repositories { | ||
maven { | ||
url = uri("https://aws.oss.sonatype.org/service/local/staging/deploy/maven2") | ||
credentials { | ||
val ossrhUsername: String by rootProject | ||
val ossrhPassword: String by rootProject | ||
username = ossrhUsername | ||
password = ossrhPassword | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Sign only if publishing to Maven Central | ||
extensions.getByType(SigningExtension::class.java).run { | ||
setRequired { | ||
releaseVersion && gradle.taskGraph.allTasks.any { it is PublishToMavenRepository } | ||
// Sign only if publishing to Maven Central | ||
extensions.getByType(SigningExtension::class.java).run { | ||
setRequired { | ||
releaseVersion && gradle.taskGraph.allTasks.any { it is PublishToMavenRepository } | ||
} | ||
sign(publishing.publications["maven"]) | ||
} | ||
sign(publishing.publications["maven"]) | ||
} | ||
} | ||
} | ||
|
@@ -146,6 +189,7 @@ abstract class PublishExtension { | |
var name: String = "" | ||
var description: String = "" | ||
var url: String = "https://github.com/partiql/partiql-lang-kotlin" | ||
var excludedDependencies: Set<String> = setOf() | ||
override fun toString(): String { | ||
return "PublishExtension(artifactId='$artifactId', name='$name', description='$description', url='$url')" | ||
} | ||
|
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
Binary file not shown.
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,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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
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
Oops, something went wrong.