Skip to content

Commit 86c0af0

Browse files
authored
Automate license headers (#266)
* Automate license headers Adds the [`com.github.hierynomus.license`][plugin] Gradle plugin that will verify all source files have license header when the `check` task runs (i.e. tests). The plugin automates adding headers to files that are missing it (i.e. check failures) by running the `licenseFormatMain` or `licenseFormatTest` task, depending on which source set the file belongs to. See [plugin][] documentation for more information. [plugin]: https://github.com/hierynomus/license-gradle-plugin * Use finalizedBy to not gate tests from runing * Dont need to link license task to check * Update CONTRIBUTING; Add missing license headers
1 parent 8b4a1d2 commit 86c0af0

File tree

7 files changed

+92
-1
lines changed

7 files changed

+92
-1
lines changed

CONTRIBUTING.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ Refer to the [Google Java Style Guide](https://google.github.io/styleguide/javag
2727

2828
## License
2929

30-
All contributions are under the CLA mentioned above. For this project, Optimizely uses the Apache 2.0 license, and so asks that by contributing your code, you agree to license your contribution under the terms of the [Apache License v2.0](http://www.apache.org/licenses/LICENSE-2.0). Your contributions should also include the following header:
30+
All contributions are under the CLA mentioned above.
31+
32+
For this project, Optimizely uses the Apache 2.0 license, and so asks that by contributing your code, you agree to license your contribution under the terms of the [Apache License v2.0](http://www.apache.org/licenses/LICENSE-2.0).
33+
34+
Your contributions should also include the following header:
3135

3236
```
3337
/****************************************************************************
@@ -49,6 +53,10 @@ All contributions are under the CLA mentioned above. For this project, Optimizel
4953

5054
The YEAR above should be the year of the contribution. If work on the file has been done over multiple years, list each year in the section above. Example: Optimizely writes the file and releases it in 2014. No changes are made in 2015. Change made in 2016. YEAR should be “2014, 2016”.
5155

56+
This project contains Gradle tasks that check the correct license header exists
57+
in each file. Contributors can use the `./gradlew licenseFormat` command to
58+
automatically insert missing license headers.
59+
5260
## Contact
5361

5462
If you have questions, please contact developers@optimizely.com.

build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ plugins {
1616
id 'jacoco'
1717
id 'me.champeau.gradle.jmh' version '0.4.5'
1818
id 'nebula.optional-base' version '3.2.0'
19+
id 'com.github.hierynomus.license' version '0.15.0'
1920
}
2021

2122
allprojects {
@@ -49,6 +50,7 @@ subprojects {
4950
apply plugin: 'maven-publish'
5051
apply plugin: 'me.champeau.gradle.jmh'
5152
apply plugin: 'nebula.optional-base'
53+
apply plugin: 'com.github.hierynomus.license'
5254

5355
sourceCompatibility = 1.8
5456
targetCompatibility = 1.8
@@ -148,6 +150,14 @@ subprojects {
148150
}
149151
}
150152

153+
license {
154+
header = rootProject.file("resources/HEADER")
155+
skipExistingHeaders = true
156+
include "**/*.java"
157+
ext.author = "Optimizely"
158+
ext.year = Calendar.getInstance().get(Calendar.YEAR)
159+
}
160+
151161
def bintrayName = 'core-api';
152162
if (name.equals('core-httpclient-impl')) {
153163
bintrayName = 'httpclient'

core-api/src/main/java/com/optimizely/ab/config/audience/EmptyCondition.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2019, Optimizely Inc. and contributors
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+
* http://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.optimizely.ab.config.audience;
217

318
import com.optimizely.ab.config.ProjectConfig;

core-api/src/main/java/com/optimizely/ab/config/audience/NullCondition.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2019, Optimizely Inc. and contributors
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+
* http://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.optimizely.ab.config.audience;
217

318
import com.optimizely.ab.config.ProjectConfig;

core-api/src/main/java/com/optimizely/ab/config/parser/TypedAudienceJacksonDeserializer.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2019, Optimizely Inc. and contributors
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+
* http://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.optimizely.ab.config.parser;
217

318
import com.fasterxml.jackson.core.JsonParser;

core-api/src/test/java/com/optimizely/ab/internal/LogbackVerifier.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2019, Optimizely Inc. and contributors
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+
* http://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.optimizely.ab.internal;
217

318
import ch.qos.logback.classic.Level;

resources/HEADER

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright ${year}, Optimizely Inc. and contributors
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

0 commit comments

Comments
 (0)