[ https://issues.apache.org/jira/browse/SUREFIRE-1431?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17154379#comment-17154379 ]
Tibor Digana edited comment on SUREFIRE-1431 at 7/9/20, 9:25 AM: ----------------------------------------------------------------- [~benze] [~vmassol] If you specify what exactly is broken then it might be fixed or you can fix it as a contributor on Github and i can guide you in the code. But referencing itself {noformat} <argLine>@{argLine} -Xmx1024m</argLine> {noformat} is strange. The (at) is not understood by Maven therefore Surefire is using it as a symbol for replacement with peroperty defined in POM. The @{argLine} should not be here. If you want to use it with JaCoCo, do it like this <argLine>${jvm.args.tests} ${jacoco.agent}</argLine> and configure the JaCoCo plugin as follows: {noformat} <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <executions> <execution> <id>jacoco-agent</id> <goals> <goal>prepare-agent</goal> </goals> </execution> </executions> <configuration> <propertyName>jacoco.agent</propertyName> </configuration> </plugin> {noformat} If you want to reference *argLine* in the tests, you can do it by defining extra property in *<properties/>* and filling out the <systemProperties/>. If you want to use (at) follow the principal in our integration tets: {noformat} <?xml version="1.0" encoding="UTF-8"?> <!-- ~ 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. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.maven.surefire</groupId> <artifactId>it-parent</artifactId> <version>1.0</version> <relativePath>../pom.xml</relativePath> </parent> <groupId>org.apache.maven.plugins.surefire</groupId> <artifactId>testArgProperties</artifactId> <version>1.0-SNAPSHOT</version> <name>Test for late replacement argLine properties.</name> <properties> <from.prop>from-prop-value</from.prop> <override.prop>not-override-prop-value</override.prop> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <version>1.0-alpha-2</version> <executions> <execution> <id>default</id> <phase>validate</phase> <goals> <goal>read-project-properties</goal> </goals> <configuration> <files> <file>${project.basedir}/src/test/resources/it.properties</file> </files> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <forkMode>once</forkMode> <argLine>-Dp1=@{from.prop} -Dp2=@{override.prop} -Dp3=@{undefined.prop} -Dp4=@{generated.prop}</argLine> </configuration> </plugin> </plugins> </build> </project> {noformat} was (Author: tibor17): [~benze] [~vmassol] If you specify what exactly is broken then it might be fixed or you can fix it as a contributor on Github and i can guide you in the code. But referencing itself {noformat} <argLine>@{argLine} -Xmx1024m</argLine> {noformat} is strange. The (at) is not understood by Maven therefore Surefire is using it as a symbol for replacement with peroperty defined in POM. The @{argLine} should not be here. If you want to use it with JaCoCo, do it like this <argLine>${jvm.args.tests} ${jacoco.agent}</argLine> and configure the JaCoCo plugin as follows: {noformat} <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <executions> <execution> <id>jacoco-agent</id> <goals> <goal>prepare-agent</goal> </goals> </execution> </executions> <configuration> <propertyName>jacoco.agent</propertyName> </configuration> </plugin> {noformat} If you want to reference *argLine *in the tests, you can do it by defining extra property in *<properties/>* and filling out the <systemProperties/>. If you want to use (at) follow the principal in our integration tets: {noformat} <?xml version="1.0" encoding="UTF-8"?> <!-- ~ 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. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.maven.surefire</groupId> <artifactId>it-parent</artifactId> <version>1.0</version> <relativePath>../pom.xml</relativePath> </parent> <groupId>org.apache.maven.plugins.surefire</groupId> <artifactId>testArgProperties</artifactId> <version>1.0-SNAPSHOT</version> <name>Test for late replacement argLine properties.</name> <properties> <from.prop>from-prop-value</from.prop> <override.prop>not-override-prop-value</override.prop> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <version>1.0-alpha-2</version> <executions> <execution> <id>default</id> <phase>validate</phase> <goals> <goal>read-project-properties</goal> </goals> <configuration> <files> <file>${project.basedir}/src/test/resources/it.properties</file> </files> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <forkMode>once</forkMode> <argLine>-Dp1=@{from.prop} -Dp2=@{override.prop} -Dp3=@{undefined.prop} -Dp4=@{generated.prop}</argLine> </configuration> </plugin> </plugins> </build> </project> {noformat} > @{argLine} not replaced if undefined > ------------------------------------ > > Key: SUREFIRE-1431 > URL: https://issues.apache.org/jira/browse/SUREFIRE-1431 > Project: Maven Surefire > Issue Type: Bug > Components: Maven Surefire Plugin > Affects Versions: 2.21.1 > Environment: Maven 3.5.0 > Reporter: Matthieu Fillon > Assignee: Tibor Digana > Priority: Major > Attachments: maven.log > > > I need to specify argLine for my tests. I also need it to work with Java > agent Jacoco when a certain Maven profile is activated. > So I added `@{argLine}` to my argLine property and it works fine when running > with Jacoco agent activated. > When running the tests without profile that activates Jacoco agent, the > surefire plugin fails with following line (relevant maven logs attached) : > {color:red}Error: Could not find or load main class @\{argLine} {color} > I guess @{argLine} is only replaced if an argLine has been defined before by > another plugin but if not it is not replaced at all. > Should'nt it be replaced in any case and if none defined, just replace with > empty value? -- This message was sent by Atlassian Jira (v8.3.4#803005)