From 109c9de44e048f052f30ed0c705eaa1cffa248c8 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Sat, 20 Apr 2024 13:24:54 +0200 Subject: [PATCH] Default must be manually handled, i missed this. Fixes #912 --- .../mvnd/client/DaemonParameters.java | 15 +++++--- .../it/MavenConfIgnoreExtDefNativeIT.java | 24 +++++++++++++ .../mvnd/it/MavenConfIgnoreExtDefTest.java | 24 +++++++++++++ .../mvnd/it/MavenConfIgnoreExtNativeIT.java | 34 +++++++++++++++++++ .../mvnd/it/MavenConfIgnoreExtTest.java | 24 +++++++++++++ .../mvndaemon/mvnd/it/MavenConfNativeIT.java | 23 ++++++++----- .../.mvn/extensions.xml | 9 +++++ .../maven-conf-ignore-ext-def/pom.xml | 27 +++++++++++++++ .../maven-conf-ignore-ext/.mvn/extensions.xml | 9 +++++ .../projects/maven-conf-ignore-ext/pom.xml | 27 +++++++++++++++ 10 files changed, 202 insertions(+), 14 deletions(-) create mode 100644 integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfIgnoreExtDefNativeIT.java create mode 100644 integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfIgnoreExtDefTest.java create mode 100644 integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfIgnoreExtNativeIT.java create mode 100644 integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfIgnoreExtTest.java create mode 100644 integration-tests/src/test/projects/maven-conf-ignore-ext-def/.mvn/extensions.xml create mode 100644 integration-tests/src/test/projects/maven-conf-ignore-ext-def/pom.xml create mode 100644 integration-tests/src/test/projects/maven-conf-ignore-ext/.mvn/extensions.xml create mode 100644 integration-tests/src/test/projects/maven-conf-ignore-ext/pom.xml diff --git a/client/src/main/java/org/mvndaemon/mvnd/client/DaemonParameters.java b/client/src/main/java/org/mvndaemon/mvnd/client/DaemonParameters.java index 1dab82a5c..ccf7d4371 100644 --- a/client/src/main/java/org/mvndaemon/mvnd/client/DaemonParameters.java +++ b/client/src/main/java/org/mvndaemon/mvnd/client/DaemonParameters.java @@ -491,16 +491,21 @@ private static List readCoreExtensionsDescriptor(Path multiModule private static List filterCoreExtensions(List coreExtensions) { Set exclusions = new HashSet<>(); - String exclusionsString = - systemProperty(Environment.MVND_CORE_EXTENSIONS_EXCLUDE).asString(); + String exclusionsString = systemProperty(Environment.MVND_CORE_EXTENSIONS_EXCLUDE) + .orDefault() + .asString(); if (exclusionsString != null) { exclusions.addAll(Arrays.stream(exclusionsString.split(",")) .filter(e -> e != null && !e.trim().isEmpty()) .collect(Collectors.toList())); } - return coreExtensions.stream() - .filter(e -> !exclusions.contains(e.getGroupId() + ":" + e.getArtifactId())) - .collect(Collectors.toList()); + if (!exclusions.isEmpty()) { + return coreExtensions.stream() + .filter(e -> !exclusions.contains(e.getGroupId() + ":" + e.getArtifactId())) + .collect(Collectors.toList()); + } else { + return coreExtensions; + } } private static Properties loadProperties(Path path) { diff --git a/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfIgnoreExtDefNativeIT.java b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfIgnoreExtDefNativeIT.java new file mode 100644 index 000000000..70994d2c5 --- /dev/null +++ b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfIgnoreExtDefNativeIT.java @@ -0,0 +1,24 @@ +/* + * 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.mvndaemon.mvnd.it; + +import org.mvndaemon.mvnd.junit.MvndNativeTest; + +@MvndNativeTest(projectDir = "src/test/projects/maven-conf-ignore-ext-def") +class MavenConfIgnoreExtDefNativeIT extends MavenConfNativeIT {} diff --git a/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfIgnoreExtDefTest.java b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfIgnoreExtDefTest.java new file mode 100644 index 000000000..31b5b9224 --- /dev/null +++ b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfIgnoreExtDefTest.java @@ -0,0 +1,24 @@ +/* + * 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.mvndaemon.mvnd.it; + +import org.mvndaemon.mvnd.junit.MvndTest; + +@MvndTest(projectDir = "src/test/projects/maven-conf-ignore-ext-def") +class MavenConfIgnoreExtDefTest extends MavenConfIgnoreExtDefNativeIT {} diff --git a/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfIgnoreExtNativeIT.java b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfIgnoreExtNativeIT.java new file mode 100644 index 000000000..80f6495d8 --- /dev/null +++ b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfIgnoreExtNativeIT.java @@ -0,0 +1,34 @@ +/* + * 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.mvndaemon.mvnd.it; + +import java.util.ArrayList; +import java.util.List; + +import org.mvndaemon.mvnd.junit.MvndNativeTest; + +@MvndNativeTest(projectDir = "src/test/projects/maven-conf-ignore-ext") +class MavenConfIgnoreExtNativeIT extends MavenConfNativeIT { + @Override + protected List mvndParams() { + ArrayList result = new ArrayList<>(super.mvndParams()); + result.add("-Dmvnd.coreExtensionsExclude=foo:bar"); + return result; + } +} diff --git a/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfIgnoreExtTest.java b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfIgnoreExtTest.java new file mode 100644 index 000000000..3df1990c6 --- /dev/null +++ b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfIgnoreExtTest.java @@ -0,0 +1,24 @@ +/* + * 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.mvndaemon.mvnd.it; + +import org.mvndaemon.mvnd.junit.MvndTest; + +@MvndTest(projectDir = "src/test/projects/maven-conf-ignore-ext") +class MavenConfIgnoreExtTest extends MavenConfIgnoreExtNativeIT {} diff --git a/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfNativeIT.java b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfNativeIT.java index 75c84bde0..4a6e5da78 100644 --- a/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfNativeIT.java +++ b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfNativeIT.java @@ -21,6 +21,8 @@ import javax.inject.Inject; import java.io.IOException; +import java.util.Arrays; +import java.util.List; import org.junit.jupiter.api.Test; import org.mvndaemon.mvnd.assertj.TestClientOutput; @@ -43,17 +45,20 @@ class MavenConfNativeIT { void version() throws IOException, InterruptedException { final TestClientOutput o = new TestClientOutput(); // this test also exercise the "-D foo=bar" syntax for defining properties - client.execute( - o, - "org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate", - "-D", - "expression=maven.conf", - "-q", - "-DforceStdout", - "--raw-streams") - .assertSuccess(); + client.execute(o, mvndParams().toArray(new String[0])).assertSuccess(); String conf = parameters.mvndHome().resolve("mvn").resolve("conf").toString(); assertTrue( o.getMessages().stream().anyMatch(m -> m.toString().contains(conf)), "Output should contain " + conf); } + + protected List mvndParams() { + return Arrays.asList( + "org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate", + "-D", + "expression=maven.conf", + "-q", + "-DforceStdout", + "--raw-streams", + "-X"); + } } diff --git a/integration-tests/src/test/projects/maven-conf-ignore-ext-def/.mvn/extensions.xml b/integration-tests/src/test/projects/maven-conf-ignore-ext-def/.mvn/extensions.xml new file mode 100644 index 000000000..640cfc121 --- /dev/null +++ b/integration-tests/src/test/projects/maven-conf-ignore-ext-def/.mvn/extensions.xml @@ -0,0 +1,9 @@ + + + + + io.takari.maven + takari-smart-builder + 0.6.4 + + \ No newline at end of file diff --git a/integration-tests/src/test/projects/maven-conf-ignore-ext-def/pom.xml b/integration-tests/src/test/projects/maven-conf-ignore-ext-def/pom.xml new file mode 100644 index 000000000..6a1c209fa --- /dev/null +++ b/integration-tests/src/test/projects/maven-conf-ignore-ext-def/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + org.mvndaemon.mvnd.test.maven-conf + maven-conf-ignore-ext-def + 0.0.1-SNAPSHOT + pom + + \ No newline at end of file diff --git a/integration-tests/src/test/projects/maven-conf-ignore-ext/.mvn/extensions.xml b/integration-tests/src/test/projects/maven-conf-ignore-ext/.mvn/extensions.xml new file mode 100644 index 000000000..ae56bd22e --- /dev/null +++ b/integration-tests/src/test/projects/maven-conf-ignore-ext/.mvn/extensions.xml @@ -0,0 +1,9 @@ + + + + + foo + bar + 1.0.0 + + \ No newline at end of file diff --git a/integration-tests/src/test/projects/maven-conf-ignore-ext/pom.xml b/integration-tests/src/test/projects/maven-conf-ignore-ext/pom.xml new file mode 100644 index 000000000..fb803ed44 --- /dev/null +++ b/integration-tests/src/test/projects/maven-conf-ignore-ext/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + org.mvndaemon.mvnd.test.maven-conf + maven-conf-ignore-ext + 0.0.1-SNAPSHOT + pom + + \ No newline at end of file