|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | +package org.apache.maven.it; |
| 20 | + |
| 21 | +import java.io.File; |
| 22 | +import java.util.Properties; |
| 23 | + |
| 24 | +import org.junit.jupiter.api.Test; |
| 25 | + |
| 26 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 27 | + |
| 28 | +/** |
| 29 | + * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-8598">MNG-8598</a>: |
| 30 | + * Verify that ${MAVEN_PROJECTBASEDIR} and $MAVEN_PROJECTBASEDIR in .mvn/jvm.config are properly |
| 31 | + * substituted with the actual project base directory. |
| 32 | + */ |
| 33 | +public class MavenITmng8598JvmConfigSubstitutionTest extends AbstractMavenIntegrationTestCase { |
| 34 | + public MavenITmng8598JvmConfigSubstitutionTest() { |
| 35 | + super("[4.0.0-rc-4,)"); |
| 36 | + } |
| 37 | + |
| 38 | + @Test |
| 39 | + public void testProjectBasedirSubstitution() throws Exception { |
| 40 | + File testDir = extractResources("/mng-8598"); |
| 41 | + |
| 42 | + Verifier verifier = newVerifier(testDir.getAbsolutePath()); |
| 43 | + verifier.addCliArgument( |
| 44 | + "-Dexpression.outputFile=" + new File(testDir, "target/pom.properties").getAbsolutePath()); |
| 45 | + verifier.setForkJvm(true); // custom .mvn/jvm.config |
| 46 | + verifier.addCliArgument("validate"); |
| 47 | + verifier.execute(); |
| 48 | + verifier.verifyErrorFreeLog(); |
| 49 | + |
| 50 | + Properties props = verifier.loadProperties("target/pom.properties"); |
| 51 | + String expectedPath = testDir.getAbsolutePath().replace('\\', '/'); |
| 52 | + assertEquals( |
| 53 | + expectedPath + "/curated", |
| 54 | + props.getProperty("project.properties.curatedPathProp").replace('\\', '/')); |
| 55 | + assertEquals( |
| 56 | + expectedPath + "/simple", |
| 57 | + props.getProperty("project.properties.simplePathProp").replace('\\', '/')); |
| 58 | + } |
| 59 | +} |
0 commit comments