|
| 1 | +/* |
| 2 | + * Copyright (C) 2021 DiffPlug |
| 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 | + * https://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 | + */ |
| 16 | +package com.diffplug.gradle.swt; |
| 17 | + |
| 18 | + |
| 19 | +import com.diffplug.gradle.GradleIntegrationTest; |
| 20 | +import java.io.IOException; |
| 21 | +import org.gradle.testkit.runner.GradleRunner; |
| 22 | +import org.junit.Ignore; |
| 23 | +import org.junit.Test; |
| 24 | + |
| 25 | +public class PlatformSpecificBuildPluginTest extends GradleIntegrationTest { |
| 26 | + protected GradleRunner gradleRunner() { |
| 27 | + return super.gradleRunner().withGradleVersion("7.2"); |
| 28 | + } |
| 29 | + |
| 30 | + private GradleRunner breakConfigCache() throws IOException { |
| 31 | + write("gradle.properties", "org.gradle.unsafe.configuration-cache=true"); |
| 32 | + write("build.gradle", |
| 33 | + "plugins {", |
| 34 | + " id 'java'", |
| 35 | + " id 'com.diffplug.eclipse.mavencentral'", |
| 36 | + "}", |
| 37 | + "repositories { mavenCentral() }", |
| 38 | + "eclipseMavenCentral {", |
| 39 | + " release '4.20.0', {", |
| 40 | + " implementation 'org.eclipse.swt'", |
| 41 | + " implementation 'org.eclipse.jface'", |
| 42 | + " implementation \"org.eclipse.swt.${com.diffplug.common.swt.os.SwtPlatform.getRunning()}\"", |
| 43 | + " useNativesForRunningPlatform()", |
| 44 | + " }", |
| 45 | + "}"); |
| 46 | + write("src/main/java/pkg/Demo.java", |
| 47 | + "package pkg;", |
| 48 | + "public class Demo {}"); |
| 49 | + return gradleRunner().withArguments("jar"); |
| 50 | + } |
| 51 | + |
| 52 | + @Test |
| 53 | + @Ignore // fails in real project, but not unit test, not sure why |
| 54 | + public void configurationCacheBroken() throws IOException { |
| 55 | + breakConfigCache().buildAndFail(); |
| 56 | + } |
| 57 | + |
| 58 | + @Test |
| 59 | + public void configurationCacheWorks() throws IOException { |
| 60 | + write("settings.gradle", |
| 61 | + "plugins {", |
| 62 | + " id 'com.diffplug.configuration-cache-for-platform-specific-build'", |
| 63 | + "}"); |
| 64 | + breakConfigCache().build(); |
| 65 | + } |
| 66 | +} |
0 commit comments