You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "cstamas (via GitHub)" <gi...@apache.org> on 2024/08/23 11:14:09 UTC
[PR] [MNG-8222] Extend PropertyContributor [maven]
cstamas opened a new pull request, #1679:
URL: https://github.com/apache/maven/pull/1679
Add more contextual info to it.
---
https://issues.apache.org/jira/browse/MNG-8222
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MNG-8222] Extend PropertyContributor [maven]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #1679:
URL: https://github.com/apache/maven/pull/1679#discussion_r1728889706
##########
api/maven-api-spi/src/main/java/org/apache/maven/api/spi/PropertyContributor.java:
##########
@@ -33,9 +34,12 @@
@Consumer
public interface PropertyContributor extends SpiService {
/**
- * Invoked just before session is created with a mutable map that carries collected user properties so far.
+ * Invoked just before session is created.
*
- * @param userProperties The mutable user properties, never {@code null}.
+ * @param systemProperties Immutable map of system properties, never {@code null}.
+ * @param userProperties Immutable map of user properties, never {@code null}.
+ * @param topDirectory The path of top directory, never {@code null}.
*/
- void contribute(Map<String, String> userProperties);
+ Map<String, String> contribute(
+ Map<String, String> systemProperties, Map<String, String> userProperties, Path topDirectory);
Review Comment:
I like type safe things, so added "proto session"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MNG-8222] Extend PropertyContributor [maven]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #1679:
URL: https://github.com/apache/maven/pull/1679#issuecomment-2488720732
Superseded by https://github.com/apache/maven/pull/1929
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MNG-8222] Extend PropertyContributor [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #1679:
URL: https://github.com/apache/maven/pull/1679#discussion_r1728899433
##########
maven-core/src/main/java/org/apache/maven/internal/aether/PropertyContributorExtender.java:
##########
@@ -50,13 +54,53 @@ class PropertyContributorExtender implements MavenExecutionRequestExtender {
public void extend(MavenExecutionRequest mavenExecutionRequest) {
Map<String, PropertyContributor> effectivePropertyContributors = lookup.lookupMap(PropertyContributor.class);
if (!effectivePropertyContributors.isEmpty()) {
- HashMap<String, String> userPropertiesMap = new HashMap<>((Map) mavenExecutionRequest.getUserProperties());
+ final Version mavenVersion = lookup.lookup(VersionParser.class)
+ .parseVersion(lookup.lookup(RuntimeInformation.class).getMavenVersion());
+ final Map<String, String> systemPropertiesMap =
+ Map.copyOf((Map) mavenExecutionRequest.getSystemProperties());
+ final Map<String, String> userPropertiesMap = Map.copyOf((Map) mavenExecutionRequest.getUserProperties());
+ final ProtoSession protoSession = new ProtoSession() {
+ @Override
+ public Version getMavenVersion() {
+ return mavenVersion;
+ }
+
+ @Override
+ public Map<String, String> getUserProperties() {
+ return userPropertiesMap;
+ }
+
+ @Override
+ public Map<String, String> getSystemProperties() {
+ return systemPropertiesMap;
+ }
+
+ @Override
+ public Path getTopDirectory() {
+ return mavenExecutionRequest.getTopDirectory();
+ }
+
+ @Override
+ public Path getRootDirectory() {
+ return mavenExecutionRequest.getRootDirectory();
+ }
+ };
+
+ final Properties newProperties = new Properties();
+
for (PropertyContributor contributor : effectivePropertyContributors.values()) {
- contributor.contribute(userPropertiesMap);
+ Map<String, String> contribution = contributor.contribute(protoSession);
Review Comment:
A given contributor won't see properties added by previous contributors, is that what we want ?
##########
api/maven-api-core/src/main/java/org/apache/maven/api/ProtoSession.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.apache.maven.api;
Review Comment:
Should it be moved to `org.apache.maven.api.spi` ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MNG-8222] Extend PropertyContributor [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #1679:
URL: https://github.com/apache/maven/pull/1679#discussion_r1728833841
##########
api/maven-api-spi/src/main/java/org/apache/maven/api/spi/PropertyContributor.java:
##########
@@ -33,9 +34,12 @@
@Consumer
public interface PropertyContributor extends SpiService {
/**
- * Invoked just before session is created with a mutable map that carries collected user properties so far.
+ * Invoked just before session is created.
*
- * @param userProperties The mutable user properties, never {@code null}.
+ * @param systemProperties Immutable map of system properties, never {@code null}.
+ * @param userProperties Immutable map of user properties, never {@code null}.
+ * @param topDirectory The path of top directory, never {@code null}.
*/
- void contribute(Map<String, String> userProperties);
+ Map<String, String> contribute(
+ Map<String, String> systemProperties, Map<String, String> userProperties, Path topDirectory);
Review Comment:
I'd use a `Map<String, String>` for paths, to store all required paths, similar to https://github.com/apache/maven/blob/6ac914d6f97517d827f51afa7aaa41e5acdbe023/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java#L620-L626, as we probably also need the `rootDirectory`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MNG-8222] Extend PropertyContributor [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #1679:
URL: https://github.com/apache/maven/pull/1679#discussion_r1728900903
##########
api/maven-api-core/src/main/java/org/apache/maven/api/ProtoSession.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.apache.maven.api;
+
+import java.nio.file.Path;
+import java.util.Map;
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.annotations.ThreadSafe;
+
+/**
+ * The proto session, material used to create {@link Session}.
+ *
+ * @since 4.0.0
+ */
+@Experimental
+@ThreadSafe
+public interface ProtoSession {
+
Review Comment:
We should give access to CLI commands / arguments I think, this may be needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MNG-8222] Extend PropertyContributor [maven]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas closed pull request #1679: [MNG-8222] Extend PropertyContributor
URL: https://github.com/apache/maven/pull/1679
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MNG-8222] Extend PropertyContributor [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #1679:
URL: https://github.com/apache/maven/pull/1679#discussion_r1728905518
##########
api/maven-api-core/src/main/java/org/apache/maven/api/ProtoSession.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.apache.maven.api;
+
+import java.nio.file.Path;
+import java.util.Map;
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.annotations.ThreadSafe;
+
+/**
+ * The proto session, material used to create {@link Session}.
+ *
+ * @since 4.0.0
+ */
+@Experimental
+@ThreadSafe
+public interface ProtoSession {
+
Review Comment:
Maybe just a `List<String>` to not expose commons-cli.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MNG-8222] Extend PropertyContributor [maven]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #1679:
URL: https://github.com/apache/maven/pull/1679#issuecomment-2313581431
We will rework this, but leaving as DRAFT for reference
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org