Skip to content

Commit 977c8ab

Browse files
committed
Fix style issues
1 parent c1453af commit 977c8ab

File tree

10 files changed

+211
-19
lines changed

10 files changed

+211
-19
lines changed

native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/JavaApplicationWithAgentFunctionalTest.groovy

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ class JavaApplicationWithAgentFunctionalTest extends AbstractGraalVMMavenFunctio
7878
outputDoesNotContain "containers found"
7979
}
8080

81-
def "simple test of agent usage"() {
81+
def "test agent with metadata copy task"() {
8282
given:
8383
withSample("java-application-with-reflection")
84-
mvn '-Pnative', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'
84+
mvn'-Pnative', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'
8585

8686
when:
87-
mvn '-Pnative', '-DskipNativeTests', 'native:metadata-copy'
87+
mvn'-Pnative', '-DskipNativeTests', 'native:metadata-copy'
8888

8989
then:
9090
buildSucceeded
@@ -94,13 +94,13 @@ class JavaApplicationWithAgentFunctionalTest extends AbstractGraalVMMavenFunctio
9494
outputContains "Metadata copy process finished."
9595
}
9696

97-
def "simple test of agent usage with direct mode"() {
97+
def "test agent in direct mode with metadata copy task"() {
9898
given:
9999
withSample("java-application-with-reflection")
100-
mvn '-PagentConfigurationDirectMode', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'
100+
mvn'-PagentConfigurationDirectMode', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'
101101

102102
when:
103-
mvn '-PagentConfigurationDirectMode', '-DskipNativeTests', 'native:metadata-copy'
103+
mvn '-PagentConfigurationDirectMode', '-DskipNativeTests', 'native:metadata-copy'
104104

105105
then:
106106
buildSucceeded
@@ -109,10 +109,10 @@ class JavaApplicationWithAgentFunctionalTest extends AbstractGraalVMMavenFunctio
109109
outputContains "You are running agent in direct mode. Skipping both merge and metadata copy tasks."
110110
}
111111

112-
def "simple test of agent usage with disabled stages"() {
112+
def "test agent with metadata copy task and disabled stages"() {
113113
given:
114114
withSample("java-application-with-reflection")
115-
mvn '-PagentConfigurationWithDisabledStages', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'
115+
mvn'-PagentConfigurationWithDisabledStages', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'
116116

117117
when:
118118
mvn'-PagentConfigurationWithDisabledStages', '-DskipNativeTests', 'native:metadata-copy'

native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/AbstractNativeImageMojo.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,24 @@
5454
import org.graalvm.buildtools.utils.SharedConstants;
5555

5656
import javax.inject.Inject;
57-
import java.io.*;
57+
import java.io.File;
58+
import java.io.InputStream;
59+
import java.io.BufferedReader;
60+
import java.io.InputStreamReader;
61+
import java.io.IOException;
5862
import java.net.URI;
5963
import java.nio.charset.StandardCharsets;
6064
import java.nio.file.FileSystem;
61-
import java.nio.file.*;
62-
import java.util.*;
65+
import java.nio.file.FileSystems;
66+
import java.nio.file.Path;
67+
import java.nio.file.Paths;
68+
import java.nio.file.Files;
69+
import java.util.ArrayList;
70+
import java.util.Arrays;
71+
import java.util.List;
72+
import java.util.Collections;
73+
import java.util.Map;
74+
import java.util.Optional;
6375
import java.util.regex.Pattern;
6476
import java.util.stream.Collectors;
6577
import java.util.stream.Stream;

native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/NativeExtension.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
import java.util.stream.Collectors;
6666

6767
import static org.graalvm.buildtools.utils.NativeImageConfigurationUtils.getNativeImage;
68-
import static org.graalvm.buildtools.utils.Utils.assertNotEmptyAndTrim;
6968

7069
/**
7170
* This extension is responsible for configuring the Surefire plugin to enable

native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/config/AbstractMergeAgentFilesMojo.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
/*
2+
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* The Universal Permissive License (UPL), Version 1.0
6+
*
7+
* Subject to the condition set forth below, permission is hereby granted to any
8+
* person obtaining a copy of this software, associated documentation and/or
9+
* data (collectively the "Software"), free of charge and under any and all
10+
* copyright rights in the Software, and any and all patent rights owned or
11+
* freely licensable by each licensor hereunder covering either (i) the
12+
* unmodified Software as contributed to or provided by such licensor, or (ii)
13+
* the Larger Works (as defined below), to deal in both
14+
*
15+
* (a) the Software, and
16+
*
17+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
* one is included with the Software each a "Larger Work" to which the Software
19+
* is contributed by such licensors),
20+
*
21+
* without restriction, including without limitation the rights to copy, create
22+
* derivative works of, display, perform, and distribute the Software and make,
23+
* use, sell, offer for sale, import, export, have made, and have sold the
24+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
* either these or other terms.
26+
*
27+
* This license is subject to the following condition:
28+
*
29+
* The above copyright notice and either this complete permission notice or at a
30+
* minimum a reference to the UPL must be included in all copies or substantial
31+
* portions of the Software.
32+
*
33+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
* SOFTWARE.
40+
*/
41+
142
package org.graalvm.buildtools.maven.config;
243

344
import org.apache.maven.plugin.AbstractMojo;
@@ -25,6 +66,10 @@ public abstract class AbstractMergeAgentFilesMojo extends AbstractMojo {
2566
protected File mergerExecutable;
2667

2768
protected void tryInstallMergeExecutable(Path nativeImageExecutablePath) {
69+
if (mergerExecutable != null && mergerExecutable.exists()) {
70+
return;
71+
}
72+
2873
File nativeImageExecutable = nativeImageExecutablePath.toAbsolutePath().toFile();
2974
File mergerExecutable = new File(nativeImageExecutable.getParentFile(), nativeImageConfigureFileName());
3075
if (!mergerExecutable.exists()) {
@@ -45,6 +90,7 @@ protected void tryInstallMergeExecutable(Path nativeImageExecutablePath) {
4590
}
4691

4792
}
93+
4894
this.mergerExecutable = mergerExecutable;
4995
}
5096

native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/config/agent/AgentConfiguration.java

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,51 @@
1+
/*
2+
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* The Universal Permissive License (UPL), Version 1.0
6+
*
7+
* Subject to the condition set forth below, permission is hereby granted to any
8+
* person obtaining a copy of this software, associated documentation and/or
9+
* data (collectively the "Software"), free of charge and under any and all
10+
* copyright rights in the Software, and any and all patent rights owned or
11+
* freely licensable by each licensor hereunder covering either (i) the
12+
* unmodified Software as contributed to or provided by such licensor, or (ii)
13+
* the Larger Works (as defined below), to deal in both
14+
*
15+
* (a) the Software, and
16+
*
17+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
* one is included with the Software each a "Larger Work" to which the Software
19+
* is contributed by such licensors),
20+
*
21+
* without restriction, including without limitation the rights to copy, create
22+
* derivative works of, display, perform, and distribute the Software and make,
23+
* use, sell, offer for sale, import, export, have made, and have sold the
24+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
* either these or other terms.
26+
*
27+
* This license is subject to the following condition:
28+
*
29+
* The above copyright notice and either this complete permission notice or at a
30+
* minimum a reference to the UPL must be included in all copies or substantial
31+
* portions of the Software.
32+
*
33+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
* SOFTWARE.
40+
*/
41+
142
package org.graalvm.buildtools.maven.config.agent;
243

344
import org.apache.maven.plugins.annotations.Parameter;
4-
import org.graalvm.buildtools.agent.*;
45+
import org.graalvm.buildtools.agent.AgentMode;
46+
import org.graalvm.buildtools.agent.ConditionalAgentMode;
47+
import org.graalvm.buildtools.agent.DirectAgentMode;
48+
import org.graalvm.buildtools.agent.StandardAgentMode;
549

650
import java.util.Arrays;
751
import java.util.Properties;

native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/config/agent/CommonOptionsConfiguration.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
/*
2+
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* The Universal Permissive License (UPL), Version 1.0
6+
*
7+
* Subject to the condition set forth below, permission is hereby granted to any
8+
* person obtaining a copy of this software, associated documentation and/or
9+
* data (collectively the "Software"), free of charge and under any and all
10+
* copyright rights in the Software, and any and all patent rights owned or
11+
* freely licensable by each licensor hereunder covering either (i) the
12+
* unmodified Software as contributed to or provided by such licensor, or (ii)
13+
* the Larger Works (as defined below), to deal in both
14+
*
15+
* (a) the Software, and
16+
*
17+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
* one is included with the Software each a "Larger Work" to which the Software
19+
* is contributed by such licensors),
20+
*
21+
* without restriction, including without limitation the rights to copy, create
22+
* derivative works of, display, perform, and distribute the Software and make,
23+
* use, sell, offer for sale, import, export, have made, and have sold the
24+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
* either these or other terms.
26+
*
27+
* This license is subject to the following condition:
28+
*
29+
* The above copyright notice and either this complete permission notice or at a
30+
* minimum a reference to the UPL must be included in all copies or substantial
31+
* portions of the Software.
32+
*
33+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
* SOFTWARE.
40+
*/
41+
142
package org.graalvm.buildtools.maven.config.agent;
243

344
import org.apache.maven.plugins.annotations.Parameter;

native-maven-plugin/src/main/java/org/graalvm/buildtools/maven/config/agent/ModesConfiguration.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
/*
2+
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* The Universal Permissive License (UPL), Version 1.0
6+
*
7+
* Subject to the condition set forth below, permission is hereby granted to any
8+
* person obtaining a copy of this software, associated documentation and/or
9+
* data (collectively the "Software"), free of charge and under any and all
10+
* copyright rights in the Software, and any and all patent rights owned or
11+
* freely licensable by each licensor hereunder covering either (i) the
12+
* unmodified Software as contributed to or provided by such licensor, or (ii)
13+
* the Larger Works (as defined below), to deal in both
14+
*
15+
* (a) the Software, and
16+
*
17+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
* one is included with the Software each a "Larger Work" to which the Software
19+
* is contributed by such licensors),
20+
*
21+
* without restriction, including without limitation the rights to copy, create
22+
* derivative works of, display, perform, and distribute the Software and make,
23+
* use, sell, offer for sale, import, export, have made, and have sold the
24+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
* either these or other terms.
26+
*
27+
* This license is subject to the following condition:
28+
*
29+
* The above copyright notice and either this complete permission notice or at a
30+
* minimum a reference to the UPL must be included in all copies or substantial
31+
* portions of the Software.
32+
*
33+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
* SOFTWARE.
40+
*/
41+
142
package org.graalvm.buildtools.maven.config.agent;
243

344
import org.apache.maven.plugins.annotations.Parameter;

native-maven-plugin/src/main/java/org/graalvm/buildtools/utils/AgentUtils.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@
4242

4343
import org.apache.maven.execution.MavenSession;
4444
import org.codehaus.plexus.util.xml.Xpp3Dom;
45-
import org.graalvm.buildtools.agent.*;
45+
46+
import org.graalvm.buildtools.agent.AgentMode;
47+
import org.graalvm.buildtools.agent.DisabledAgentMode;
48+
import org.graalvm.buildtools.agent.StandardAgentMode;
49+
import org.graalvm.buildtools.agent.DirectAgentMode;
50+
import org.graalvm.buildtools.agent.ConditionalAgentMode;
51+
import org.graalvm.buildtools.agent.AgentConfiguration;
52+
4653
import org.graalvm.buildtools.maven.config.agent.CommonOptionsConfiguration;
4754

4855
import java.util.ArrayList;
@@ -55,7 +62,7 @@
5562

5663
public final class AgentUtils {
5764

58-
private AgentUtils() {}
65+
private AgentUtils() { }
5966

6067
public static AgentMode getAgentMode(Xpp3Dom agent) throws Exception {
6168
Xpp3Dom defaultModeNode = Xpp3DomParser.getTagByName(agent, "defaultMode");
@@ -112,7 +119,7 @@ public static AgentMode getAgentMode(Xpp3Dom agent) throws Exception {
112119
return agentMode;
113120
}
114121

115-
public static AgentConfiguration collectAgentProperties(MavenSession session, Xpp3Dom rootNode) throws RuntimeException{
122+
public static AgentConfiguration collectAgentProperties(MavenSession session, Xpp3Dom rootNode) throws RuntimeException {
116123
Xpp3Dom agent = Xpp3DomParser.getTagByName(rootNode, "agent");
117124
if (agent == null) {
118125
return new AgentConfiguration();
@@ -169,7 +176,7 @@ public static ArrayList<String> getDisabledStages(Xpp3Dom rootNode) {
169176
Xpp3Dom agent = Xpp3DomParser.getTagByName(rootNode, "agent");
170177
if (agent != null) {
171178
Xpp3Dom disabledStagesNode = Xpp3DomParser.getTagByName(agent, "disabledStages");
172-
if (disabledStagesNode != null){
179+
if (disabledStagesNode != null) {
173180
Xpp3DomParser.getAllTagsByName(disabledStagesNode, "stage")
174181
.forEach(stageNode -> disabledStages.add(stageNode.getValue()));
175182
}

native-maven-plugin/src/main/java/org/graalvm/buildtools/utils/Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
public final class Utils {
4444

45-
private Utils() {}
45+
private Utils() { }
4646

4747
public static boolean parseBoolean(String description, String value) {
4848
value = assertNotEmptyAndTrim(value, description + " must have a value").toLowerCase();

native-maven-plugin/src/main/java/org/graalvm/buildtools/utils/Xpp3DomParser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@
3838
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3939
* SOFTWARE.
4040
*/
41+
4142
package org.graalvm.buildtools.utils;
4243

4344
import org.codehaus.plexus.util.xml.Xpp3Dom;
4445

4546
import java.util.LinkedList;
47+
import java.util.List;
4648

4749
public class Xpp3DomParser {
4850

@@ -62,7 +64,7 @@ public static Xpp3Dom getTagByName(Xpp3Dom root, String name) {
6264
return null;
6365
}
6466

65-
public static LinkedList<Xpp3Dom> getAllTagsByName(Xpp3Dom root, String name) {
67+
public static List<Xpp3Dom> getAllTagsByName(Xpp3Dom root, String name) {
6668
LinkedList<Xpp3Dom> listOfTags = new LinkedList<>();
6769
Xpp3Dom[] children = root.getChildren();
6870
for (Xpp3Dom child : children) {

0 commit comments

Comments
 (0)