Clean up some warnings during the build (#750)

This commit is contained in:
Guillaume Nodet
2022-12-13 23:00:11 +01:00
committed by GitHub
parent bc021d0577
commit 25b5117749
7 changed files with 35 additions and 79 deletions

View File

@@ -22,8 +22,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@@ -34,10 +36,27 @@ import java.util.List;
import java.util.Locale;
import java.util.Random;
import java.util.UUID;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class DaemonRegistryTest {
private PrintStream oldSysErr;
private PrintStream newSysErr;
@BeforeEach
void setup() {
oldSysErr = System.err;
newSysErr = new PrintStream(new ByteArrayOutputStream());
System.setErr(newSysErr);
}
@AfterEach
void tearDown() {
System.setErr(oldSysErr);
}
@Test
public void testReadWrite() throws IOException {
Path temp = File.createTempFile("reg", ".data").toPath();

View File

@@ -652,7 +652,7 @@ public class CachingProjectBuilder implements ProjectBuilder {
return noErrors;
}
@SuppressWarnings("checkstyle:methodlength")
@SuppressWarnings({"checkstyle:methodlength", "deprecation"})
private void initProject(
MavenProject project,
Map<File, MavenProject> projects,

View File

@@ -49,10 +49,15 @@ public class DependencyGraph<K> {
private final Map<K, Set<K>> transitiveUpstreams;
private final Map<K, List<K>> downstreams;
@SuppressWarnings("unchecked")
public static DependencyGraph<MavenProject> fromMaven(MavenSession session) {
final ProjectDependencyGraph graph = session.getProjectDependencyGraph();
return fromMaven(graph);
Map<String, Object> data = session.getRequest().getData();
DependencyGraph<MavenProject> graph = (DependencyGraph<MavenProject>) data.get(DependencyGraph.class.getName());
if (graph == null) {
graph = fromMaven(session.getProjectDependencyGraph());
data.put(DependencyGraph.class.getName(), graph);
}
return graph;
}
static DependencyGraph<MavenProject> fromMaven(ProjectDependencyGraph graph) {

View File

@@ -99,8 +99,7 @@ public class SmartBuilder implements Builder {
session.getRepositorySession().getData().set(ReactorBuildStatus.class, reactorBuildStatus);
DependencyGraph<MavenProject> graph =
(DependencyGraph<MavenProject>) session.getRequest().getData().get(DependencyGraph.class.getName());
DependencyGraph<MavenProject> graph = DependencyGraph.fromMaven(session);
// log overall build info
final int degreeOfConcurrency = session.getRequest().getDegreeOfConcurrency();

View File

@@ -53,7 +53,6 @@ public class ClientDispatcher extends BuildEventListener {
final MavenSession session = event.getSession();
final int degreeOfConcurrency = session.getRequest().getDegreeOfConcurrency();
final DependencyGraph<MavenProject> dependencyGraph = DependencyGraph.fromMaven(session);
session.getRequest().getData().put(DependencyGraph.class.getName(), dependencyGraph);
final int maxThreads =
degreeOfConcurrency == 1 ? 1 : dependencyGraph.computeMaxWidth(degreeOfConcurrency, 1000);

View File

@@ -61,6 +61,7 @@ public class DaemonPrompter extends AbstractInputHandler implements Prompter, In
}
@Override
@SuppressWarnings("unchecked")
public String prompt(String message, List possibleValues, String defaultReply) throws PrompterException {
return doPrompt(message, possibleValues, defaultReply, false);
}

77
pom.xml
View File

@@ -92,7 +92,6 @@
<buildnumber-maven-plugin.version>3.0.0</buildnumber-maven-plugin.version>
<compiler.version>3.10.1</compiler.version>
<groovy-maven-plugin.version>2.1.0</groovy-maven-plugin.version>
<license-maven-plugin.version>4.2.rc3</license-maven-plugin.version>
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
<maven-install-plugin.version>3.1.0</maven-install-plugin.version>
<maven-shade-plugin.version>3.4.1</maven-shade-plugin.version>
@@ -335,65 +334,6 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>${license-maven-plugin.version}</version>
<configuration>
<inlineHeader>Copyright ${project.inceptionYear} the original author or authors.
Licensed 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.</inlineHeader>
<excludes>
<exclude>**/*.adoc</exclude>
<exclude>**/README.*</exclude>
<exclude>**/.cache/**</exclude>
<exclude>**/.gitkeep</exclude>
<exclude>**/mvnd.properties.template</exclude>
<exclude>**/m2.conf</exclude>
<exclude>**/mvnd</exclude>
<exclude>**/mvnDebug</exclude>
<exclude>**/.mvn/maven.config</exclude>
<exclude>**/.mvn/jvm.config</exclude>
<exclude>.gitattributes/</exclude>
<exclude>.git-blame-ignore-revs</exclude>
<exclude>.mvn/maven.config</exclude>
<exclude>.mvn/wrapper/</exclude>
<exclude>LICENSE.txt</exclude>
<exclude>NOTICE.txt</exclude>
<exclude>mvnw</exclude>
<exclude>mvnw.cmd</exclude>
<exclude>pom.xml.versionsBackup</exclude>
<exclude>**/*.so</exclude>
<exclude>**/*.dll</exclude>
<exclude>**/*.jnilib</exclude>
<exclude>**/Makefile*</exclude>
<exclude>**/docker/**</exclude>
<exclude>**/*.tpl</exclude>
</excludes>
<mapping>
<bash>SCRIPT_STYLE</bash>
<groovy>SLASHSTAR_STYLE</groovy>
<java>SLASHSTAR_STYLE</java>
<mvn>SCRIPT_STYLE</mvn>
<mvnd.sh>SCRIPT_STYLE</mvnd.sh>
<mvns>SCRIPT_STYLE</mvns>
<vbs>APOSTROPHE_STYLE</vbs>
</mapping>
<skipExistingHeaders>true</skipExistingHeaders>
<!-- we want to keep third party license headers -->
<failIfUnknown>true</failIfUnknown>
</configuration>
</plugin>
<plugin>
<groupId>ca.vanzyl.provisio.maven.plugins</groupId>
<artifactId>provisio-maven-plugin</artifactId>
@@ -474,6 +414,11 @@ limitations under the License.</inlineHeader>
<tagNameFormat>@{project.version}</tagNameFormat>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.1</version>
</plugin>
</plugins>
</pluginManagement>
@@ -488,18 +433,6 @@ limitations under the License.</inlineHeader>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>format</goal>
</goals>
<phase>process-sources</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>