Skip to content

Commit

Permalink
Add license header validation on java files
Browse files Browse the repository at this point in the history
- Add license-header.txt file with the expected content of the headers
- Update formatting.gradle on both plugins to validate the license header
- Rename buildSrc directory to formatter
  • Loading branch information
QU3B1M committed Oct 16, 2024
1 parent 7bb8298 commit e878e3b
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 8 deletions.
8 changes: 8 additions & 0 deletions plugins/command-manager/formatter/license-header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
15 changes: 11 additions & 4 deletions plugins/command-manager/gradle/formatting.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

allprojects {
Expand All @@ -9,10 +13,13 @@ allprojects {
java {
target 'src/**/*.java'
removeUnusedImports()
eclipse().configFile rootProject.file('buildSrc/formatterConfig.xml')
eclipse().configFile rootProject.file('formatter/formatterConfig.xml')
trimTrailingWhitespace()
endWithNewline()
}
format("license", {
licenseHeaderFile("${rootProject.file("formatter/license-header.txt")}", "package ");
target("src/*/java/**/*.java")
})
}
precommit.dependsOn 'spotlessJavaCheck'
}
1 change: 1 addition & 0 deletions plugins/setup/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ apply plugin: 'eclipse'
apply plugin: 'opensearch.opensearchplugin'
apply plugin: 'opensearch.yaml-rest-test'
apply plugin: 'opensearch.pluginzip'
apply from: 'gradle/formatting.gradle'

def pluginName = 'wazuh-indexer-setup'
def pluginDescription = 'Wazuh Indexer setup plugin'
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions plugins/setup/formatter/license-header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
15 changes: 11 additions & 4 deletions plugins/setup/gradle/formatting.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

allprojects {
Expand All @@ -9,10 +13,13 @@ allprojects {
java {
target 'src/**/*.java'
removeUnusedImports()
eclipse().configFile rootProject.file('buildSrc/formatterConfig.xml')
eclipse().configFile rootProject.file('formatter/formatterConfig.xml')
trimTrailingWhitespace()
endWithNewline()
}
format("license", {
licenseHeaderFile("${rootProject.file("formatter/license-header.txt")}", "package ");
target("src/*/java/**/*.java")
})
}
precommit.dependsOn 'spotlessJavaCheck'
}

0 comments on commit e878e3b

Please sign in to comment.