Skip to content

Commit

Permalink
Automate file headers (#5207)
Browse files Browse the repository at this point in the history
Automates license headers and updates generated headers to more clearly indicate what should be changed. Removes spotless exclusions where possible, using file comments instead when necessary. Disables spotless for files not under the dh license.

This will fail to build, the next commit, #5208 will apply these changes across the codebase.

Fixes #1997
  • Loading branch information
niloc132 authored Mar 7, 2024
1 parent 21c02c1 commit 7113b72
Show file tree
Hide file tree
Showing 125 changed files with 1,282 additions and 1,079 deletions.
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

0 comments on commit 7113b72

Please sign in to comment.