Skip to content

Commit

Permalink
Common constant for Kotlin's license header delimiter
Browse files Browse the repository at this point in the history
To share same regex between Gradle and Maven plugins.
  • Loading branch information
lutovich committed Mar 12, 2018
1 parent ca64af9 commit 60ecd22
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2016 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.diffplug.spotless.kotlin;

public final class KotlinConstants {

// '^' is prepended to the regex in LICENSE_HEADER_DELIMITER later in FormatExtension.licenseHeader(String, String)
public static final String LICENSE_HEADER_DELIMITER = "(package |@file)";

private KotlinConstants() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.diffplug.gradle.spotless;

import static com.diffplug.spotless.kotlin.KotlinConstants.LICENSE_HEADER_DELIMITER;

import java.util.Objects;

import org.gradle.api.GradleException;
Expand All @@ -25,8 +27,6 @@
import com.diffplug.spotless.kotlin.KtLintStep;

public class KotlinExtension extends FormatExtension {
// '^' is prepended to the regex in LICENSE_HEADER_DELIMITER later in FormatExtension.licenseHeader(String, String)
private static final String LICENSE_HEADER_DELIMITER = "(package |@file)";
static final String NAME = "kotlin";

public KotlinExtension(SpotlessExtension rootExtension) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.diffplug.spotless.maven.kotlin;

import static com.diffplug.common.collect.Sets.newHashSet;
import static com.diffplug.spotless.kotlin.KotlinConstants.LICENSE_HEADER_DELIMITER;
import static java.util.Collections.unmodifiableSet;

import java.util.Set;
Expand All @@ -27,8 +28,6 @@ public class Kotlin extends FormatterFactory {
private static final Set<String> DEFAULT_INCLUDES = unmodifiableSet(newHashSet("src/main/kotlin/**/*.kt",
"src/test/kotlin/**/*.kt"));

private static final String LICENSE_HEADER_DELIMITER = "(package |@file)";

@Override
public Set<String> defaultIncludes() {
return DEFAULT_INCLUDES;
Expand Down

0 comments on commit 60ecd22

Please sign in to comment.