diff --git a/src/test/java/org/apache/maven/buildcache/its/Issue218Test.java b/src/test/java/org/apache/maven/buildcache/its/Issue218Test.java new file mode 100644 index 00000000..e94b5231 --- /dev/null +++ b/src/test/java/org/apache/maven/buildcache/its/Issue218Test.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.maven.buildcache.its; + +import org.apache.maven.buildcache.its.junit.IntegrationTest; +import org.apache.maven.it.VerificationException; +import org.apache.maven.it.Verifier; +import org.junit.jupiter.api.Test; + +/** + * Regression test for issue #218. + * + *

When {@code -Dmaven.build.cache.enabled=false} is passed on the command line (globally disabling the cache) + * and a module has {@code true} set as a POM project + * property, the build used to fail with: + *

IllegalStateException: Cache is not initialized. Actual state: DISABLED
+ */ +@IntegrationTest("src/test/projects/mbuildcache-218") +class Issue218Test { + + @Test + void cacheGloballyDisabledWithPerModuleSkipCachePropertyShouldNotFail(Verifier verifier) + throws VerificationException { + verifier.setAutoclean(false); + verifier.addCliOption("-Dmaven.build.cache.enabled=false"); + + verifier.executeGoal("package"); + + verifier.verifyErrorFreeLog(); + } +} diff --git a/src/test/projects/mbuildcache-218/.mvn/extensions.xml b/src/test/projects/mbuildcache-218/.mvn/extensions.xml new file mode 100644 index 00000000..637b22db --- /dev/null +++ b/src/test/projects/mbuildcache-218/.mvn/extensions.xml @@ -0,0 +1,28 @@ + + + + + org.apache.maven.extensions + maven-build-cache-extension + ${projectVersion} + + diff --git a/src/test/projects/mbuildcache-218/pom.xml b/src/test/projects/mbuildcache-218/pom.xml new file mode 100644 index 00000000..ea99c2e9 --- /dev/null +++ b/src/test/projects/mbuildcache-218/pom.xml @@ -0,0 +1,40 @@ + + + + 4.0.0 + org.apache.maven.caching.test + mbuildcache-218 + 0.0.1-SNAPSHOT + + + 1.8 + 1.8 + + true + + + diff --git a/src/test/projects/mbuildcache-218/src/main/java/Main.java b/src/test/projects/mbuildcache-218/src/main/java/Main.java new file mode 100644 index 00000000..2d15bb73 --- /dev/null +++ b/src/test/projects/mbuildcache-218/src/main/java/Main.java @@ -0,0 +1,5 @@ +public class Main { + public static void main(String[] args) { + System.out.println("Hello World!"); + } +}