Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate file headers #5207

Merged
merged 51 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
43812f1
Configure spotless plugin for license headers
niloc132 Oct 24, 2023
722c16d
Generated headers need an obvious signature
niloc132 Oct 24, 2023
a83308a
Avoid license headers in generated grpc/pb files
niloc132 Oct 24, 2023
481b5d8
Avoid license headers in grpc py files
niloc132 Oct 24, 2023
1f33a7e
Exclude config files
niloc132 Oct 24, 2023
7fdac65
Avoid overwriting replicted headers
niloc132 Oct 24, 2023
7805708
Handle replication for shorter headers
niloc132 Oct 24, 2023
8e0156e
safe replication updates
niloc132 Oct 24, 2023
da8292e
wip
niloc132 Oct 25, 2023
69889b9
Don't replace apache headers in grpc-java
niloc132 Oct 25, 2023
a18bdf9
License header attempt
niloc132 Feb 27, 2024
d4e661c
Attempt to update code generators to match
niloc132 Feb 27, 2024
232a3a2
Add marker for generated headers
niloc132 Feb 27, 2024
d3f0415
Update replication tasks to use the new format
niloc132 Feb 27, 2024
3008408
Allow more files to be spotless'd
niloc132 Feb 27, 2024
18af78e
Update replication to write gradle task to run it
niloc132 Feb 27, 2024
2f517b7
Revert header changes before we review
niloc132 Feb 27, 2024
f7d695b
Temporarily disable spotless headers
niloc132 Feb 27, 2024
702b9e5
Spotless on codegen classes
niloc132 Feb 27, 2024
976fe3d
Spotless on non-generated StateManager types
niloc132 Feb 27, 2024
373a421
Disable formatting on javapoet-generated types
niloc132 Feb 27, 2024
6448485
Adjust comment-consuming code
niloc132 Feb 28, 2024
43354aa
Disable formatting on template files
niloc132 Feb 28, 2024
3b2120f
fix repl primitives
niloc132 Feb 28, 2024
4add80c
disable more formatting
niloc132 Feb 28, 2024
82197ea
Extra newline after generated header
niloc132 Feb 28, 2024
776d564
Python files need some content after license header
niloc132 Feb 29, 2024
a5dc237
Update copyright year
niloc132 Feb 29, 2024
8924a2b
Restore copyright header change, disable all exclusions
niloc132 Feb 29, 2024
d3019c4
Disable formatter for other generated classes
niloc132 Feb 29, 2024
7a78ee9
engine-table primitive codegen
niloc132 Feb 29, 2024
2b2fdaa
Don't re-enable formatting, it will affect replicated types
niloc132 Feb 29, 2024
f81ecb8
Avoid formatting downstream chunk hashers
niloc132 Feb 29, 2024
d1e5595
No need to dedup headers any more
niloc132 Feb 29, 2024
55eb1e5
Share header in 3 places
niloc132 Feb 29, 2024
d029de4
Add headers in more generated files
niloc132 Feb 29, 2024
f4f13da
Disable formatting on generated files
niloc132 Feb 29, 2024
9a2dc5e
No need to suppress here
niloc132 Feb 29, 2024
b279fe5
Always remove, re-apply headers
niloc132 Feb 29, 2024
c96bb3c
Allow header line to disable spotless
niloc132 Feb 29, 2024
39ba0b2
ReplicateHashTable should emit a header
niloc132 Feb 29, 2024
f98eaef
Don't format this file
niloc132 Feb 29, 2024
805fd56
Mark generated segments as not formatted
niloc132 Mar 1, 2024
ae42946
Roll back unnecessary formatting
niloc132 Mar 1, 2024
3bae47c
Always generate code before formatting/checking
niloc132 Mar 1, 2024
d5ee50b
Reinstate spotless excludes for generated proto output
niloc132 Mar 1, 2024
25609dc
Reinstate spotless excludes for generated proto output
niloc132 Mar 1, 2024
b4bd974
Leave generated test reference impl out of spotless
niloc132 Mar 1, 2024
f32b507
Additional excludes
niloc132 Mar 5, 2024
bbca76b
Review feedback from Ryan pt1: remove extra formatter tags, fix task …
niloc132 Mar 6, 2024
13233e6
Restore copyright headers to ftl using correct syntax
niloc132 Mar 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions Base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,3 @@ configurations {
artifacts {
tests jarTests
}

spotless {
java {
targetExclude(
'**/ringbuffer/Aggregating*RingBuffer*.java'
)
}
}
8 changes: 0 additions & 8 deletions ClientSupport/ClientSupport.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,3 @@ dependencies {
implementation project(':Configuration')
implementation depCommonsLang3
}

spotless {
java {
targetExclude(
'**/**ValueTracker.java',
)
}
}
8 changes: 7 additions & 1 deletion Container/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ plugins {

dependencies {
Classpaths.inheritJUnitClassic(project, 'testImplementation')
}
}

spotless {
java {
targetExclude '**/*'
}
}
23 changes: 13 additions & 10 deletions Generators/src/main/java/io/deephaven/gen/GenUtils.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
package io.deephaven.gen;

import gnu.trove.map.TIntObjectMap;
Expand Down Expand Up @@ -38,16 +41,16 @@ public static String indent(final int n) {
* @return The header for a generated java file
*/
public static String javaHeader(final Class<?> generatorClass, final String gradleTask) {
return "/**\n" +
" * Copyright (c) 2016-2023 Deephaven Data Labs and Patent Pending\n" +
" */\n" +
"/****************************************************************************************************************************\n"
+
" ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY - Run " + generatorClass.getSimpleName()
+ " or \"./gradlew " + gradleTask + "\" to regenerate\n"
+
" ****************************************************************************************************************************/\n\n";

return String.join("\n",
"//",
"// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending",
"//",
"// ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY",
"// ****** Run " + generatorClass.getSimpleName() + " or \"./gradlew " + gradleTask
+ "\" to regenerate",
"//",
"// @formatter:off",
"");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,10 @@ private static void generate(final boolean assertNoChange, final String file, fi
final String header3 =
headerSpace + headerComment + " AND THEN RUN GeneratePlottingConvenience " + headerComment;

StringBuilder code = new StringBuilder(header + "\n" + header2 + "\n" + header3 + "\n\n\n");
StringBuilder code = new StringBuilder().append(header).append("\n")
.append(header2).append("\n")
.append(header3).append("\n// @formatter:off\n\n\n");


code.append(
codeFunction(isInterface, new String[] {"x", "y"}, new String[][] {numberTimeTypes, numberTimeTypes},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ private void generateCode(final String devroot, final boolean assertNoChange, fi
final String header3 =
headerSpace + headerComment + " AND THEN RUN GenerateFigureImmutable " + headerComment;

code.append(String.join("\n", header, header2, header3)).append("\n\n");
code.append(String.join("\n", header, header2, header3))
.append("\n// @formatter:off\n\n");


code.append(generateClasses(skip));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
# Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
#

######################################################################################################################
Expand Down
13 changes: 0 additions & 13 deletions Plot/Plot.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,3 @@ dependencies {
testRuntimeOnly project(':log-to-slf4j')
Classpaths.inheritSlf4j(project, 'slf4j-simple', 'testRuntimeOnly')
}

spotless {
java {
targetExclude(
'src/main/java/io/deephaven/plot/Axes.java',
'src/main/java/io/deephaven/plot/AxesImpl.java',
'src/main/java/io/deephaven/plot/Figure.java',
'src/main/java/io/deephaven/plot/FigureImpl.java',
'src/main/java/io/deephaven/plot/PlottingConvenience.java',
'src/main/java/io/deephaven/plot/datasets/multiseries/**'
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private static void generateForService(
grpcServiceName);
JavaFile javaFile = JavaFile.builder(packageName, typeSpec.build())
.addFileComment("\n")
.addFileComment("Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending\n")
.addFileComment("Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending\n")
.addFileComment("\n")
.addFileComment("---------------------------------------------------------------------\n")
.addFileComment("This class is generated by GenerateContextualAuthWiring. DO NOT EDIT!\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private static void generateForService(
service.getName() + "Grpc");
JavaFile javaFile = JavaFile.builder(packageName, typeSpec.build())
.addFileComment("\n")
.addFileComment("Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending\n")
.addFileComment("Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending\n")
.addFileComment("\n")
.addFileComment("------------------------------------------------------------------\n")
.addFileComment("This class is generated by GenerateServiceAuthWiring. DO NOT EDIT!\n")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import com.diffplug.spotless.generic.LicenseHeaderStep

plugins {
id 'com.diffplug.spotless'
}

spotless {
java {
eclipse().configFile("${rootDir}/style/eclipse-java-google-style.xml")

licenseHeader '''//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//''', '(' + LicenseHeaderStep.DEFAULT_JAVA_HEADER_DELIMITER + '|// (\\*\\*\\*\\*\\*|@formatter:off))'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ plugins {
id 'java'
id 'io.deephaven.java-classpath-conventions'
id 'io.deephaven.java-license-conventions'
id 'io.deephaven.java-header-conventions'
id 'io.deephaven.java-toolchain-conventions'
id 'io.deephaven.java-jar-conventions'
}
Expand Down

This file was deleted.

10 changes: 10 additions & 0 deletions buildSrc/src/main/groovy/io.deephaven.python-wheel.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
plugins {
id 'com.bmuschko.docker-remote-api'
id 'io.deephaven.project.register'
id 'com.diffplug.spotless'
}

import io.deephaven.python.PythonWheelExtension

project.extensions.create('wheel', PythonWheelExtension, project.objects)

spotless {
python {
target '**/*.py'
targetExclude '**/proto/*_pb2*', '**/setup.py', 'docs/**'
licenseHeader '#\n' +
'# Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending\n' +
'#', '[^#]'
}
}
configurations {
pythonWheel
getByName(Dependency.DEFAULT_CONFIGURATION).extendsFrom(pythonWheel)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
*/
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
package io.deephaven.generator.primitivetemplate;

import freemarker.template.Configuration;
Expand Down Expand Up @@ -36,11 +36,16 @@ public static void main(final String[] args) throws Exception {
final Writer fileWriter = new FileWriter(new File(outputFile));

fileWriter.write(
"/**********************************************************************************\n" +
"* DO NOT EDIT THIS FILE.\n" +
"* This code was auto-generated from " + templateFile + " by CodeGenerator.\n" +
"* Manual changes to this file will be lost.\n" +
"***********************************************************************************/\n\n");
String.join("\n",
"//",
"// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending",
"//",
"// ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY",
"// ****** Edit " + templateFile
+ " and run \"./gradlew :engine-function:compileJava\" to regenerate",
"//",
"// @formatter:off",
""));

try {
template.process(input, fileWriter);
Expand Down
11 changes: 11 additions & 0 deletions cpp-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ plugins {
id 'com.bmuschko.docker-remote-api'
id 'io.deephaven.project.register'
id 'io.deephaven.deephaven-in-docker'
id 'com.diffplug.spotless'
}

spotless {
cpp {
target '**/*.cc', '**/*.h'
targetExclude '**/Barrage_generated.h', '**/third_party/**', '**/*.pb.*'
licenseHeader '''/*
* Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
*/'''
}
}

// We use the cpp-clients-multi-base image instead of the cpp-client-base,
Expand Down
16 changes: 0 additions & 16 deletions engine/api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,3 @@ dependencies {

Classpaths.inheritJUnitClassic(project, 'testImplementation')
}

spotless {
java {
targetExclude(
'**/*Boolean*.java',
'**/*Byte*.java',
'**/*Char*.java',
'**/*Short*.java',
'**/*Int*.java',
'**/*Long*.java',
'**/*Float*.java',
'**/*Double*.java',
'**/*Object*.java',
)
}
}
16 changes: 0 additions & 16 deletions engine/benchmark/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,6 @@ dependencies {
testRuntimeOnly project(path: ':test-configs')
}

spotless {
java {
targetExclude(
'**/Boolean*Benchmark.java',
'**/Byte*Benchmark.java',
'**/Char*Benchmark.java',
'**/Short*Benchmark.java',
'**/Int*Benchmark.java',
'**/Long*Benchmark.java',
'**/Float*Benchmark.java',
'**/Double*Benchmark.java',
'**/Object*Benchmark.java',
)
}
}

task jmhRun(type: JavaExec) {
new File("$rootDir/tmp/workspace").mkdirs()
new File("$rootDir/tmp/logs").mkdirs()
Expand Down
16 changes: 0 additions & 16 deletions engine/chunk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,3 @@ dependencies {
project(path: ':test-configs')
Classpaths.inheritSlf4j(project, 'slf4j-simple', 'testRuntimeOnly')
}

spotless {
java {
targetExclude(
'**/*Boolean*.java',
'**/*Byte*.java',
'**/*Char*.java',
'**/*Short*.java',
'**/*Int*.java',
'**/*Long*.java',
'**/*Float*.java',
'**/*Double*.java',
'**/*Object*.java',
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
*/
package io.deephaven.chunk;

// @formatter:off

import io.deephaven.chunk.attributes.Any;
import io.deephaven.chunk.util.pools.MultiChunkPool;

Expand All @@ -23,8 +21,6 @@

import static io.deephaven.chunk.util.pools.ChunkPoolConstants.POOL_WRITABLE_CHUNKS;

// @formatter:on

/**
* {@link WritableChunk} implementation for char data.
*/
Expand Down
13 changes: 6 additions & 7 deletions engine/function/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ dependencies {
def generatedFiles = []


spotless {
java {
targetExclude generatedFiles
}
}


//////////////// Code Generation ////////////////

// task to clean up generated files
Expand All @@ -52,6 +45,12 @@ def gencode = { name, template, output ->
inputs.file template
outputs.file output
}
tasks.named('spotlessJava').configure {
mustRunAfter gen
}
tasks.named('spotlessJavaCheck').configure {
mustRunAfter gen
}

[sourceSets.main.compileJavaTaskName, sourceSets.main.sourcesJarTaskName, sourceSets.main.javadocTaskName].each {
tasks.named(it).configure {
Expand Down
6 changes: 3 additions & 3 deletions engine/function/src/templates/Basic.ftl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2016-2021 Deephaven Data Labs and Patent Pending
*/
<#--
Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
-->

package io.deephaven.function;

Expand Down
3 changes: 3 additions & 0 deletions engine/function/src/templates/BinSearch.ftl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<#--
Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
-->

package io.deephaven.function;

Expand Down
6 changes: 3 additions & 3 deletions engine/function/src/templates/Cast.ftl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2016-2021 Deephaven Data Labs and Patent Pending
*/
<#--
Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
-->

package io.deephaven.function;

Expand Down
3 changes: 3 additions & 0 deletions engine/function/src/templates/Numeric.ftl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<#--
Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
-->

package io.deephaven.function;

Expand Down
3 changes: 3 additions & 0 deletions engine/function/src/templates/Sort.ftl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<#--
Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
-->

package io.deephaven.function;

Expand Down
6 changes: 3 additions & 3 deletions engine/function/src/templates/TestBasic.ftl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2016-2021 Deephaven Data Labs and Patent Pending
*/
<#--
Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
-->

package io.deephaven.function;

Expand Down
Loading
Loading