Skip to content

Commit bfe1849

Browse files
author
ntwigg
committed
Spotless and fix plugin publishing.
1 parent e644715 commit bfe1849

File tree

4 files changed

+75
-33
lines changed

4 files changed

+75
-33
lines changed

gradle.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ org=diffplug
55
license=apache
66
git_url=github.com/diffplug/webtools
77
plugin_tags=node
8-
plugin_list=node jte
8+
plugin_list=node jte flywayjooq
99

1010
ver_java=21
1111

@@ -20,3 +20,8 @@ plugin_jte_id=com.diffplug.webtools.jte
2020
plugin_jte_impl=com.diffplug.webtools.jte.JtePlugin
2121
plugin_jte_name=DiffPlug JTE
2222
plugin_jte_desc=Runs the JTE plugin and adds typesafe model classes
23+
24+
plugin_flywayjooq_id=com.diffplug.webtools.flywayjooq
25+
plugin_flywayjooq_impl=com.diffplug.webtools.flywayjooq.FlywayJooqPlugin
26+
plugin_flywayjooq_name=DiffPlug Flyway jOOQ
27+
plugin_flywayjooq_desc=Coordinates Docker Compose, Flyway, and jOOQ for fast testing and easy deployment.

src/main/java/com/diffplug/webtools/flywayjooq/FlywayJooqPlugin.java

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
1+
/*
2+
* Copyright (C) 2025 DiffPlug
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.diffplug.webtools.flywayjooq;
217

18+
import java.net.URL;
19+
import java.net.URLClassLoader;
20+
import java.util.regex.Matcher;
21+
import java.util.regex.Pattern;
22+
import javax.inject.Inject;
323
import org.gradle.api.DefaultTask;
424
import org.gradle.api.Plugin;
525
import org.gradle.api.Project;
@@ -16,12 +36,6 @@
1636
import org.gradle.api.tasks.TaskProvider;
1737
import org.jooq.codegen.gradle.CodegenPluginExtension;
1838

19-
import javax.inject.Inject;
20-
import java.net.URL;
21-
import java.net.URLClassLoader;
22-
import java.util.regex.Matcher;
23-
import java.util.regex.Pattern;
24-
2539
/**
2640
* This plugin spools up a fresh postgres session,
2741
* runs flyway on it, then runs jooq on the result.
@@ -34,9 +48,8 @@ public class FlywayJooqPlugin implements Plugin<Project> {
3448
public static class Extension extends CodegenPluginExtension {
3549
@Inject
3650
public Extension(
37-
ObjectFactory objects,
38-
ProjectLayout layout
39-
) {
51+
ObjectFactory objects,
52+
ProjectLayout layout) {
4053
super(objects, layout);
4154
}
4255

@@ -131,7 +144,6 @@ public void dockerDown() throws Exception {
131144
}
132145
}
133146

134-
135147
/** Detects the jooq version. */
136148
private static String detectJooqVersion() {
137149
URLClassLoader loader = (URLClassLoader) FlywayJooqPlugin.class.getClassLoader();

src/main/java/com/diffplug/webtools/flywayjooq/JooqTask.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1+
/*
2+
* Copyright (C) 2025 DiffPlug
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.diffplug.webtools.flywayjooq;
217

318
import com.diffplug.common.base.Preconditions;
419
import com.diffplug.common.base.Throwables;
20+
import java.io.File;
21+
import java.net.ConnectException;
522
import org.gradle.api.DefaultTask;
623
import org.gradle.api.GradleException;
724
import org.gradle.api.file.DirectoryProperty;
@@ -11,9 +28,6 @@
1128
import org.jooq.meta.jaxb.Generator;
1229
import org.jooq.meta.jaxb.Logging;
1330

14-
import java.io.File;
15-
import java.net.ConnectException;
16-
1731
@CacheableTask
1832
public abstract class JooqTask extends DefaultTask {
1933
SetupCleanupDockerFlyway setup;
@@ -59,4 +73,3 @@ public void generate() throws Exception {
5973
}
6074
}
6175
}
62-

src/main/java/com/diffplug/webtools/flywayjooq/SetupCleanupDockerFlyway.java

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
/*
2+
* Copyright (C) 2025 DiffPlug
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.diffplug.webtools.flywayjooq;
217

318
import com.diffplug.common.base.Either;
419
import com.diffplug.common.base.Errors;
520
import com.diffplug.common.base.Throwables;
621
import com.diffplug.common.base.Throwing;
22+
import com.diffplug.webtools.node.SetupCleanup;
723
import com.google.common.collect.ImmutableList;
824
import com.google.common.io.ByteStreams;
925
import com.google.common.io.Files;
@@ -15,12 +31,6 @@
1531
import com.palantir.docker.compose.execution.DockerCompose;
1632
import com.palantir.docker.compose.execution.DockerComposeExecArgument;
1733
import com.palantir.docker.compose.execution.DockerComposeExecOption;
18-
import org.flywaydb.core.Flyway;
19-
import org.gradle.api.GradleException;
20-
import org.postgresql.ds.PGSimpleDataSource;
21-
import webtools.Env;
22-
import com.diffplug.webtools.node.SetupCleanup;
23-
2434
import java.io.*;
2535
import java.nio.charset.StandardCharsets;
2636
import java.nio.file.FileVisitResult;
@@ -29,6 +39,10 @@
2939
import java.nio.file.attribute.BasicFileAttributes;
3040
import java.util.*;
3141
import java.util.concurrent.TimeUnit;
42+
import org.flywaydb.core.Flyway;
43+
import org.gradle.api.GradleException;
44+
import org.postgresql.ds.PGSimpleDataSource;
45+
import webtools.Env;
3246

3347
public class SetupCleanupDockerFlyway implements Serializable {
3448
private static final long serialVersionUID = -8606504827780656288L;
@@ -71,7 +85,6 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
7185
}
7286
}
7387

74-
7588
void forceStop(File projectDir) throws Exception {
7689
try {
7790
new Impl().doStop(this);
@@ -107,8 +120,8 @@ PGSimpleDataSource getConnection() throws IOException {
107120
port = Integer.parseInt(connectionProps.getProperty("port"));
108121
}
109122
PGSimpleDataSource dataSource = new PGSimpleDataSource();
110-
dataSource.setServerNames(new String[] {ip});
111-
dataSource.setPortNumbers(new int[] {port});
123+
dataSource.setServerNames(new String[]{ip});
124+
dataSource.setPortNumbers(new int[]{port});
112125
dataSource.setUser("root");
113126
dataSource.setPassword("password");
114127
dataSource.setDatabaseName("template1");
@@ -144,7 +157,6 @@ public static void keepTrying(Throwing.Runnable toAttempt) {
144157
}
145158
}
146159

147-
148160
DockerComposeRule rule() {
149161
return DockerComposeRule.builder()
150162
.file(dockerComposeFile.getAbsolutePath())
@@ -187,19 +199,19 @@ protected void doStart(SetupCleanupDockerFlyway key) throws IOException, Interru
187199
PGSimpleDataSource postgres = key.getConnection();
188200
keepTrying(() -> {
189201
Flyway.configure()
190-
.dataSource(postgres)
191-
.locations("filesystem:" + key.flywayMigrations.getAbsolutePath())
192-
.schemas("public")
193-
.load()
194-
.migrate();
202+
.dataSource(postgres)
203+
.locations("filesystem:" + key.flywayMigrations.getAbsolutePath())
204+
.schemas("public")
205+
.load()
206+
.migrate();
195207
});
196208

197209
// write out the schema to disk
198210
String schema;
199211
List<String> pg_dump_args = Arrays.asList("-d", "template1", "-U", postgres.getUser(), "--schema-only", "--restrict-key=reproduciblediff");
200212
if (rule == null) {
201-
Process process = Runtime.getRuntime().exec(ImmutableList.<String>builder().add(
202-
"pg_dump",
213+
Process process = Runtime.getRuntime().exec(ImmutableList.<String> builder().add(
214+
"pg_dump",
203215
"-h", GITHUB_IP, "-p", Integer.toString(GITHUB_PORT))
204216
.addAll(pg_dump_args).build().toArray(new String[0]));
205217
// swallow errors (not great...)
@@ -212,7 +224,7 @@ protected void doStart(SetupCleanupDockerFlyway key) throws IOException, Interru
212224
schema = rule.dockerCompose().exec(DockerComposeExecOption.noOptions(),
213225
"postgres", DockerComposeExecArgument.arguments(ImmutableList.builder().add("pg_dump")
214226
.addAll(pg_dump_args)
215-
.build().toArray(new String[0])));
227+
.build().toArray(new String[0])));
216228
}
217229
Files.createParentDirs(key.flywaySchemaDump);
218230
Files.write(schema, key.flywaySchemaDump, StandardCharsets.UTF_8);

0 commit comments

Comments
 (0)