Skip to content

Commit

Permalink
Fixed Spotless so that it actually works. (diffplug/spotless#437 stri…
Browse files Browse the repository at this point in the history
…kes again!)
  • Loading branch information
nedtwigg committed Dec 2, 2019
1 parent b2b5cb3 commit 0560b00
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 29 deletions.
15 changes: 14 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
plugins {
id 'java-gradle-plugin'
id 'com.gradle.plugin-publish' version '0.10.1'
id 'com.github.ben-manes.versions' version '0.27.0'
id 'com.diffplug.gradle.spotless' version '3.26.1'
}

spotless {
format 'misc', {
target '.gitignore', '*.gradle', '.ci/*.sh', 'src/main/resources/*.gradle'
target '.gitignore', '*.gradle', 'src/main/resources/*.gradle'
indentWithTabs()
}
freshmark {
Expand All @@ -16,6 +17,13 @@ spotless {
endWithNewline()
propertiesFile('gradle.properties')
}
java {
target 'src/main/java/**/*.java', 'src/test/java/**/*.java'
licenseHeaderFile rootProject.file('gradle/spotless/spotless.license.java') // License header file
eclipse().configFile rootProject.file('gradle/spotless/spotless.eclipseformat.xml') // XML file dumped out by the Eclipse formatter
importOrder()
removeUnusedImports()
}
}

apply plugin: 'eclipse'
Expand All @@ -41,3 +49,8 @@ gradlePlugin {
}
}
}
pluginBundle {
website = 'https://github.com/diffplug/blowdryer'
vcsUrl = 'https://github.com/diffplug/blowdryer'
tags = ['defaults', 'standards', 'dry', 'multi-project']
}
26 changes: 20 additions & 6 deletions src/main/java/com/diffplug/blowdryer/AsFile.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
/*
* Copyright 2019 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.blowdryer;


import com.diffplug.common.base.Errors;
import com.diffplug.common.base.StandardSystemProperty;
import com.diffplug.common.hash.Hashing;
import com.diffplug.common.io.Files;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -11,12 +31,6 @@
import java.util.Map;
import java.util.Objects;
import java.util.Properties;

import com.diffplug.common.base.Errors;
import com.diffplug.common.base.StandardSystemProperty;
import com.diffplug.common.hash.Hashing;
import com.diffplug.common.io.Files;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
Expand Down
20 changes: 17 additions & 3 deletions src/main/java/com/diffplug/blowdryer/BlowdryerExtension.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
/*
* Copyright 2019 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.blowdryer;


import com.diffplug.common.base.Errors;
import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.Objects;

import org.gradle.api.Project;

import com.diffplug.common.base.Errors;

public class BlowdryerExtension {
static final String NAME = "blowdryer";

Expand Down
21 changes: 21 additions & 0 deletions src/main/java/com/diffplug/blowdryer/BlowdryerPlugin.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
/*
* Copyright 2019 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.blowdryer;


import org.gradle.api.Plugin;
import org.gradle.api.Project;

public class BlowdryerPlugin implements Plugin<Project> {
static final String PLUGIN_ID = "com.diffplug.blowdryer";

@Override
public void apply(Project project) {
if (project.getRootProject() != project) {
throw new IllegalArgumentException("You must apply " + PLUGIN_ID + " only on the root project, not " + project.getPath());
}
project.getExtensions().create(BlowdryerExtension.NAME, BlowdryerExtension.class);
}
}
33 changes: 33 additions & 0 deletions src/test/java/com/diffplug/blowdryer/AsFileTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2019 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.blowdryer;


import org.assertj.core.api.Assertions;
import org.junit.Test;

public class AsFileTest {
@Test
public void filenameSafe() {
filenameSafe("http://shortName.com/a+b-0-9~Z", "http-shortName.com-a+b-0-9-Z");
filenameSafe("https://raw.githubusercontent.com/diffplug/durian-build/07f588e52eb0f31e596eab0228a5df7233a98a14/gradle/spotless/spotless.license.java",
"https-raw.githubusercontent.com-diffplug--3vpUTw--14-gradle-spotless-spotless.license.java");
}

private void filenameSafe(String url, String safe) {
Assertions.assertThat(AsFile.filenameSafe(url)).isEqualTo(safe);
}
}
19 changes: 0 additions & 19 deletions src/test/java/com/diffplug/blowdryer/AsLocalTest.java

This file was deleted.

0 comments on commit 0560b00

Please sign in to comment.