You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/11/28 13:40:01 UTC

[GitHub] [maven] cstamas opened a new pull request, #884: Add M4 Transport API

cstamas opened a new pull request, #884:
URL: https://github.com/apache/maven/pull/884

   Something simple to use and would reuse all the auth/proxy etc data from Maven. Intentionally super-trivial API.
   
   If something more "serious" needed, plugin should probably roll it's own solution.


-- 
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


[GitHub] [maven] cstamas commented on pull request #884: [MNG-7607] Add M4 Transport API

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #884:
URL: https://github.com/apache/maven/pull/884#issuecomment-1331929692

   > We also have another case when user want to download a custom resource from any remote url. And also want to use authorization configuration from settings/servers and preserve settings/proxy for connections.
   
   @slawekjaranowski  But user can create own new instance of RemoteRepository (using whatever values/url he wants), and use that. Or is that not feasible?


-- 
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


[GitHub] [maven] cstamas merged pull request #884: [MNG-7607] Add M4 Transport API

Posted by GitBox <gi...@apache.org>.
cstamas merged PR #884:
URL: https://github.com/apache/maven/pull/884


-- 
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


[GitHub] [maven] gnodet commented on a diff in pull request #884: Add M4 Transport API

Posted by GitBox <gi...@apache.org>.
gnodet commented on code in PR #884:
URL: https://github.com/apache/maven/pull/884#discussion_r1033659141


##########
api/maven-api-core/src/main/java/org/apache/maven/api/services/Transport.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.services;
+
+import java.io.Closeable;
+import java.net.URI;
+import java.nio.charset.Charset;
+import java.nio.file.Path;
+import org.apache.maven.api.RemoteRepository;
+import org.apache.maven.api.annotations.Consumer;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nullable;
+
+/**
+ * Transport for specified remote repository (using provided remote repository base URI as root). Must be treated as a
+ * resource, best in try-with-resource block.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Consumer
+public interface Transport extends Closeable {
+    /**
+     * GETs the source URI content into target (does not have to exist, or will be overwritten if exist). The
+     * source MUST BE relative from the {@link RemoteRepository#getUrl()} root.
+     *
+     * @return {@code true} if operation succeeded, {@code false} if source does not exist.
+     * @throws RuntimeException If failed (and not due source not exists).
+     */
+    boolean get(URI relativeSource, Path target);
+
+    /**
+     * GETs the source URI content into target consumer. The
+     * source MUST BE relative from the {@link RemoteRepository#getUrl()} root.
+     *
+     * @return the byte array if operation succeeded, {@code null} if source does not exist.
+     * @throws RuntimeException If failed (and not due source not exists).
+     */
+    @Nullable
+    byte[] getBytes(URI relativeSource);
+
+    /**
+     * GETs the source URI content as string. The
+     * source MUST BE relative from the {@link RemoteRepository#getUrl()} root.
+     *
+     * @return the string if operation succeeded, {@code null} if source does not exist.
+     * @throws RuntimeException If failed (and not due source not exists).
+     */
+    @Nullable
+    String getString(URI relativeSource, Charset charset);
+
+    /**
+     * PUTs the source file (must exist as file) to target URI. The target MUST BE relative from the
+     * {@link RemoteRepository#getUrl()} root.
+     *
+     * @throws RuntimeException If PUT fails for any reason.
+     */
+    void put(Path source, URI relativeTarget);
+
+    /**
+     * PUTs the source byte array to target URI. The target MUST BE relative from the
+     * {@link RemoteRepository#getUrl()} root.
+     *
+     * @throws RuntimeException If PUT fails for any reason.
+     */
+    void putBytes(byte[] source, URI relativeTarget);
+
+    /**
+     * PUTs the source string to target URI. The target MUST BE relative from the
+     * {@link RemoteRepository#getUrl()} root.
+     *
+     * @throws RuntimeException If PUT fails for any reason.
+     */
+    void putString(String source, Charset charset, URI relativeTarget);

Review Comment:
   May I ask for a default:
   ```
   default void putString(String source, URI relativeTarget) {
       putString(source, StandardCharsets.UTF_8, relativeTarget);
   }
   ```



