gnodet commented on code in PR #11405:
URL: https://github.com/apache/maven/pull/11405#discussion_r3646643210
##########
api/maven-api-core/src/main/java/org/apache/maven/api/Constants.java:
##########
@@ -739,5 +739,11 @@ public final class Constants {
*/
public static final String MAVEN_MODEL_PROCESSOR_REFERENCE_TYPE_PREFIX =
"maven.model.processor.referenceType.";
+ /**
+ * System property to keep temp material for diagnostics.
+ *
+ */
+ public static final String KEEP_PROP = "maven.tempfile.keep";
Review Comment:
All 113 other constants in this file use the `MAVEN_` prefix (`MAVEN_HOME`,
`MAVEN_CACHE_STATS`, `MAVEN_REPO_LOCAL`, etc.). This should be
`MAVEN_TEMPFILE_KEEP`. Also missing `@since 4.1.0` and `@Config` annotation (71
other constants have `@Config`).
```suggestion
/**
* System property to keep temp material for diagnostics.
*
* @since 4.1.0
*/
@Config(type = "java.lang.Boolean", defaultValue = "false")
public static final String MAVEN_TEMPFILE_KEEP = "maven.tempfile.keep";
```
##########
api/maven-api-core/src/main/java/org/apache/maven/api/services/TempFileService.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.IOException;
+import java.nio.file.Path;
+
+import org.apache.maven.api.Service;
+import org.apache.maven.api.Session;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * Service to create and track temporary files/directories for a Maven build.
+ * All created paths are deleted automatically when the session ends.
+ */
+public interface TempFileService extends Service {
+
+ /**
+ * Creates a temp file in the default temp directory.
+ */
+ @Nonnull
+ Path createTempFile(Session session, String prefix, String suffix) throws
IOException;
+
+ /**
+ * Creates a temp file in the given directory.
+ */
+ @Nonnull
+ Path createTempFile(Session session, String prefix, String suffix, Path
directory) throws IOException;
+
+ /**
+ * Creates a temp directory in the default temp directory.
+ */
+ @Nonnull
+ Path createTempDirectory(Session session, String prefix) throws
IOException;
+
+ /**
+ * Creates a temp directory in the given directory.
+ */
+ @Nonnull
+ Path createTempDirectory(Session session, String prefix, Path directory)
throws IOException;
+
+ /**
+ * Registers an externally created path for cleanup at session end.
+ */
+ @Nonnull
+ void register(Session session, Path path);
Review Comment:
`@Nonnull` on a `void` return type is semantically meaningless. In existing
services (`ArtifactDeployer.deploy`, `ArtifactManager.setPath`), `@Nonnull` is
applied to parameters, not void returns.
Same issue on `cleanup()` below.
```suggestion
void register(@Nonnull Session session, @Nonnull Path path);
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]