Skip to content

Commit

Permalink
Add BOM (#2049)
Browse files Browse the repository at this point in the history
  • Loading branch information
devinrsmith authored Feb 28, 2022
1 parent e57e24b commit fdbf13a
Show file tree
Hide file tree
Showing 13 changed files with 314 additions and 158 deletions.
17 changes: 17 additions & 0 deletions bom/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plugins {
id 'io.deephaven.project.register'
}

description = 'Deephaven Bill of Materials'

dependencies {
constraints { constraint ->
project.rootProject
.subprojects
.findAll { p -> io.deephaven.project.ProjectType.isPublic(p) }
.each { p ->
// TODO(deephaven-core#2050): Annotate some public dependencies with "runtime" constraint
constraint.api p
}
}
}
1 change: 1 addition & 0 deletions bom/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.deephaven.project.ProjectType=BOM_PUBLIC
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import io.deephaven.project.util.PublishingConstants

plugins {
id 'java'
id 'signing'
Expand All @@ -17,119 +19,25 @@ tasks.withType(Javadoc) {
options.addStringOption('sourcepath', sourceSets.main.allJava.getSourceDirectories().getAsPath())
}

def developerId = 'deephaven'
def developerName = 'Deephaven Developers'
def developerEmail = '[email protected]'

def projectUrl = 'https://github.com/deephaven/deephaven-core'
def orgName = 'Deephaven Data Labs'
def orgUrl = 'https://deephaven.io/'

def licenseName = ext.license.name
def licenseUrl = ext.license.url

def issuesSystem = 'GitHub Issues'
def issuesUrl = 'https://github.com/deephaven/deephaven-core/issues'

def scmUrl = 'https://github.com/deephaven/deephaven-core'
def scmConnection = 'scm:git:git://github.com/deephaven/deephaven-core.git'
def scmDevConnection = 'scm:git:ssh://github.com/deephaven/deephaven-core.git'

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
url = projectUrl
organization {
name = orgName
url = orgUrl
}
licenses {
license {
name = licenseName
url = licenseUrl
}
}
scm {
url = scmUrl
connection = scmConnection
developerConnection = scmDevConnection
}
issueManagement {
system = issuesSystem
url = issuesUrl
}
developers {
developer {
id = developerId
name = developerName
email = developerEmail
organization = orgName
organizationUrl = orgUrl
}
}
}
}
}
repositories {
maven {
name = 'ossrh'
// ossrhUsername, ossrhPassword
credentials(PasswordCredentials)
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}
}
}

signing {
sign publishing.publications.mavenJava
String signingKey = findProperty("signingKey")
String signingPassword = findProperty("signingPassword")
if (signingKey != null && signingPassword != null) {
// In CI, it's harder to pass a file; so if specified, we use the in-memory version.
useInMemoryPgpKeys(signingKey, signingPassword)
}
}

def assertIsRelease = tasks.register('assertIsRelease') {
it.doLast {
if (System.getenv('CI') != 'true') {
throw new IllegalStateException('Release error: env CI must be true')
}
def actualGithubRef = System.getenv('GITHUB_REF')
def expectedGithubRef = "refs/heads/release/v${project.version}"
if (actualGithubRef != expectedGithubRef) {
throw new IllegalStateException("Release error: env GITHUB_REF '${actualGithubRef}' does not match expected '${expectedGithubRef}'. Bad tag? Bump version?")
}
}
}

// This is an extra safety checks to make sure we don't publish incorrectly
publishMavenJavaPublicationToOssrhRepository.dependsOn(assertIsRelease)

afterEvaluate {
// https://central.sonatype.org/publish/requirements/
if (project.description == null) {
throw new IllegalStateException("Project '${project.name}' is missing a description, which is required for publishing to maven central")
}

// The common-conventions plugin should take care of this, but we'll double-check here
if (!project.archivesBaseName.contains('deephaven')) {
throw new IllegalStateException("Project '${project.name}' archiveBaseName '${project.archivesBaseName}' does not contain 'deephaven'")
}

publishing {
publications {
mavenJava(MavenPublication) {
artifactId = archivesBaseName
pom {
name = archivesBaseName
description = project.description
}
}
}
}
}
PublishingConstants.setupRepositories(project)
PublishingConstants.setupMavenPublication(project, publishing.publications.mavenJava)
PublishingConstants.setupSigning(project, publishing.publications.mavenJava)
33 changes: 33 additions & 0 deletions buildSrc/src/main/groovy/io.deephaven.project.bom-public.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import io.deephaven.project.util.JavaDependencies
import io.deephaven.project.util.PublishingConstants

plugins {
id 'io.deephaven.common-conventions'
id 'java-platform'
id 'maven-publish'
id 'signing'
}

publishing {
publications {
myPlatform(MavenPublication) {
from components.javaPlatform
pom {
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
}
}
}
}

PublishingConstants.setupRepositories(project)
PublishingConstants.setupMavenPublication(project, publishing.publications.myPlatform)
PublishingConstants.setupSigning(project, publishing.publications.myPlatform)

project.tasks
.getByName('quick')
.dependsOn JavaDependencies.verifyAllConfigurationsArePublicTask(project)
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import io.deephaven.project.util.JavaDependencies

