/*
 * Copyright 2020 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.gradle.spotless;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.junit.Test;

public class ConfigurationCacheTest extends GradleIntegrationHarness {
	protected void runTasks(String... tasks) throws IOException {
		setFile("gradle.properties").toContent("org.gradle.unsafe.configuration-cache=true");
		List<String> args = new ArrayList<>();
		args.addAll(Arrays.asList(tasks));
		gradleRunner()
				.withGradleVersion(GradleVersionSupport.CONFIGURATION_CACHE.version)
				.withArguments(args)
				.forwardOutput()
				.build();
	}

	@Test
	public void helpConfigures() throws IOException {
		setFile("build.gradle").toLines(
				"buildscript { repositories { mavenCentral() } }",
				"plugins {",
				"    id 'com.diffplug.spotless'",
				"}",
				"apply plugin: 'java'",
				"spotless {",
				"    java {",
				"        googleJavaFormat('1.2')",
				"    }",
				"}");
		runTasks("help");
	}
}

@@ -1567,11 +1567,436 @@
 lp%22);%0A%09%7D
+%0A%0A%09@Test%0A%09public void helpConfiguresIfTasksAreCreated() throws IOException %7B%0A%09%09setFile(%22build.gradle%22).toLines(%0A%09%09%09%09%22buildscript %7B repositories %7B mavenCentral() %7D %7D%22,%0A%09%09%09%09%22plugins %7B%22,%0A%09%09%09%09%22    id 'com.diffplug.spotless'%22,%0A%09%09%09%09%22%7D%22,%0A%09%09%09%09%22apply plugin: 'java'%22,%0A%09%09%09%09%22spotless %7B%22,%0A%09%09%09%09%22    java %7B%22,%0A%09%09%09%09%22        googleJavaFormat('1.2')%22,%0A%09%09%09%09%22    %7D%22,%0A%09%09%09%09%22%7D%22,%0A%09%09%09%09%22tasks.named('spotlessJavaApply').get()%22);%0A%09%09runTasks(%22help%22);%0A%09%7D
 %0A%7D%0A

Does spotless interfere with config cache if its tasks are configured? (answer: yes)