Skip to content

Commit 92be926

Browse files
committed
Move to new modules
1 parent f6667a2 commit 92be926

664 files changed

Lines changed: 407 additions & 205 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ jobs:
6969
- name: Compile the native image
7070
run: |
7171
./gradlew -PnativeImage=true \
72-
:palantir-java-format-native:nativeCompile \
73-
:palantir-java-format-jdk-bootstrap:test \
74-
:gradle-palantir-java-format:test
72+
:open-java-format-native:nativeCompile \
73+
:open-java-format-jdk-bootstrap:test \
74+
:gradle-open-java-format:test
7575
7676
- name: Publish Test Report
7777
uses: mikepenz/action-junit-report@d9f48fc87bc235f7e214acf696ca5abc0a986f16 # v6.4.2

‎build.gradle‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ apply plugin: 'com.palantir.idea-language-injector'
3232
// per project below, so error-prone and the JUnit wiring survive.
3333
apply plugin: 'com.palantir.baseline-error-prone-root'
3434
apply plugin: 'com.palantir.baseline-java-versions'
35+
// Maven Central releases: buildSrc/src/main/groovy/open-java-format.release-conventions.gradle.
36+
apply plugin: 'open-java-format.release-conventions'
3537

3638
// GitHub Actions sets GITHUB_REF_TYPE=tag on a tag build; otherwise derive the
3739
// version from git history (needs a full clone: actions/checkout fetch-depth: 0).
@@ -69,7 +71,8 @@ allprojects {
6971
apply plugin: com.palantir.baseline.plugins.BaselineTesting
7072
apply plugin: 'com.palantir.java-format'
7173
apply plugin: 'com.palantir.jakarta-package-alignment'
72-
group = 'com.palantir.javaformat'
74+
// The fork's Maven group (README, "Coordinates"). The Java packages stay com.palantir.javaformat.
75+
group = 'dev.openjavaformat'
7376
version = rootProject.version
7477

7578
tasks.withType(JavaCompile).configureEach {
@@ -97,14 +100,6 @@ allprojects {
97100
subprojects {
98101
apply plugin: 'java-library'
99102

100-
// Publication is plain maven-publish; JReleaser takes it from there.
101-
apply plugin: 'maven-publish'
102-
103-
java {
104-
withSourcesJar()
105-
withJavadocJar()
106-
}
107-
108103
dependencies {
109104
// Gives a version to the JUnit artifacts that plugins add without one.
110105
testImplementation platform(libs.junit.bom)

‎buildSrc/build.gradle‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
plugins {
2+
id 'groovy-gradle-plugin'
3+
}
4+
5+
repositories {
6+
gradlePluginPortal()
7+
}
8+
9+
dependencies {
10+
implementation 'org.jreleaser:org.jreleaser.gradle.plugin:1.26.0'
11+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Applied by every module with a Maven publication: the POM Maven Central requires, and a local
2+
// `staging` repository that JReleaser signs and uploads from (open-java-format.release-conventions).
3+
plugins {
4+
id 'maven-publish'
5+
}
6+
7+
java {
8+
withSourcesJar()
9+
withJavadocJar()
10+
}
11+
12+
// Upstream's jars carry an Implementation-Version, and code reads it back: the Gradle plugin resolves
13+
// the formatter of that version, the IntelliJ plugin reads it off the formatter jar, --version prints it.
14+
tasks.named('jar', Jar) {
15+
manifest {
16+
attributes('Implementation-Version': project.version)
17+
}
18+
}
19+
20+
def stagingDeploy = layout.buildDirectory.dir('staging-deploy')
21+
22+
publishing {
23+
publications.withType(MavenPublication).configureEach { publication ->
24+
pom {
25+
// Conventions, not values: java-gradle-plugin names and describes its plugin marker
26+
// publications itself.
27+
name.convention(provider { "${publication.groupId}:${publication.artifactId}".toString() })
28+
description.convention(provider { project.description ?: project.name })
29+
url = 'https://github.com/openjavaformat/open-java-format'
30+
licenses {
31+
license {
32+
name = 'The Apache Software License, Version 2.0'
33+
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
34+
distribution = 'repo'
35+
}
36+
}
37+
developers {
38+
developer {
39+
name = 'Alexey Abashev'
40+
email = 'alexey@abashev.ru'
41+
}
42+
}
43+
scm {
44+
connection = 'scm:git:https://github.com/openjavaformat/open-java-format.git'
45+
developerConnection = 'scm:git:ssh://git@github.com/openjavaformat/open-java-format.git'
46+
url = 'https://github.com/openjavaformat/open-java-format'
47+
}
48+
}
49+
}
50+
51+
repositories {
52+
maven {
53+
name = 'staging'
54+
url = stagingDeploy
55+
}
56+
}
57+
}
58+
59+
// JReleaser uploads everything it finds in the staging repository, so each staging run starts from an
60+
// empty one: otherwise artifacts left by an earlier run — a dry run, another version — would go too.
61+
def cleanStagingDeploy = tasks.register('cleanStagingDeploy', Delete) {
62+
delete stagingDeploy
63+
}
64+
tasks.withType(PublishToMavenRepository).configureEach {
65+
if (name.endsWith('ToStagingRepository')) {
66+
dependsOn cleanStagingDeploy
67+
}
68+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// Applied to the root project: signs the staged publications and uploads them to the Maven Central
2+
// Portal. `mise run release` runs it; `mise run release:dry-run` rehearses without uploading.
3+
plugins {
4+
id 'base'
5+
id 'org.jreleaser'
6+
}
7+
8+
// What goes to Maven Central. Each of these applies open-java-format.publishing-conventions, which
9+
// stages its publications in build/staging-deploy.
10+
//
11+
// Not released yet: open-java-format-native needs a binary per platform, each from its own CI job,
12+
// and all of them have to go up in one deployment.
13+
def releasedProjects = [
14+
':open-java-format-spi',
15+
':open-java-format',
16+
':open-java-format-jdk-bootstrap',
17+
':gradle-open-java-format',
18+
]
19+
def stagingRepositories = releasedProjects.collect { path ->
20+
relativePath(project(path).layout.buildDirectory.dir('staging-deploy'))
21+
}
22+
23+
jreleaser {
24+
dependsOnAssemble = false
25+
26+
project {
27+
name = 'open-java-format'
28+
description = 'A modern, lambda-friendly, 120-character Java formatter'
29+
license = 'Apache-2.0'
30+
links {
31+
homepage = 'https://github.com/openjavaformat/open-java-format'
32+
}
33+
languages {
34+
java {
35+
groupId = 'dev.openjavaformat'
36+
multiProject = true
37+
version = '21'
38+
}
39+
}
40+
}
41+
42+
release {
43+
github {
44+
enabled = false
45+
}
46+
}
47+
48+
// The key comes from JRELEASER_GPG_SECRET_KEY and JRELEASER_GPG_PASSPHRASE, in the environment or in
49+
// ~/.jreleaser/config.properties. There is no public key to check the signatures against, hence
50+
// verify = false.
51+
signing {
52+
pgp {
53+
active = 'ALWAYS'
54+
armored = true
55+
verify = false
56+
}
57+
}
58+
59+
deploy {
60+
maven {
61+
mavenCentral {
62+
// The deployer's name selects its credentials — the Central Portal user token, as
63+
// JRELEASER_DEPLOY_MAVEN_MAVENCENTRAL_SONATYPE_USERNAME and _PASSWORD.
64+
sonatype {
65+
active = 'ALWAYS'
66+
url = 'https://central.sonatype.com/api/v1/publisher'
67+
namespace = 'dev.openjavaformat'
68+
applyMavenCentralRules = true
69+
stagingRepositories.each { stagingRepository(it) }
70+
}
71+
}
72+
}
73+
}
74+
}
75+
76+
// A release cannot be taken back, and the version comes from `git describe`: anywhere but a clean
77+
// checkout of a release tag it reads like 2.97.0-41-gf6667a2d.dirty. Refuse to upload that.
78+
def releaseVersion = provider { version.toString() }
79+
80+
tasks.named('jreleaserDeploy') {
81+
releasedProjects.each { path ->
82+
dependsOn "${path}:publishAllPublicationsToStagingRepository"
83+
}
84+
doFirst {
85+
if (!dryrun.getOrElse(false) && !(releaseVersion.get() ==~ /\d+\.\d+\.\d+/)) {
86+
throw new GradleException("Refusing to release ${releaseVersion.get()}: check out a release tag on a "
87+
+ 'clean working tree, or pass --dryrun to rehearse without uploading.')
88+
}
89+
}
90+
}

gradle-palantir-java-format/src/main/groovy/com/palantir/javaformat/gradle/ConfigureJavaFormatterXml.groovy renamed to gradle-open-java-format/src/main/groovy/com/palantir/javaformat/gradle/ConfigureJavaFormatterXml.groovy

File renamed without changes.

gradle-palantir-java-format/src/main/groovy/com/palantir/javaformat/gradle/FileUtils.java renamed to gradle-open-java-format/src/main/groovy/com/palantir/javaformat/gradle/FileUtils.java

File renamed without changes.

gradle-palantir-java-format/src/main/groovy/com/palantir/javaformat/gradle/NativeImageAtomicCopy.java renamed to gradle-open-java-format/src/main/groovy/com/palantir/javaformat/gradle/NativeImageAtomicCopy.java

File renamed without changes.

gradle-palantir-java-format/src/main/groovy/com/palantir/javaformat/gradle/PalantirJavaFormatIdeaPlugin.java renamed to gradle-open-java-format/src/main/groovy/com/palantir/javaformat/gradle/PalantirJavaFormatIdeaPlugin.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ public abstract class PalantirJavaFormatIdeaPlugin implements Plugin<Project> {
4747
public void apply(Project rootProject) {
4848
Preconditions.checkState(
4949
rootProject == rootProject.getRootProject(),
50-
"May only apply com.palantir.java-format-idea to the root project");
50+
"May only apply dev.openjavaformat.java-format-idea to the root project");
5151

5252
rootProject.getPlugins().apply(PalantirJavaFormatProviderPlugin.class);
5353
rootProject.getPluginManager().withPlugin("idea", ideaPlugin -> {
5454
TaskProvider<UpdatePalantirJavaFormatIdeaXmlFile> updatePalantirJavaFormatXml = rootProject
5555
.getTasks()
5656
.register("updatePalantirJavaFormatXml", UpdatePalantirJavaFormatIdeaXmlFile.class, task -> {
57-
task.getXmlOutputFile().set(rootProject.file(".idea/palantir-java-format.xml"));
57+
task.getXmlOutputFile().set(rootProject.file(".idea/open-java-format.xml"));
5858
task.getImplementationConfig()
5959
.from(rootProject
6060
.getConfigurations()
@@ -66,7 +66,7 @@ public void apply(Project rootProject) {
6666
.getGradle()
6767
.getGradleUserHomeDir()
6868
.toPath()
69-
.resolve("palantir-java-format-caches/")
69+
.resolve("open-java-format-caches/")
7070
.resolve(Paths.get(task.getNativeImageConfig()
7171
.getSingleFile()
7272
.toURI())
@@ -98,7 +98,7 @@ public void apply(Project rootProject) {
9898
IdeaConfigurationExtension extension = rootProject.getExtensions().getByType(IdeaConfigurationExtension.class);
9999
extension
100100
.getExternalDependencies()
101-
.register("palantir-java-format", dep -> dep.atLeastVersion(MIN_IDEA_PLUGIN_VERSION));
101+
.register("open-java-format", dep -> dep.atLeastVersion(MIN_IDEA_PLUGIN_VERSION));
102102
}
103103

104104
private Optional<Configuration> maybeGetNativeImplConfiguration() {

0 commit comments

Comments
 (0)