plugins {
id 'io.deephaven.common-conventions'
id 'io.deephaven.java-common-conventions'
Expand All @@ -6,3 +8,7 @@ plugins {
id 'io.deephaven.java-publishing-conventions'
id 'io.deephaven.default-description'
}

project.tasks
.getByName('quick')
.dependsOn JavaDependencies.verifyRuntimeClasspathIsPublicTask(project)
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import io.deephaven.project.util.JavaDependencies

plugins {
id 'io.deephaven.common-conventions'
id 'io.deephaven.java-common-conventions'
Expand All @@ -6,3 +8,7 @@ plugins {
id 'io.deephaven.java-publishing-conventions'
id 'io.deephaven.default-description'
}

project.tasks
.getByName('quick')
.dependsOn JavaDependencies.verifyRuntimeClasspathIsPublicTask(project)
16 changes: 16 additions & 0 deletions buildSrc/src/main/groovy/io.deephaven.project.root.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
import io.deephaven.project.ProjectType

plugins {
id 'io.deephaven.common-conventions'
}

def verifyAllProjectsRegistered = project.tasks.register('verifyAllProjectsRegistered') { task ->
task.doLast {
project.allprojects { Project p ->
if (!ProjectType.isRegistered(p)) {
throw new IllegalStateException("Project '${project.name}' has not registered. Please apply the plugin 'io.deephaven.project.register'.")
}
}
}
}

project.tasks
.getByName('quick')
.dependsOn verifyAllProjectsRegistered
66 changes: 9 additions & 57 deletions buildSrc/src/main/groovy/io/deephaven/project/ProjectType.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package io.deephaven.project

import groovy.transform.CompileStatic
import io.deephaven.project.util.JavaDependencies
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.plugins.JavaPlatformPlugin
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.tasks.TaskProvider

@CompileStatic
enum ProjectType {
Expand All @@ -15,25 +14,16 @@ enum ProjectType {
JAVA_EXTERNAL(true, 'io.deephaven.project.java-external'),
JAVA_LOCAL(false, 'io.deephaven.project.java-local'),
JAVA_PUBLIC(true, 'io.deephaven.project.java-public'),
BOM_PUBLIC(true, 'io.deephaven.project.bom-public'),
ROOT(false, 'io.deephaven.project.root');

public static final String VERIFY_ALL_PROJECTS_REGISTERED_TASK_NAME = 'verifyAllProjectsRegistered'

public static final String VERIFY_RUNTIME_CLASSPATH_IS_PUBLIC_TASK_NAME = 'verifyRuntimeClasspathIsPublic'

static void register(Project project) {
ProjectType type = getType(project)
if (type == ROOT && project.rootProject != project) {
throw new IllegalStateException("Project '${project.name}' is likely inheriting the 'ROOT' type - please set the property 'io.deephaven.project.ProjectType' as appropriate.")
}

project.pluginManager.apply(type.pluginId)
registerInternal(project, type)
if (type == ROOT) {
project.tasks
.getByName('quick')
.dependsOn verifyAllRegisteredTask(project)
}
project.pluginManager.apply(type.pluginId)
}

private static void registerInternal(Project project, ProjectType projectType) {
Expand All @@ -44,51 +34,8 @@ enum ProjectType {
" - is already registered with the type '${ext.get(key)}'")
}
ext.set(key, projectType)
if (projectType.isPublic) {
project.tasks
.getByName('quick')
.dependsOn verifyRuntimeClasspathIsPublicTask(project)
}
}

private static TaskProvider<Task> verifyRuntimeClasspathIsPublicTask(Project project) {
return project.tasks.register(VERIFY_RUNTIME_CLASSPATH_IS_PUBLIC_TASK_NAME) { task ->
task.doLast {
verifyRuntimeClasspathIsPublic(project)
}
}
}

private static void verifyRuntimeClasspathIsPublic(Project project) {
project
.configurations
.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)
.getAllDependencies()
.findAll { it instanceof ProjectDependency }
.collect { ((ProjectDependency)it).dependencyProject }
.each {
if (!isPublic(it)) {
throw new IllegalStateException("Public project '${project.name}' has a dependency on a non-public project '${it.name}'")
}
}
}

private static TaskProvider<Task> verifyAllRegisteredTask(Project project) {
return project.tasks.register(VERIFY_ALL_PROJECTS_REGISTERED_TASK_NAME) { task ->
task.doLast {
project.allprojects { Project p ->
verifyRegistered(p)
}
}
}
}

private static void verifyRegistered(Project project) {
def ext = project.extensions.extraProperties
if (!ext.has("${ProjectType.class.name}.isRegistered")) {
throw new IllegalStateException("Project '${project.name}' has not registered. Please apply the plugin 'io.deephaven.project.register'.")
}
}

static ProjectType getType(Project project) {
def typeString = project.findProperty('io.deephaven.project.ProjectType') as String
Expand All @@ -98,6 +45,11 @@ enum ProjectType {
return valueOf(typeString)
}

static boolean isRegistered(Project project) {
def ext = project.extensions.extraProperties
return ext.has("${ProjectType.class.name}.isRegistered")
}

static boolean isPublic(Project project) {
return getType(project).isPublic
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.deephaven.project.util

import groovy.transform.CompileStatic
import io.deephaven.project.ProjectType
import org.gradle.api.Project

@CompileStatic
class CombinedJavadoc {

static boolean includeProject(Project p) {
ProjectType type = ProjectType.getType(p)
if (!type.isPublic) {
return false
}
switch (type) {
case ProjectType.BOM_PUBLIC:
return false
case ProjectType.JAVA_EXTERNAL:
case ProjectType.JAVA_PUBLIC:
return true
default:
throw new IllegalStateException("Unsure if public project type '${type}' is supposed to be included in combined-javadoc.")
}
}
}
Loading

0 comments on commit fdbf13a

Please sign in to comment.