Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ public void putRemoteFile(
// We do this in here so we can checksum the artifact metadata too, otherwise it could be metadata itself
for (String extension : checksums.keySet()) {
// TODO shouldn't need a file intermediary - improve wagon to take a stream
File temp = File.createTempFile("maven-artifact", null);
File temp = Files.createTempFile("maven-artifact", null).toFile();
temp.deleteOnExit();
byte[] bytes = sums.get(extension).getBytes(StandardCharsets.UTF_8);
Files.write(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -91,7 +92,7 @@ public synchronized File createTempDir() {
}

public synchronized File createTempFile() throws IOException {
File tempFile = File.createTempFile(baseFilename, fileSuffix);
File tempFile = Files.createTempFile(baseFilename, fileSuffix).toFile();
tempFile.deleteOnExit();
markForDeletion(tempFile);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

import org.codehaus.plexus.util.Os;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -64,7 +65,7 @@ void testWindowsPaths() throws Exception {
}

private File createTempFile(String name) throws IOException {
File tempFile = File.createTempFile(name, ".xml");
File tempFile = Files.createTempFile(name, ".xml").toFile();
tempFile.deleteOnExit();
return tempFile;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
Expand Down Expand Up @@ -85,7 +86,8 @@ void isMatchingProjectMatchOnSelectorReturnsTrue(String selector) {

@Test
void isMatchingProjectMatchOnFileReturnsTrue() throws IOException {
final File tempFile = File.createTempFile("maven-core-unit-test-pom", ".xml");
final File tempFile =
Files.createTempFile("maven-core-unit-test-pom", ".xml").toFile();
final String selector = tempFile.getName();
final MavenProject mavenProject = createMavenProject("maven-core");
mavenProject.setFile(tempFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security´s everybody favourite.
This might be a good example to integrate and then build up from there avoiding further friction. Giving more freedom and attention to review.

[WARNING] The recipe produced 16 warning(s). Please report this to the recipe author.
[WARNING] Changes have been made to its/core-it-suite/src/test/resources/mng-0612/plugin/src/main/java/org/apache/maven/its/it0125/DependenciesMojo.java by:
[WARNING]     org.openrewrite.java.security.JavaSecurityBestPractices
[WARNING]         org.openrewrite.staticanalysis.BufferedWriterCreationRecipes
[WARNING]             org.openrewrite.staticanalysis.BufferedWriterCreationRecipes$BufferedWriterFromNewFileWriterWithFileArgumentRecipe
[WARNING] Changes have been made to compat/maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceTest.java by:
[WARNING]     org.openrewrite.java.security.JavaSecurityBestPractices
[WARNING]         org.openrewrite.java.security.SecureTempFileCreation
[WARNING] Changes have been made to impl/maven-core/src/test/java/org/apache/maven/graph/ProjectSelectorTest.java by:
[WARNING]     org.openrewrite.java.security.JavaSecurityBestPractices
[WARNING]         org.openrewrite.java.security.SecureTempFileCreation
[WARNING] Changes have been made to compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java by:
[WARNING]     org.openrewrite.java.security.JavaSecurityBestPractices
[WARNING]         org.openrewrite.java.security.SecureTempFileCreation
[WARNING] Changes have been made to compat/maven-compat/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.java by:
[WARNING]     org.openrewrite.java.security.JavaSecurityBestPractices
[WARNING]         org.openrewrite.java.security.SecureTempFileCreation
[WARNING] Please review and commit the results.
[WARNING] Estimate time saved: 9m

import java.io.IOException;
import java.nio.file.Files;
import java.util.Iterator;
import java.util.Set;

Expand Down Expand Up @@ -78,7 +78,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}

try {
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
BufferedWriter writer = Files.newBufferedWriter(file.toPath());

for (Iterator iterator = artifacts.iterator(); iterator.hasNext(); ) {
Artifact artifact = (Artifact) iterator.next();
Expand Down
98 changes: 81 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -714,21 +714,21 @@ under the License.
<artifactId>modello-maven-plugin</artifactId>
<configuration>
<licenseText>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
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
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.</licenseText>
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.</licenseText>
</configuration>
</plugin>
<!-- enforce backwards compatibility -->
Expand Down Expand Up @@ -807,9 +807,59 @@ under the License.</licenseText>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.8.1</version>
<configuration>
<activeRecipes>
<!-- Issue: https://github.com/apache/maven/pull/2277 -->
<!-- Fix: https://github.com/openrewrite/rewrite-static-analysis/pull/558 -->
<!-- <recipe>org.openrewrite.staticanalysis.ReplaceCollectToListWithToList</recipe> -->
<!-- <recipe>org.openrewrite.staticanalysis.ReplaceCollectToListWithToList</recipe> -->
<!-- <recipe>org.openrewrite.staticanalysis.RemoveUnusedPrivateFields</recipe> -->
<!-- <recipe>org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods</recipe> -->
<!-- <recipe>org.openrewrite.staticanalysis.UnnecessaryThrows</recipe> -->
<!-- <recipe>org.openrewrite.java.ShortenFullyQualifiedTypeReferences</recipe> -->
<!-- Issue: https://github.com/apache/maven/pull/2338 -->
<!-- Fix: https://github.com/openrewrite/rewrite-static-analysis/pull/560 -->
<!-- <recipe>org.openrewrite.staticanalysis.RemoveUnusedParams</recipe> -->
<recipe>org.openrewrite.java.security.JavaSecurityBestPractices</recipe>
<recipe>org.openrewrite.staticanalysis.RemoveUnusedLocalVariables</recipe>
</activeRecipes>
<exportDatatables>true</exportDatatables>
<failOnDryRunResults>true</failOnDryRunResults>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-static-analysis</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-java-security</artifactId>
<version>3.8.0</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>rewrite-maven-plugin</id>
<goals>
<goal>run</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- undo-->
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
</plugin>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its only active on clean install when here, why so?

<plugin>
<groupId>io.github.olamy.maven.plugins</groupId>
<artifactId>jacoco-aggregator-maven-plugin</artifactId>
Expand All @@ -822,10 +872,10 @@ under the License.</licenseText>
<configuration>
<asfExtOptions>
<charter>The mission of the Apache Maven project is to create and maintain software
libraries that provide a widely-used project build tool, targeting mainly Java
development. Apache Maven promotes the use of dependencies via a
standardized coordinates system, binary plugins, and a standard build
lifecycle.</charter>
libraries that provide a widely-used project build tool, targeting mainly Java
development. Apache Maven promotes the use of dependencies via a
standardized coordinates system, binary plugins, and a standard build
lifecycle.</charter>
</asfExtOptions>
</configuration>
</plugin>
Expand Down Expand Up @@ -1170,5 +1220,19 @@ under the License.</licenseText>
</plugins>
</build>
</profile>
<profile>
<id>rewrite</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Loading