-
Notifications
You must be signed in to change notification settings - Fork 877
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NETBEANS-5479] improve maven multithreaded execution detection.
mvn is ST by default, mvnd is MT by default. Lets try to detect the execution mode a bit better by inspecting the command line parameters. MT modes can't use the event spy. contains minor performance improvement: try to get maven version by analyzing `maven-core.jar` file name. this is a lot faster than opening the jar, parsing and evaluating the properties file. Since the file name approach does not work for maven 2 the previous logic was kept. Co-authored-by: Michael Bien <mbien42@gmail.com>
- Loading branch information
Showing
5 changed files
with
373 additions
and
11 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
132 changes: 132 additions & 0 deletions
132
.../test/unit/src/org/netbeans/modules/maven/execute/MavenCommandParametersAnalyzerTest.java
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,132 @@ | ||
/* | ||
* 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.netbeans.modules.maven.execute; | ||
|
||
import java.util.Arrays; | ||
|
||
import static junit.framework.TestCase.assertFalse; | ||
import static junit.framework.TestCase.assertTrue; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* | ||
* @author Benjamin Asbach (asbachb.netbeans@impl.it) | ||
*/ | ||
public class MavenCommandParametersAnalyzerTest { | ||
|
||
@Test | ||
public void defaultIsSingleThreaded() { | ||
assertFalse(isMultiThreadedMaven("")); | ||
} | ||
|
||
@Test | ||
public void validateMultiThreaded1() { | ||
assertTrue(isMultiThreadedMaven("-T 10")); | ||
} | ||
|
||
@Test | ||
public void validateMultiThreaded2() { | ||
assertTrue(isMultiThreadedMaven("-T 2")); | ||
} | ||
|
||
@Test | ||
public void validateMultiThreaded3() { | ||
assertTrue(isMultiThreadedMaven("-Dmaven.test.skip=true -T 10")); | ||
} | ||
|
||
@Test | ||
public void validateMultiThreaded4() { | ||
assertTrue(isMultiThreadedMaven("-Dmaven.test.skip=true -T 2")); | ||
} | ||
|
||
@Test | ||
public void validateMultiThreaded5() { | ||
assertTrue(isMultiThreadedMaven("-Dmaven.test.skip=true -T 10 -Dmaven.test.skip=true ")); | ||
} | ||
|
||
@Test | ||
public void validateMultiThreaded6() { | ||
assertTrue(isMultiThreadedMaven("-Dmaven.test.skip=true -T 2 -Dmaven.test.skip=true ")); | ||
} | ||
|
||
@Test | ||
public void validateMultiThreaded7() { | ||
assertTrue(isMultiThreadedMaven("-T 10 -Dmaven.test.skip=true")); | ||
} | ||
|
||
@Test | ||
public void validateMultiThreaded8() { | ||
assertTrue(isMultiThreadedMaven("-T 2 -Dmaven.test.skip=true")); | ||
} | ||
|
||
@Test | ||
public void validateMultiThreaded9() { | ||
assertTrue(isMultiThreadedMaven("--threads 10")); | ||
} | ||
|
||
@Test | ||
public void validateMultiThreaded10() { | ||
assertTrue(isMultiThreadedMaven("--threads 2")); | ||
} | ||
|
||
@Test | ||
public void validateMultiThreaded11() { | ||
assertTrue(isMultiThreadedMaven("-Dmaven.test.skip=true --threads 10")); | ||
} | ||
|
||
@Test | ||
public void validateMultiThreaded12() { | ||
assertTrue(isMultiThreadedMaven("-Dmaven.test.skip=true --threads 2")); | ||
} | ||
|
||
@Test | ||
public void validateMultiThreaded13() { | ||
assertTrue(isMultiThreadedMaven("-Dmaven.test.skip=true --threads 10 -Dmaven.test.skip=true ")); | ||
} | ||
|
||
@Test | ||
public void validateMultiThreaded14() { | ||
assertTrue(isMultiThreadedMaven("-Dmaven.test.skip=true --threads 2 -Dmaven.test.skip=true ")); | ||
} | ||
|
||
@Test | ||
public void validateMultiThreaded15() { | ||
assertTrue(isMultiThreadedMaven("--threads 10 -Dmaven.test.skip=true")); | ||
} | ||
|
||
@Test | ||
public void validateMultiThreaded16() { | ||
assertTrue(isMultiThreadedMaven("--threads 2 -Dmaven.test.skip=true")); | ||
} | ||
|
||
@Test | ||
public void validateSingleThreaded1() { | ||
assertFalse(isMultiThreadedMaven("--threads 1")); | ||
} | ||
|
||
@Test | ||
public void validateSingleThreaded2() { | ||
assertFalse(isMultiThreadedMaven("-T 1")); | ||
} | ||
|
||
private boolean isMultiThreadedMaven(String params) { | ||
return MavenCommandLineExecutor.isMultiThreadedMaven(Arrays.asList(params.split(" "))); | ||
} | ||
} |
Oops, something went wrong.