-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MSHARED-885] Maven Wrapper fails on non-Windows OSes
- Loading branch information
Showing
7 changed files
with
235 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package org.apache.maven.it; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
/* | ||
* 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. | ||
*/ | ||
|
||
import static org.hamcrest.Matchers.is; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.FileReader; | ||
import java.io.IOException; | ||
import java.nio.file.Paths; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.Properties; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
public class ForkedLauncherTest | ||
{ | ||
@Rule | ||
public TemporaryFolder temporaryFolder = new TemporaryFolder(); | ||
|
||
private ForkedLauncher launcher; | ||
|
||
private final String workingDir = Paths.get( "src/test/resources/wrapper-project" ).toAbsolutePath().toString(); | ||
|
||
@Test | ||
public void mvnw() throws Exception | ||
{ | ||
launcher = new ForkedLauncher( ".", Collections.<String, String>emptyMap(), false, true ); | ||
File logFile = temporaryFolder.newFile( "build.log" ); | ||
|
||
int exitCode = launcher.run( new String[0], new Properties(), workingDir, logFile ); | ||
|
||
// most likely this contains the exception in case exitCode != 0 | ||
expectFileLine( logFile, "Hello World" ); | ||
|
||
assertThat( "exit code", exitCode , is ( 0 ) ); | ||
} | ||
|
||
@Test | ||
public void mvnwDebug() throws Exception | ||
{ | ||
launcher = new ForkedLauncher( ".", Collections.<String, String>emptyMap(), true, true ); | ||
File logFile = temporaryFolder.newFile( "build.log" ); | ||
|
||
int exitCode = launcher.run( new String[0], new Properties(), workingDir, logFile ); | ||
|
||
// most likely this contains the exception in case exitCode != 0 | ||
expectFileLine( logFile, "Hello World" ); | ||
|
||
assertThat( "exit code", exitCode , is ( 0 ) ); | ||
} | ||
|
||
private void expectFileLine( File file, String expectedline ) throws IOException | ||
{ | ||
try ( FileReader fr = new FileReader( file ); | ||
BufferedReader br = new BufferedReader( fr ) ) | ||
{ | ||
Collection<String> text = new ArrayList<>(); | ||
String line; | ||
while ( ( line = br.readLine() ) != null ) | ||
{ | ||
if ( expectedline.equals( line ) ) | ||
{ | ||
return; | ||
} | ||
text.add( line ); | ||
} | ||
|
||
String message = "%s doesn't contain '%s', was:\n%s"; | ||
fail( String.format( message, file.getName(), expectedline, text ) ); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
# ---------------------------------------------------------------------------- | ||
# 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. | ||
# ---------------------------------------------------------------------------- | ||
echo Hello World |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@REM ---------------------------------------------------------------------------- | ||
@REM Licensed to the Apache Software Foundation (ASF) under one | ||
@REM or more contributor license agreements. See the NOTICE file | ||
@REM distributed with this work for additional information | ||
@REM regarding copyright ownership. The ASF licenses this file | ||
@REM to you under the Apache License, Version 2.0 (the | ||
@REM "License"); you may not use this file except in compliance | ||
@REM with the License. You may obtain a copy of the License at | ||
@REM | ||
@REM http://www.apache.org/licenses/LICENSE-2.0 | ||
@REM | ||
@REM Unless required by applicable law or agreed to in writing, | ||
@REM software distributed under the License is distributed on an | ||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
@REM KIND, either express or implied. See the License for the | ||
@REM specific language governing permissions and limitations | ||
@REM under the License. | ||
@REM ---------------------------------------------------------------------------- | ||
@echo off | ||
@ECHO Hello World | ||
@echo on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/sh | ||
|
||
# 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. | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Apache Maven Debug Script | ||
# | ||
# Environment Variable Prerequisites | ||
# | ||
# JAVA_HOME Must point at your Java Development Kit installation. | ||
# MAVEN_OPTS (Optional) Java runtime options used when Maven is executed. | ||
# MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files. | ||
# ----------------------------------------------------------------------------- | ||
|
||
MAVEN_DEBUG_OPTS= | ||
|
||
echo Preparing to execute Maven Wrapper in debug mode | ||
|
||
env MAVEN_OPTS="$MAVEN_OPTS" MAVEN_DEBUG_OPTS="$MAVEN_DEBUG_OPTS" "`dirname "$0"`/mvnw" "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@REM Licensed to the Apache Software Foundation (ASF) under one | ||
@REM or more contributor license agreements. See the NOTICE file | ||
@REM distributed with this work for additional information | ||
@REM regarding copyright ownership. The ASF licenses this file | ||
@REM to you under the Apache License, Version 2.0 (the | ||
@REM "License"); you may not use this file except in compliance | ||
@REM with the License. You may obtain a copy of the License at | ||
@REM | ||
@REM http://www.apache.org/licenses/LICENSE-2.0 | ||
@REM | ||
@REM Unless required by applicable law or agreed to in writing, | ||
@REM software distributed under the License is distributed on an | ||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
@REM KIND, either express or implied. See the License for the | ||
@REM specific language governing permissions and limitations | ||
@REM under the License. | ||
|
||
@REM ----------------------------------------------------------------------------- | ||
@REM Apache Maven Debug Script | ||
@REM | ||
@REM Environment Variable Prerequisites | ||
@REM | ||
@REM JAVA_HOME Must point at your Java Development Kit installation. | ||
@REM MAVEN_BATCH_ECHO (Optional) Set to 'on' to enable the echoing of the batch commands. | ||
@REM MAVEN_BATCH_PAUSE (Optional) set to 'on' to wait for a key stroke before ending. | ||
@REM MAVEN_OPTS (Optional) Java runtime options used when Maven is executed. | ||
@REM MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files. | ||
@REM ----------------------------------------------------------------------------- | ||
|
||
@setlocal | ||
@set MAVEN_DEBUG_OPTS= | ||
|
||
@call "%~dp0"mvnw.cmd %* |