File tree Expand file tree Collapse file tree 16 files changed +460
-0
lines changed
mexec-gh-389-block-exit-non-zero
mexec-gh-389-block-exit-zero
mexec-gh-389-default-permit-exit
main/java/org/codehaus/mojo/exec Expand file tree Collapse file tree 16 files changed +460
-0
lines changed Original file line number Diff line number Diff line change 9494 </roles >
9595 <timezone >Europe/Berlin</timezone >
9696 </contributor >
97+ <contributor >
98+ <name >Alexander Kriegisch</name >
99+ <email >protected</email >
100+ <organization >Scrum-Master.de - Agiles Projektmanagement</organization >
101+ <organizationUrl >https://scrum-master.de</organizationUrl >
102+ <roles >
103+ <role >Feature Contributor</role >
104+ </roles >
105+ </contributor >
97106 </contributors >
98107
99108 <licenses >
335344 <invoker .parallelThreads>1</invoker .parallelThreads>
336345 </properties >
337346 </profile >
347+ <profile >
348+ <id >java17+</id >
349+ <activation >
350+ <jdk >[17,)</jdk >
351+ </activation >
352+ <properties >
353+ <invoker .security.manager>-Djava.security.manager=allow</invoker .security.manager>
354+ </properties >
355+ </profile >
338356 <profile >
339357 <id >run-its</id >
340358 <build >
360378 <scriptVariables >
361379 <projectVersion >${project.version} </projectVersion >
362380 </scriptVariables >
381+ <!--
382+ Necessary on JDK 17+ for ITs "mexec-gh-389-block-exit-*" to avoid "UnsupportedOperationException:
383+ The Security Manager is deprecated and will be removed in a future release". See profile 'java17+'.
384+ -->
385+ <mavenOpts >${invoker.security.manager} </mavenOpts >
363386 </configuration >
364387 <executions >
365388 <execution >
Original file line number Diff line number Diff line change 1+ invoker.goals = clean process-classes
2+ invoker.buildResult = failure
3+ invoker.debug = false
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
4+ <modelVersion >4.0.0</modelVersion >
5+
6+ <parent >
7+ <groupId >org.codehaus.mojo.exec.it</groupId >
8+ <artifactId >parent</artifactId >
9+ <version >0.1</version >
10+ </parent >
11+
12+ <artifactId >mexec-gh-389</artifactId >
13+ <version >0.0.1-SNAPSHOT</version >
14+
15+ <build >
16+ <plugins >
17+ <plugin >
18+ <groupId >org.codehaus.mojo</groupId >
19+ <artifactId >exec-maven-plugin</artifactId >
20+ <version >@project.version@</version >
21+ <executions >
22+ <execution >
23+ <phase >process-classes</phase >
24+ <goals >
25+ <goal >java</goal >
26+ </goals >
27+ <configuration >
28+ <mainClass >Main</mainClass >
29+ <blockSystemExit >true</blockSystemExit >
30+ <systemProperties >
31+ <systemProperty >
32+ <key >exitBehaviour</key >
33+ <value >system-exit-error</value >
34+ </systemProperty >
35+ </systemProperties >
36+ <arguments >
37+ <argument >one</argument >
38+ <argument >two</argument >
39+ <argument >three</argument >
40+ </arguments >
41+ </configuration >
42+ </execution >
43+ </executions >
44+ </plugin >
45+ </plugins >
46+ </build >
47+ </project >
Original file line number Diff line number Diff line change 1+ import java .util .Arrays ;
2+
3+ public class Main
4+ {
5+ public static void main ( String [] args )
6+ {
7+ System .out .println ( Arrays .toString ( args ) );
8+ switch ( System .getProperty ( "exitBehaviour" , "ok" ) )
9+ {
10+ case "throw-exception" :
11+ throw new RuntimeException ( "uh-oh" );
12+ case "system-exit-ok" :
13+ System .exit ( 0 );
14+ case "system-exit-error" :
15+ System .exit ( 123 );
16+ }
17+ System .out .println ( "OK" );
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright MojoHaus and Contributors
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+ * http://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+
17+ def buildLogLines = new File ( basedir, " build.log" ). readLines()
18+
19+ // Find "System::exit was called" line index
20+ def infoMessageLineNumber = buildLogLines. indexOf(" [INFO] System::exit was called with return code 123" )
21+ assert infoMessageLineNumber > 0
22+ // Verify that preceding line is program output
23+ assert buildLogLines[infoMessageLineNumber - 1 ] == " [one, two, three]"
24+ // Verify that subsequent lines contain the beginning of the thrown SystemExitException stack trace
25+ assert buildLogLines[infoMessageLineNumber + 1 ]. startsWith(" [WARNING]" )
26+ assert buildLogLines[infoMessageLineNumber + 2 ]. contains(" SystemExitException: System::exit was called with return code 123" )
27+ assert buildLogLines[infoMessageLineNumber + 3 ]. contains(" SystemExitManager.checkExit (SystemExitManager.java" )
Original file line number Diff line number Diff line change 1+ invoker.goals = clean process-classes
2+ invoker.buildResult = success
3+ invoker.debug = false
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
4+ <modelVersion >4.0.0</modelVersion >
5+
6+ <parent >
7+ <groupId >org.codehaus.mojo.exec.it</groupId >
8+ <artifactId >parent</artifactId >
9+ <version >0.1</version >
10+ </parent >
11+
12+ <artifactId >mexec-gh-389</artifactId >
13+ <version >0.0.1-SNAPSHOT</version >
14+
15+ <build >
16+ <plugins >
17+ <plugin >
18+ <groupId >org.codehaus.mojo</groupId >
19+ <artifactId >exec-maven-plugin</artifactId >
20+ <version >@project.version@</version >
21+ <executions >
22+ <execution >
23+ <phase >process-classes</phase >
24+ <goals >
25+ <goal >java</goal >
26+ </goals >
27+ <configuration >
28+ <mainClass >Main</mainClass >
29+ <blockSystemExit >true</blockSystemExit >
30+ <systemProperties >
31+ <systemProperty >
32+ <key >exitBehaviour</key >
33+ <value >system-exit-ok</value >
34+ </systemProperty >
35+ </systemProperties >
36+ <arguments >
37+ <argument >one</argument >
38+ <argument >two</argument >
39+ <argument >three</argument >
40+ </arguments >
41+ </configuration >
42+ </execution >
43+ </executions >
44+ </plugin >
45+ </plugins >
46+ </build >
47+ </project >
Original file line number Diff line number Diff line change 1+ import java .util .Arrays ;
2+
3+ public class Main
4+ {
5+ public static void main ( String [] args )
6+ {
7+ System .out .println ( Arrays .toString ( args ) );
8+ switch ( System .getProperty ( "exitBehaviour" , "ok" ) )
9+ {
10+ case "throw-exception" :
11+ throw new RuntimeException ( "uh-oh" );
12+ case "system-exit-ok" :
13+ System .exit ( 0 );
14+ case "system-exit-error" :
15+ System .exit ( 123 );
16+ }
17+ System .out .println ( "OK" );
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright MojoHaus and Contributors
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+ * http://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+
17+ def buildLogLines = new File ( basedir, " build.log" ). readLines()
18+
19+ // Find "System::exit was called" line index
20+ def infoMessageLineNumber = buildLogLines. indexOf(" [INFO] System::exit was called with return code 0" )
21+ assert infoMessageLineNumber > 0
22+ // Verify that preceding line is program output
23+ assert buildLogLines[infoMessageLineNumber - 1 ] == " [one, two, three]"
Original file line number Diff line number Diff line change 1+ invoker.goals = clean process-classes
2+ # Cannot not check result, because build terminates unexpectedly
3+ # invoker.buildResult = failure
4+ invoker.debug = false
You can’t perform that action at this time.
0 commit comments