##########
api/maven-api-core/src/main/java/org/apache/maven/api/services/Transport.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.services;
+
+import java.io.Closeable;
+import java.net.URI;
+import java.nio.charset.Charset;
+import java.nio.file.Path;
+import org.apache.maven.api.RemoteRepository;
+import org.apache.maven.api.annotations.Consumer;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nullable;
+
+/**
+ * Transport for specified remote repository (using provided remote repository base URI as root). Must be treated as a
+ * resource, best in try-with-resource block.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Consumer
+public interface Transport extends Closeable {
+    /**
+     * GETs the source URI content into target (does not have to exist, or will be overwritten if exist). The
+     * source MUST BE relative from the {@link RemoteRepository#getUrl()} root.
+     *
+     * @return {@code true} if operation succeeded, {@code false} if source does not exist.
+     * @throws RuntimeException If failed (and not due source not exists).
+     */
+    boolean get(URI relativeSource, Path target);
+
+    /**
+     * GETs the source URI content into target consumer. The
+     * source MUST BE relative from the {@link RemoteRepository#getUrl()} root.
+     *
+     * @return the byte array if operation succeeded, {@code null} if source does not exist.
+     * @throws RuntimeException If failed (and not due source not exists).
+     */
+    @Nullable
+    byte[] getBytes(URI relativeSource);
+
+    /**
+     * GETs the source URI content as string. The
+     * source MUST BE relative from the {@link RemoteRepository#getUrl()} root.
+     *
+     * @return the string if operation succeeded, {@code null} if source does not exist.
+     * @throws RuntimeException If failed (and not due source not exists).
+     */
+    @Nullable
+    String getString(URI relativeSource, Charset charset);

Review Comment:
   May I ask for a default:
   ```
   default String getString(URI relativeSource) {
       return getString(relativeSource, StandardCharsets.UTF_8);
   }
   ```



-- 
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


[GitHub] [maven] gnodet commented on a diff in pull request #884: Add M4 Transport API

Posted by GitBox <gi...@apache.org>.
gnodet commented on code in PR #884:
URL: https://github.com/apache/maven/pull/884#discussion_r1033568463


##########
api/maven-api-core/src/main/java/org/apache/maven/api/services/Transport.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * 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.services;
+
+import java.net.URI;
+import java.nio.file.Path;
+
+import org.apache.maven.api.RemoteRepository;
+import org.apache.maven.api.annotations.Consumer;
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * @since 4.0
+ */
+@Experimental
+@Consumer
+public interface Transport
+{

Review Comment:
   I would still add helpers for transferring the data as `byte[]` and `String`.  Even the `java.nio.Files` api now as those !



-- 
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


[GitHub] [maven] slawekjaranowski commented on pull request #884: Add M4 Transport API

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on PR #884:
URL: https://github.com/apache/maven/pull/884#issuecomment-1329296262

   Great idea, I see that we can cover one case when user want to download a custom resource from remote repository.
   
   We also have another case when user want to download a custom resource from any remote url. 
   And also want to use authorization configuration from settings/servers and preserve settings/proxy for connections.
   


-- 
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


[GitHub] [maven] gnodet commented on a diff in pull request #884: Add M4 Transport API

Posted by GitBox <gi...@apache.org>.
gnodet commented on code in PR #884:
URL: https://github.com/apache/maven/pull/884#discussion_r1033666376


##########
api/maven-api-core/src/main/java/org/apache/maven/api/services/Transport.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.services;
+
+import java.io.Closeable;
+import java.net.URI;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import org.apache.maven.api.RemoteRepository;
+import org.apache.maven.api.annotations.Consumer;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.annotations.Nullable;
+
+/**
+ * Transport for specified remote repository (using provided remote repository base URI as root). Must be treated as a
+ * resource, best in try-with-resource block.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Consumer
+public interface Transport extends Closeable {
+    /**
+     * GETs the source URI content into target (does not have to exist, or will be overwritten if exist). The
+     * source MUST BE relative from the {@link RemoteRepository#getUrl()} root.
+     *
+     * @return {@code true} if operation succeeded, {@code false} if source does not exist.
+     * @throws RuntimeException If failed (and not due source not exists).
+     */
+    boolean get(@Nonnull URI relativeSource, @Nonnull Path target);
+
+    /**
+     * GETs the source URI content as byte array. The source MUST BE relative from the {@link RemoteRepository#getUrl()}
+     * root.
+     *
+     * @return the byte array if operation succeeded, {@code null} if source does not exist.
+     * @throws RuntimeException If failed (and not due source not exists).
+     */
+    @Nullable
+    byte[] getBytes(@Nonnull URI relativeSource);
+
+    /**
+     * GETs the source URI content as string. The source MUST BE relative from the {@link RemoteRepository#getUrl()}
+     * root.
+     *
+     * @return the string if operation succeeded, {@code null} if source does not exist.
+     * @throws RuntimeException If failed (and not due source not exists).
+     */
+    @Nullable
+    String getString(@Nonnull URI relativeSource, @Nonnull Charset charset);
+
+    /**
+     * GETs the source URI content as string using UTF8 charset. The source MUST BE relative from the 
+     * {@link RemoteRepository#getUrl()} root.
+     *
+     * @return the string if operation succeeded, {@code null} if source does not exist.
+     * @throws RuntimeException If failed (and not due source not exists).
+     */
+    default String getString(@Nonnull URI relativeSource) {

Review Comment:
   `@Nullable` ?



-- 
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


[GitHub] [maven] cstamas commented on pull request #884: Add M4 Transport API

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #884:
URL: https://github.com/apache/maven/pull/884#issuecomment-1329316827

   One big remark I just noticed: m4 API uses Optional quite extensively, while I went with my own preference. Better to not mix things, and rework this with Optional?


-- 
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