You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2023/01/06 13:42:01 UTC
[maven-mvnd] 04/28: Reformat
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch mvnd-0.9.x
in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git
commit e95bd93dcae85c92bac36a823377d3e839698943
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Fri Jan 6 13:26:18 2023 +0100
Reformat
---
agent/pom.xml | 110 +--
.../main/java/org/mvndaemon/mvnd/agent/Agent.java | 40 +-
build-plugin/pom.xml | 164 ++--
.../org/mvndaemon/mvnd/plugin/doc/DocMojo.java | 46 +-
client/pom.xml | 278 +++---
.../org/mvndaemon/mvnd/client/BuildProperties.java | 25 +-
.../java/org/mvndaemon/mvnd/client/Client.java | 26 +-
.../java/org/mvndaemon/mvnd/client/Completion.java | 26 +-
.../mvnd/client/DaemonClientConnection.java | 39 +-
.../org/mvndaemon/mvnd/client/DaemonConnector.java | 160 ++--
.../mvndaemon/mvnd/client/DaemonDiagnostics.java | 67 +-
.../mvndaemon/mvnd/client/DaemonParameters.java | 125 ++-
.../org/mvndaemon/mvnd/client/DefaultClient.java | 117 ++-
.../org/mvndaemon/mvnd/client/ExecutionResult.java | 26 +-
.../mvnd/client/svm/ReflectionRegistration.java | 25 +-
.../client/svm/StaticMDCBinderSubstitution.java | 26 +-
.../mvnd/client/CompletionGeneratorTest.java | 31 +-
.../mvndaemon/mvnd/client/DaemonConnectorTest.java | 29 +-
.../org/mvndaemon/mvnd/client/EnvironmentTest.java | 60 +-
.../org/mvndaemon/mvnd/client/OsUtilsTest.java | 25 +-
common/pom.xml | 340 +++----
.../org/mvndaemon/mvnd/common/BufferCaster.java | 26 +-
.../org/mvndaemon/mvnd/common/BufferHelper.java | 35 +-
.../mvndaemon/mvnd/common/ByteChannelWrapper.java | 25 +-
.../mvnd/common/DaemonCompatibilitySpec.java | 35 +-
.../mvndaemon/mvnd/common/DaemonConnection.java | 32 +-
.../org/mvndaemon/mvnd/common/DaemonException.java | 26 +-
.../mvnd/common/DaemonExpirationStatus.java | 25 +-
.../java/org/mvndaemon/mvnd/common/DaemonInfo.java | 75 +-
.../org/mvndaemon/mvnd/common/DaemonRegistry.java | 71 +-
.../org/mvndaemon/mvnd/common/DaemonState.java | 26 +-
.../org/mvndaemon/mvnd/common/DaemonStopEvent.java | 33 +-
.../org/mvndaemon/mvnd/common/Environment.java | 73 +-
.../mvndaemon/mvnd/common/InterpolationHelper.java | 53 +-
.../java/org/mvndaemon/mvnd/common/IoUtils.java | 31 +-
.../org/mvndaemon/mvnd/common/JavaVersion.java | 25 +-
.../org/mvndaemon/mvnd/common/MavenDaemon.java | 61 +-
.../java/org/mvndaemon/mvnd/common/Message.java | 443 +++++----
.../java/org/mvndaemon/mvnd/common/OptionType.java | 25 +-
.../main/java/org/mvndaemon/mvnd/common/Os.java | 29 +-
.../java/org/mvndaemon/mvnd/common/OsUtils.java | 63 +-
.../org/mvndaemon/mvnd/common/ProcessHelper.java | 29 +-
.../org/mvndaemon/mvnd/common/SocketFamily.java | 88 +-
.../org/mvndaemon/mvnd/common/SocketHelper.java | 25 +-
.../java/org/mvndaemon/mvnd/common/TimeUtils.java | 46 +-
.../mvnd/common/logging/ClientOutput.java | 25 +-
.../mvnd/common/logging/TerminalOutput.java | 538 +++++------
.../mvndaemon/mvnd/common/DaemonRegistryTest.java | 89 +-
.../org/mvndaemon/mvnd/common/MessageTest.java | 33 +-
.../org/mvndaemon/mvnd/common/OsUtilsTest.java | 26 +-
.../mvndaemon/mvnd/common/SocketFamilyTest.java | 36 +-
.../org/mvndaemon/mvnd/common/TimeUtilsTest.java | 33 +-
daemon/pom.xml | 194 ++--
.../maven/classrealm/MvndClassRealmManager.java | 106 +-
.../java/org/apache/maven/cli/DaemonMavenCli.java | 240 ++---
.../org/apache/maven/cli/MvndHelpFormatter.java | 170 ++--
.../maven/project/CachingProjectBuilder.java | 257 +++--
.../apache/maven/project/SnapshotModelCache.java | 28 +-
.../mvndaemon/mvnd/builder/DependencyGraph.java | 100 +-
.../mvndaemon/mvnd/builder/ProjectComparator.java | 55 +-
.../mvnd/builder/ProjectExecutorService.java | 67 +-
.../mvndaemon/mvnd/builder/ReactorBuildQueue.java | 29 +-
.../mvndaemon/mvnd/builder/ReactorBuildStats.java | 46 +-
.../org/mvndaemon/mvnd/builder/SmartBuilder.java | 52 +-
.../mvndaemon/mvnd/builder/SmartBuilderImpl.java | 54 +-
.../main/java/org/mvndaemon/mvnd/cache/Cache.java | 26 +-
.../org/mvndaemon/mvnd/cache/CacheFactory.java | 26 +-
.../java/org/mvndaemon/mvnd/cache/CacheRecord.java | 26 +-
.../mvnd/cache/impl/DefaultCacheFactory.java | 26 +-
.../mvnd/cache/impl/TimestampCacheFactory.java | 72 +-
.../mvnd/cache/impl/WatchServiceCacheFactory.java | 42 +-
.../InvalidatingExtensionRealmCache.java | 36 +-
.../InvalidatingPluginArtifactsCache.java | 32 +-
.../InvalidatingPluginDescriptorCache.java | 33 +-
.../invalidating/InvalidatingPluginRealmCache.java | 32 +-
.../InvalidatingProjectArtifactsCache.java | 66 +-
.../InvalidatingRealmCacheEventSpy.java | 55 +-
.../java/org/mvndaemon/mvnd/cli/EnvHelper.java | 37 +-
.../mvndaemon/mvnd/daemon/ClientDispatcher.java | 126 ++-
.../java/org/mvndaemon/mvnd/daemon/Connection.java | 26 +-
.../mvndaemon/mvnd/daemon/DaemonExpiration.java | 113 +--
.../mvndaemon/mvnd/daemon/DaemonMemoryStatus.java | 52 +-
.../java/org/mvndaemon/mvnd/daemon/Server.java | 200 ++--
.../mvnd/execution/BuildResumptionAnalyzer.java | 27 +-
.../mvnd/execution/BuildResumptionData.java | 28 +-
.../execution/BuildResumptionDataRepository.java | 30 +-
.../BuildResumptionPersistenceException.java | 27 +-
.../execution/DefaultBuildResumptionAnalyzer.java | 30 +-
.../DefaultBuildResumptionDataRepository.java | 28 +-
.../mvnd/interactivity/DaemonPrompter.java | 32 +-
.../logging/internal/MvndSlf4jConfiguration.java | 46 +-
.../mvnd/logging/internal/SimpleAppender.java | 55 +-
.../mvnd/logging/internal/Slf4jLogger.java | 7 +-
.../mvnd/logging/internal/Slf4jLoggerManager.java | 16 +-
.../mvnd/logging/smart/BuildEventListener.java | 58 +-
.../logging/smart/LoggingExecutionListener.java | 47 +-
.../mvnd/logging/smart/LoggingOutputStream.java | 25 +-
.../logging/smart/ProjectBuildLogAppender.java | 41 +-
.../mvnd/plugin/CachingPluginVersionResolver.java | 35 +-
.../mvnd/plugin/CliMavenPluginManager.java | 134 +--
.../plugin/ValidatingConfigurationListener.java | 7 +-
.../syncontext/DaemonNamedLockFactorySelector.java | 36 +-
.../mvndaemon/mvnd/timing/BuildTimeEventSpy.java | 101 +-
.../mvnd/transfer/DaemonMavenTransferListener.java | 25 +-
.../mvnd/builder/AbstractSmartBuilderTest.java | 26 +-
.../org/mvndaemon/mvnd/builder/DagWidthTest.java | 82 +-
.../mvnd/builder/ProjectComparatorTest.java | 30 +-
.../mvnd/builder/ProjectExecutorServiceTest.java | 36 +-
.../mvnd/builder/ReactorBuildQueueTest.java | 25 +-
.../mvnd/builder/TestProjectDependencyGraph.java | 25 +-
.../mvnd/cache/impl/CacheFactoryTest.java | 31 +-
.../java/org/mvndaemon/mvnd/cli/EnvHelperTest.java | 35 +-
.../mvnd/daemon/ClientDispatcherTest.java | 26 +-
.../java/org/mvndaemon/mvnd/daemon/ServerTest.java | 29 +-
dist/pom.xml | 108 +--
helper/pom.xml | 22 +-
.../java/org/mvndaemon/mvnd/pump/AgentHelper.java | 31 +-
integration-tests/pom.xml | 322 ++++---
.../mvnd/assertj/MatchInOrderAmongOthers.java | 30 +-
.../mvndaemon/mvnd/assertj/TestClientOutput.java | 35 +-
.../mvnd/it/AttachedArtifactResolutionTest.java | 26 +-
.../org/mvndaemon/mvnd/it/BootstrapPluginTest.java | 32 +-
.../org/mvndaemon/mvnd/it/CompletionNativeIT.java | 25 +-
.../java/org/mvndaemon/mvnd/it/CompletionTest.java | 28 +-
.../mvndaemon/mvnd/it/ConcurrentDownloadsTest.java | 33 +-
.../org/mvndaemon/mvnd/it/DaemonCrashTest.java | 38 +-
.../org/mvndaemon/mvnd/it/DeleteRepoNativeIT.java | 29 +-
.../java/org/mvndaemon/mvnd/it/DeleteRepoTest.java | 29 +-
.../test/java/org/mvndaemon/mvnd/it/DistroIT.java | 44 +-
.../test/java/org/mvndaemon/mvnd/it/DupGATest.java | 25 +-
.../org/mvndaemon/mvnd/it/EnvironmentTest.java | 46 +-
.../java/org/mvndaemon/mvnd/it/ExecOutputTest.java | 33 +-
.../org/mvndaemon/mvnd/it/ExtensionsNativeIT.java | 33 +-
.../java/org/mvndaemon/mvnd/it/ExtensionsTest.java | 29 +-
.../java/org/mvndaemon/mvnd/it/ForkedTest.java | 37 +-
.../org/mvndaemon/mvnd/it/InteractiveTest.java | 32 +-
.../org/mvndaemon/mvnd/it/InvokerNativeIT.java | 32 +-
.../java/org/mvndaemon/mvnd/it/InvokerTest.java | 29 +-
.../org/mvndaemon/mvnd/it/JUnitPlatformTest.java | 30 +-
.../org/mvndaemon/mvnd/it/MavenConfNativeIT.java | 45 +-
.../java/org/mvndaemon/mvnd/it/MavenConfTest.java | 29 +-
.../org/mvndaemon/mvnd/it/MaxHeapNativeIT.java | 65 +-
.../java/org/mvndaemon/mvnd/it/MaxHeapTest.java | 38 +-
.../mvndaemon/mvnd/it/ModuleAndPluginNativeIT.java | 57 +-
.../org/mvndaemon/mvnd/it/ModuleAndPluginTest.java | 29 +-
.../org/mvndaemon/mvnd/it/MultiLookupTest.java | 34 +-
.../org/mvndaemon/mvnd/it/MultiModuleTest.java | 70 +-
.../java/org/mvndaemon/mvnd/it/MvndTestUtil.java | 29 +-
.../mvnd/it/NewManagedModuleNativeIT.java | 28 +-
.../mvndaemon/mvnd/it/NewManagedModuleTest.java | 29 +-
.../mvndaemon/mvnd/it/ParentWithPropertyTest.java | 25 +-
.../java/org/mvndaemon/mvnd/it/RawStreamsTest.java | 35 +-
.../mvndaemon/mvnd/it/ResidentExtensionsTest.java | 46 +-
.../mvndaemon/mvnd/it/SingleModuleNativeIT.java | 33 +-
.../org/mvndaemon/mvnd/it/SingleModuleTest.java | 39 +-
.../mvndaemon/mvnd/it/SpecificFileNativeIT.java | 62 +-
.../java/org/mvndaemon/mvnd/it/StopStatusTest.java | 29 +-
.../mvndaemon/mvnd/it/ThreadOptionNativeIT.java | 25 +-
.../org/mvndaemon/mvnd/it/ThreadOptionTest.java | 25 +-
.../org/mvndaemon/mvnd/it/TypeDescriptionTest.java | 25 +-
.../mvndaemon/mvnd/it/UpgradesInBomNativeIT.java | 40 +-
.../org/mvndaemon/mvnd/it/UpgradesInBomTest.java | 28 +-
.../org/mvndaemon/mvnd/it/VersionNativeIT.java | 29 +-
.../java/org/mvndaemon/mvnd/it/VersionTest.java | 26 +-
.../org/mvndaemon/mvnd/junit/ClientFactory.java | 25 +-
.../org/mvndaemon/mvnd/junit/JvmTestClient.java | 30 +-
.../org/mvndaemon/mvnd/junit/MvndNativeTest.java | 25 +-
.../java/org/mvndaemon/mvnd/junit/MvndTest.java | 25 +-
.../mvndaemon/mvnd/junit/MvndTestExtension.java | 131 +--
.../org/mvndaemon/mvnd/junit/NativeTestClient.java | 34 +-
.../org/mvndaemon/mvnd/junit/TestParameters.java | 45 +-
.../org/mvndaemon/mvnd/junit/TestRegistry.java | 36 +-
.../java/org/mvndaemon/mvnd/junit/TestUtils.java | 26 +-
native/pom.xml | 178 ++--
.../java/org/mvndaemon/mvnd/nativ/CLibrary.java | 26 +-
.../org/mvndaemon/mvnd/nativ/MvndNativeLoader.java | 57 +-
.../main/java/org/mvndaemon/mvnd/nativ/OSInfo.java | 35 +-
.../org/mvndaemon/mvnd/nativ/CLibraryTest.java | 31 +-
.../mvndaemon/mvnd/nativ/MvndNativeLoaderTest.java | 25 +-
pom.xml | 1009 ++++++++++----------
180 files changed, 6086 insertions(+), 5299 deletions(-)
diff --git a/agent/pom.xml b/agent/pom.xml
index aed7a480..667afb39 100644
--- a/agent/pom.xml
+++ b/agent/pom.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2021 the original author or authors.
@@ -15,67 +16,66 @@
limitations under the License.
-->
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.maven.daemon</groupId>
- <artifactId>mvnd</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.maven.daemon</groupId>
+ <artifactId>mvnd</artifactId>
+ <version>0.9.0-SNAPSHOT</version>
+ </parent>
- <artifactId>mvnd-agent</artifactId>
+ <artifactId>mvnd-agent</artifactId>
- <packaging>jar</packaging>
- <name>Maven Daemon - Agent</name>
+ <packaging>jar</packaging>
+ <name>Maven Daemon - Agent</name>
- <dependencies>
+ <dependencies>
- <dependency>
- <groupId>org.javassist</groupId>
- <artifactId>javassist</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </dependency>
- </dependencies>
+ </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifestEntries>
- <Premain-Class>org.mvndaemon.mvnd.agent.Agent</Premain-Class>
- <Boot-Class-Path>mvnd-helper-agent-${project.version}.jar</Boot-Class-Path>
- </manifestEntries>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <filters>
- <filter>
- <artifact>org.javassist:javassist</artifact>
- <excludes>
- <exclude>META-INF/MANIFEST.MF</exclude>
- </excludes>
- </filter>
- </filters>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Premain-Class>org.mvndaemon.mvnd.agent.Agent</Premain-Class>
+ <Boot-Class-Path>mvnd-helper-agent-${project.version}.jar</Boot-Class-Path>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <filters>
+ <filter>
+ <artifact>org.javassist:javassist</artifact>
+ <excludes>
+ <exclude>META-INF/MANIFEST.MF</exclude>
+ </excludes>
+ </filter>
+ </filters>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/agent/src/main/java/org/mvndaemon/mvnd/agent/Agent.java b/agent/src/main/java/org/mvndaemon/mvnd/agent/Agent.java
index 3c33984a..2109f5b3 100644
--- a/agent/src/main/java/org/mvndaemon/mvnd/agent/Agent.java
+++ b/agent/src/main/java/org/mvndaemon/mvnd/agent/Agent.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.agent;
@@ -37,15 +40,21 @@ public class Agent {
public static void premain(String args, Instrumentation instrumentation) throws Exception {
instrumentation.addTransformer(new ClassFileTransformer() {
@Override
- public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined,
- ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
+ public byte[] transform(
+ ClassLoader loader,
+ String className,
+ Class<?> classBeingRedefined,
+ ProtectionDomain protectionDomain,
+ byte[] classfileBuffer)
+ throws IllegalClassFormatException {
if ("java/lang/ProcessBuilder".equals(className)) {
try {
ClassPool pool = ClassPool.getDefault();
CtClass clazz = pool.get("java.lang.ProcessBuilder");
pool.importPackage("org.mvndaemon.mvnd.pump");
- clazz.getDeclaredMethod("start",
- new CtClass[] { clazz.getClassPool().get("java.lang.ProcessBuilder$Redirect[]") })
+ clazz.getDeclaredMethod(
+ "start",
+ new CtClass[] {clazz.getClassPool().get("java.lang.ProcessBuilder$Redirect[]")})
.insertBefore(START_WITH_PIPES);
byte[] data = clazz.toBytecode();
clazz.detach();
@@ -60,5 +69,4 @@ public class Agent {
}
});
}
-
}
diff --git a/build-plugin/pom.xml b/build-plugin/pom.xml
index 35007806..7b584dc6 100644
--- a/build-plugin/pom.xml
+++ b/build-plugin/pom.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2019 the original author or authors.
@@ -15,89 +16,88 @@
limitations under the License.
-->
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.maven.daemon</groupId>
- <artifactId>mvnd</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>mvnd-build-maven-plugin</artifactId>
-
- <packaging>maven-plugin</packaging>
- <name>Maven Daemon - Documentation Maven Plugin</name>
-
- <properties>
- <maven.compiler.target>11</maven.compiler.target>
- <maven.compiler.source>11</maven.compiler.source>
-
- <roaster.version>2.23.2.Final</roaster.version>
- <maven.plugin-tools.version>3.6.0</maven.plugin-tools.version>
- <maven-plugin-plugin.version>${maven.plugin-tools.version}</maven-plugin-plugin.version>
- </properties>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>${maven.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-annotations</artifactId>
- <version>${maven.plugin-tools.version}</version>
- </dependency>
-
- </dependencies>
- </dependencyManagement>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.maven.daemon</groupId>
+ <artifactId>mvnd</artifactId>
+ <version>0.9.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>mvnd-build-maven-plugin</artifactId>
+
+ <packaging>maven-plugin</packaging>
+ <name>Maven Daemon - Documentation Maven Plugin</name>
+
+ <properties>
+ <maven.compiler.target>11</maven.compiler.target>
+ <maven.compiler.source>11</maven.compiler.source>
+
+ <roaster.version>2.23.2.Final</roaster.version>
+ <maven.plugin-tools.version>3.6.0</maven.plugin-tools.version>
+ <maven-plugin-plugin.version>${maven.plugin-tools.version}</maven-plugin-plugin.version>
+ </properties>
+
+ <dependencyManagement>
<dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-annotations</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.forge.roaster</groupId>
- <artifactId>roaster-jdt</artifactId>
- <version>${roaster.version}</version>
- </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>${maven.plugin-tools.version}</version>
+ </dependency>
</dependencies>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-plugin-plugin</artifactId>
- <version>${maven-plugin-plugin.version}</version>
- </plugin>
- </plugins>
- </pluginManagement>
-
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-plugin-plugin</artifactId>
- <configuration>
- <goalPrefix>mvnd-build</goalPrefix>
- <mojoDependencies>
- <dep>org.apache.maven:maven-plugin-api</dep>
- </mojoDependencies>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.forge.roaster</groupId>
+ <artifactId>roaster-jdt</artifactId>
+ <version>${roaster.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>${maven-plugin-plugin.version}</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <configuration>
+ <goalPrefix>mvnd-build</goalPrefix>
+ <mojoDependencies>
+ <dep>org.apache.maven:maven-plugin-api</dep>
+ </mojoDependencies>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/build-plugin/src/main/java/org/mvndaemon/mvnd/plugin/doc/DocMojo.java b/build-plugin/src/main/java/org/mvndaemon/mvnd/plugin/doc/DocMojo.java
index 46285f3d..5a660b8a 100644
--- a/build-plugin/src/main/java/org/mvndaemon/mvnd/plugin/doc/DocMojo.java
+++ b/build-plugin/src/main/java/org/mvndaemon/mvnd/plugin/doc/DocMojo.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.plugin.doc;
@@ -46,7 +49,12 @@ import org.jboss.forge.roaster.model.source.JavaEnumSource;
/**
* Extracts JavaDoc blocks from enum entries and stores them into a properties file.
*/
-@Mojo(name = "doc", defaultPhase = LifecyclePhase.NONE, threadSafe = true, requiresProject = true, requiresDependencyResolution = ResolutionScope.NONE)
+@Mojo(
+ name = "doc",
+ defaultPhase = LifecyclePhase.NONE,
+ threadSafe = true,
+ requiresProject = true,
+ requiresDependencyResolution = ResolutionScope.NONE)
public class DocMojo extends AbstractMojo {
/**
@@ -80,8 +88,7 @@ public class DocMojo extends AbstractMojo {
static void extractEnumJavaDoc(Path basePath, String enumClassName) throws MojoFailureException {
final String classRelPath = enumClassName.replace('.', '/');
- final Path enumClassLocation = basePath.resolve("src/main/java")
- .resolve(classRelPath + ".java");
+ final Path enumClassLocation = basePath.resolve("src/main/java").resolve(classRelPath + ".java");
final Path propsPath = basePath.resolve("target/classes/" + classRelPath + ".javadoc.properties");
try {
Files.createDirectories(propsPath.getParent());
@@ -99,8 +106,7 @@ public class DocMojo extends AbstractMojo {
final Properties optionsProperties = new SortedProperties();
for (EnumConstantSource enumConst : source.getEnumConstants()) {
final JavaDocSource<EnumConstantSource> javaDoc = enumConst.getJavaDoc();
- final String javadocText = javaDoc.getText()
- .replaceAll("/", "/");
+ final String javadocText = javaDoc.getText().replaceAll("/", "/");
optionsProperties.setProperty(enumConst.getName(), javadocText);
}
optionsProperties.store(Files.newOutputStream(propsPath), null);
@@ -137,14 +143,12 @@ public class DocMojo extends AbstractMojo {
}
@Override
- public void store(Writer writer, String comments)
- throws IOException {
+ public void store(Writer writer, String comments) throws IOException {
super.store(new SkipFirstLineBufferedWriter(writer), null);
}
@Override
- public void store(OutputStream out, String comments)
- throws IOException {
+ public void store(OutputStream out, String comments) throws IOException {
this.store(new OutputStreamWriter(out, "8859_1"), comments);
}
@@ -177,8 +181,6 @@ public class DocMojo extends AbstractMojo {
super.write(cbuf, off, len);
}
}
-
}
-
}
}
diff --git a/client/pom.xml b/client/pom.xml
index abc00937..efc003a5 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2019 the original author or authors.
@@ -15,159 +16,156 @@
limitations under the License.
-->
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.maven.daemon</groupId>
- <artifactId>mvnd</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.maven.daemon</groupId>
+ <artifactId>mvnd</artifactId>
+ <version>0.9.0-SNAPSHOT</version>
+ </parent>
- <artifactId>mvnd-client</artifactId>
+ <artifactId>mvnd-client</artifactId>
- <packaging>jar</packaging>
- <name>Maven Daemon - Client</name>
+ <packaging>jar</packaging>
+ <name>Maven Daemon - Client</name>
- <properties>
- <maven.compiler.target>11</maven.compiler.target>
- <maven.compiler.source>11</maven.compiler.source>
- </properties>
+ <properties>
+ <maven.compiler.target>11</maven.compiler.target>
+ <maven.compiler.source>11</maven.compiler.source>
+ </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.daemon</groupId>
- <artifactId>mvnd-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-embedder</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- </dependency>
- <dependency>
- <groupId>org.graalvm.nativeimage</groupId>
- <artifactId>svm</artifactId>
- <scope>provided</scope>
- </dependency>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.daemon</groupId>
+ <artifactId>mvnd-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-embedder</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.graalvm.nativeimage</groupId>
+ <artifactId>svm</artifactId>
+ <scope>provided</scope>
+ </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
- <build>
- <resources>
- <resource>
- <directory>${basedir}/src/main/resources</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <executions>
- <execution>
- <id>enforce-bytecode-version</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <enforceBytecodeVersion>
- <excludes>
- <exclude>org.graalvm.nativeimage:svm</exclude>
- </excludes>
- </enforceBytecodeVersion>
- </rules>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>buildnumber-maven-plugin</artifactId>
- <configuration>
- <locale>en_US</locale>
- </configuration>
- <executions>
- <execution>
- <phase>validate</phase>
- <goals>
- <goal>create</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <compilerArgs>
- <arg>--add-exports=java.base/sun.nio.ch=ALL-UNNAMED</arg>
- <arg>--add-exports=java.base/jdk.internal.module=ALL-UNNAMED</arg>
- </compilerArgs>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemPropertyVariables>
- <project.basedir>${project.basedir}</project.basedir>
- </systemPropertyVariables>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <build>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>${basedir}/src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>enforce-bytecode-version</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <enforceBytecodeVersion>
+ <excludes>
+ <exclude>org.graalvm.nativeimage:svm</exclude>
+ </excludes>
+ </enforceBytecodeVersion>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>buildnumber-maven-plugin</artifactId>
+ <configuration>
+ <locale>en_US</locale>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ <phase>validate</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgs>
+ <arg>--add-exports=java.base/sun.nio.ch=ALL-UNNAMED</arg>
+ <arg>--add-exports=java.base/jdk.internal.module=ALL-UNNAMED</arg>
+ </compilerArgs>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <project.basedir>${project.basedir}</project.basedir>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
- <profiles>
- <profile>
- <id>native</id>
+ <profiles>
+ <profile>
+ <id>native</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.graalvm.buildtools</groupId>
- <artifactId>native-maven-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>build</goal>
- </goals>
- <phase>package</phase>
- </execution>
- </executions>
- <configuration>
- <skip>false</skip>
- <mainClass>org.mvndaemon.mvnd.client.DefaultClient</mainClass>
- <imageName>mvnd</imageName>
- <buildArgs>
- --no-server
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.graalvm.buildtools</groupId>
+ <artifactId>native-maven-plugin</artifactId>
+ <configuration>
+ <skip>false</skip>
+ <mainClass>org.mvndaemon.mvnd.client.DefaultClient</mainClass>
+ <imageName>mvnd</imageName>
+ <buildArgs>--no-server
--no-fallback
--allow-incomplete-classpath
-H:IncludeResources=org/mvndaemon/mvnd/.*
-H:IncludeResources=mvnd-bash-completion.bash
-H:-ParseRuntimeOptions
-H:+AddAllCharsets
- -ea
- </buildArgs>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
+ -ea</buildArgs>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ <phase>package</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
-</project>
\ No newline at end of file
+</project>
diff --git a/client/src/main/java/org/mvndaemon/mvnd/client/BuildProperties.java b/client/src/main/java/org/mvndaemon/mvnd/client/BuildProperties.java
index 8282b986..5c3aaa47 100644
--- a/client/src/main/java/org/mvndaemon/mvnd/client/BuildProperties.java
+++ b/client/src/main/java/org/mvndaemon/mvnd/client/BuildProperties.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2018 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.client;
diff --git a/client/src/main/java/org/mvndaemon/mvnd/client/Client.java b/client/src/main/java/org/mvndaemon/mvnd/client/Client.java
index 34b79b03..8f82b4e0 100644
--- a/client/src/main/java/org/mvndaemon/mvnd/client/Client.java
+++ b/client/src/main/java/org/mvndaemon/mvnd/client/Client.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.client;
@@ -26,5 +29,4 @@ public interface Client {
default ExecutionResult execute(ClientOutput output, String... args) throws InterruptedException {
return execute(output, Arrays.asList(args));
}
-
}
diff --git a/client/src/main/java/org/mvndaemon/mvnd/client/Completion.java b/client/src/main/java/org/mvndaemon/mvnd/client/Completion.java
index 765e5e46..f971f82a 100644
--- a/client/src/main/java/org/mvndaemon/mvnd/client/Completion.java
+++ b/client/src/main/java/org/mvndaemon/mvnd/client/Completion.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.client;
@@ -37,5 +40,4 @@ public class Completion {
throw new UncheckedIOException("Could not read " + bashCompletionPath, e);
}
}
-
}
diff --git a/client/src/main/java/org/mvndaemon/mvnd/client/DaemonClientConnection.java b/client/src/main/java/org/mvndaemon/mvnd/client/DaemonClientConnection.java
index 210fbbdc..24e5875e 100644
--- a/client/src/main/java/org/mvndaemon/mvnd/client/DaemonClientConnection.java
+++ b/client/src/main/java/org/mvndaemon/mvnd/client/DaemonClientConnection.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.client;
@@ -41,7 +44,7 @@ import org.slf4j.LoggerFactory;
*/
public class DaemonClientConnection implements Closeable {
- private final static Logger LOG = LoggerFactory.getLogger(DaemonClientConnection.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DaemonClientConnection.class);
private final DaemonConnection connection;
private final DaemonInfo daemon;
@@ -56,8 +59,12 @@ public class DaemonClientConnection implements Closeable {
private final long maxKeepAliveMs;
private final DaemonParameters parameters;
- public DaemonClientConnection(DaemonConnection connection, DaemonInfo daemon,
- StaleAddressDetector staleAddressDetector, boolean newDaemon, DaemonParameters parameters) {
+ public DaemonClientConnection(
+ DaemonConnection connection,
+ DaemonInfo daemon,
+ StaleAddressDetector staleAddressDetector,
+ boolean newDaemon,
+ DaemonParameters parameters) {
this.connection = connection;
this.daemon = daemon;
this.staleAddressDetector = staleAddressDetector;
@@ -126,7 +133,8 @@ public class DaemonClientConnection implements Closeable {
if (!hasReceived && newDaemon) {
throw new ConnectException("Could not receive a message from the daemon.\n" + diag.describe(), e);
} else if (staleAddressDetector.maybeStaleAddress(e)) {
- throw new StaleAddressException("Could not receive a message from the daemon.\n" + diag.describe(), e);
+ throw new StaleAddressException(
+ "Could not receive a message from the daemon.\n" + diag.describe(), e);
}
} finally {
hasReceived = true;
@@ -171,5 +179,4 @@ public class DaemonClientConnection implements Closeable {
*/
boolean maybeStaleAddress(Exception failure);
}
-
}
diff --git a/client/src/main/java/org/mvndaemon/mvnd/client/DaemonConnector.java b/client/src/main/java/org/mvndaemon/mvnd/client/DaemonConnector.java
index 83ef6742..70d3d933 100644
--- a/client/src/main/java/org/mvndaemon/mvnd/client/DaemonConnector.java
+++ b/client/src/main/java/org/mvndaemon/mvnd/client/DaemonConnector.java
@@ -1,20 +1,26 @@
/*
- * Copyright 2011-2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.client;
+import static java.lang.Thread.sleep;
+import static org.mvndaemon.mvnd.common.DaemonState.Canceled;
+
import java.io.File;
import java.io.IOException;
import java.net.SocketAddress;
@@ -53,9 +59,6 @@ import org.mvndaemon.mvnd.common.logging.ClientOutput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static java.lang.Thread.sleep;
-import static org.mvndaemon.mvnd.common.DaemonState.Canceled;
-
/**
* File origin:
* https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/client/DefaultDaemonConnector.java
@@ -94,11 +97,11 @@ public class DaemonConnector {
return connectNoDaemon();
}
- final DaemonCompatibilitySpec constraint = new DaemonCompatibilitySpec(
- parameters.javaHome(), parameters.getDaemonOpts());
+ final DaemonCompatibilitySpec constraint =
+ new DaemonCompatibilitySpec(parameters.javaHome(), parameters.getDaemonOpts());
output.accept(Message.buildStatus("Looking up daemon..."));
- Map<Boolean, List<DaemonInfo>> idleBusy = registry.getAll().stream()
- .collect(Collectors.groupingBy(di -> di.getState() == DaemonState.Idle));
+ Map<Boolean, List<DaemonInfo>> idleBusy =
+ registry.getAll().stream().collect(Collectors.groupingBy(di -> di.getState() == DaemonState.Idle));
final Collection<DaemonInfo> idleDaemons = idleBusy.getOrDefault(true, Collections.emptyList());
final Collection<DaemonInfo> busyDaemons = idleBusy.getOrDefault(false, Collections.emptyList());
@@ -128,20 +131,27 @@ public class DaemonConnector {
}
String daemon = ProcessHandle.current().pid() + "-" + System.currentTimeMillis();
Properties properties = new Properties();
- properties.put(Environment.JAVA_HOME.getProperty(), parameters.javaHome().toString());
+ properties.put(
+ Environment.JAVA_HOME.getProperty(), parameters.javaHome().toString());
properties.put(Environment.USER_DIR.getProperty(), parameters.userDir().toString());
- properties.put(Environment.USER_HOME.getProperty(), parameters.userHome().toString());
- properties.put(Environment.MVND_HOME.getProperty(), parameters.mvndHome().toString());
+ properties.put(
+ Environment.USER_HOME.getProperty(), parameters.userHome().toString());
+ properties.put(
+ Environment.MVND_HOME.getProperty(), parameters.mvndHome().toString());
properties.put(Environment.MVND_ID.getProperty(), daemon);
- properties.put(Environment.MVND_DAEMON_STORAGE.getProperty(), parameters.daemonStorage().toString());
- properties.put(Environment.MVND_REGISTRY.getProperty(), parameters.registry().toString());
+ properties.put(
+ Environment.MVND_DAEMON_STORAGE.getProperty(),
+ parameters.daemonStorage().toString());
+ properties.put(
+ Environment.MVND_REGISTRY.getProperty(), parameters.registry().toString());
properties.putAll(parameters.getDaemonOptsMap());
Environment.setProperties(properties);
AtomicReference<Throwable> throwable = new AtomicReference<>();
Thread serverThread = new Thread(() -> {
try {
Class<?> clazz = getClass().getClassLoader().loadClass("org.mvndaemon.mvnd.daemon.Server");
- try (AutoCloseable server = (AutoCloseable) clazz.getConstructor().newInstance()) {
+ try (AutoCloseable server =
+ (AutoCloseable) clazz.getConstructor().newInstance()) {
((Runnable) server).run();
}
} catch (Throwable t) {
@@ -164,34 +174,37 @@ public class DaemonConnector {
throw new RuntimeException("Unable to connect to internal daemon", throwable.get());
}
- private String handleStopEvents(String daemonId, Collection<DaemonInfo> idleDaemons, Collection<DaemonInfo> busyDaemons) {
+ private String handleStopEvents(
+ String daemonId, Collection<DaemonInfo> idleDaemons, Collection<DaemonInfo> busyDaemons) {
final List<DaemonStopEvent> stopEvents = registry.getStopEvents();
// Clean up old stop events
long time = System.currentTimeMillis() - TimeUnit.HOURS.toMillis(1);
- List<DaemonStopEvent> oldStopEvents = stopEvents.stream()
- .filter(e -> e.getTimestamp() < time)
- .collect(Collectors.toList());
+ List<DaemonStopEvent> oldStopEvents =
+ stopEvents.stream().filter(e -> e.getTimestamp() < time).collect(Collectors.toList());
registry.removeStopEvents(oldStopEvents);
final List<DaemonStopEvent> recentStopEvents = stopEvents.stream()
.filter(e -> e.getTimestamp() >= time)
- .collect(Collectors.groupingBy(DaemonStopEvent::getDaemonId,
- Collectors.minBy(this::compare)))
+ .collect(Collectors.groupingBy(DaemonStopEvent::getDaemonId, Collectors.minBy(this::compare)))
.values()
.stream()
.map(Optional::get)
.collect(Collectors.toList());
for (DaemonStopEvent stopEvent : recentStopEvents) {
- LOGGER.debug("Previous Daemon ({}) stopped at {} {}",
- stopEvent.getDaemonId(), stopEvent.getTimestamp(), stopEvent.getReason());
+ LOGGER.debug(
+ "Previous Daemon ({}) stopped at {} {}",
+ stopEvent.getDaemonId(),
+ stopEvent.getTimestamp(),
+ stopEvent.getReason());
}
return generate(daemonId, busyDaemons.size(), idleDaemons.size(), recentStopEvents.size());
}
- public static String generate(final String daemonId, final int numBusy, final int numIncompatible, final int numStopped) {
+ public static String generate(
+ final String daemonId, final int numBusy, final int numIncompatible, final int numStopped) {
final int totalUnavailableDaemons = numBusy + numIncompatible + numStopped;
if (totalUnavailableDaemons > 0) {
final List<String> reasons = new ArrayList<>();
@@ -223,21 +236,23 @@ public class DaemonConnector {
return 0;
}
- private DaemonClientConnection connectToIdleDaemon(Collection<DaemonInfo> idleDaemons, DaemonCompatibilitySpec constraint) {
+ private DaemonClientConnection connectToIdleDaemon(
+ Collection<DaemonInfo> idleDaemons, DaemonCompatibilitySpec constraint) {
final List<DaemonInfo> compatibleIdleDaemons = getCompatibleDaemons(idleDaemons, constraint);
LOGGER.debug("Found {} idle daemons, {} compatibles", idleDaemons.size(), compatibleIdleDaemons.size());
return findConnection(compatibleIdleDaemons);
}
- private DaemonClientConnection connectToCanceledDaemon(Collection<DaemonInfo> busyDaemons,
- DaemonCompatibilitySpec constraint) {
+ private DaemonClientConnection connectToCanceledDaemon(
+ Collection<DaemonInfo> busyDaemons, DaemonCompatibilitySpec constraint) {
DaemonClientConnection connection = null;
- List<DaemonInfo> canceledBusy = busyDaemons.stream()
- .filter(di -> di.getState() == Canceled)
- .collect(Collectors.toList());
- final List<DaemonInfo> compatibleCanceledDaemons = getCompatibleDaemons(
- canceledBusy, constraint);
- LOGGER.debug("Found {} busy daemons, {} cancelled, {} compatibles", busyDaemons.size(), canceledBusy.size(),
+ List<DaemonInfo> canceledBusy =
+ busyDaemons.stream().filter(di -> di.getState() == Canceled).collect(Collectors.toList());
+ final List<DaemonInfo> compatibleCanceledDaemons = getCompatibleDaemons(canceledBusy, constraint);
+ LOGGER.debug(
+ "Found {} busy daemons, {} cancelled, {} compatibles",
+ busyDaemons.size(),
+ canceledBusy.size(),
compatibleCanceledDaemons.size());
if (!compatibleCanceledDaemons.isEmpty()) {
LOGGER.debug("Waiting for daemons with canceled builds to become available");
@@ -261,8 +276,10 @@ public class DaemonConnector {
if (result.isCompatible()) {
compatibleDaemons.add(daemon);
} else {
- LOGGER.debug("{} daemon {} does not match the desired criteria: "
- + result.getWhy(), daemon.getState(), daemon.getId());
+ LOGGER.debug(
+ "{} daemon {} does not match the desired criteria: " + result.getWhy(),
+ daemon.getState(),
+ daemon.getId());
}
}
return compatibleDaemons;
@@ -295,7 +312,8 @@ public class DaemonConnector {
}
} while (process.isAlive() && System.currentTimeMillis() - start < DEFAULT_CONNECT_TIMEOUT);
DaemonDiagnostics diag = new DaemonDiagnostics(daemonId, parameters);
- throw new DaemonException.ConnectException("Timeout waiting to connect to the Maven daemon.\n" + diag.describe());
+ throw new DaemonException.ConnectException(
+ "Timeout waiting to connect to the Maven daemon.\n" + diag.describe());
}
static String newId() {
@@ -364,24 +382,33 @@ public class DaemonConnector {
args.add("-Dmaven.home=" + mvndHome.resolve("mvn"));
args.add("-Dmaven.conf=" + mvndHome.resolve("mvn/conf"));
- Environment.MVND_JAVA_HOME.addCommandLineOption(args, parameters.javaHome().toString());
- Environment.LOGBACK_CONFIGURATION_FILE
- .addCommandLineOption(args, parameters.logbackConfigurationPath().toString());
+ Environment.MVND_JAVA_HOME.addCommandLineOption(
+ args, parameters.javaHome().toString());
+ Environment.LOGBACK_CONFIGURATION_FILE.addCommandLineOption(
+ args, parameters.logbackConfigurationPath().toString());
Environment.MVND_ID.addCommandLineOption(args, daemonId);
- Environment.MVND_DAEMON_STORAGE.addCommandLineOption(args, parameters.daemonStorage().toString());
- Environment.MVND_REGISTRY.addCommandLineOption(args, parameters.registry().toString());
- Environment.MVND_SOCKET_FAMILY.addCommandLineOption(args,
- parameters.socketFamily().orElseGet(
- () -> getJavaVersion() >= 16.0f ? SocketFamily.unix : SocketFamily.inet)
+ Environment.MVND_DAEMON_STORAGE.addCommandLineOption(
+ args, parameters.daemonStorage().toString());
+ Environment.MVND_REGISTRY.addCommandLineOption(
+ args, parameters.registry().toString());
+ Environment.MVND_SOCKET_FAMILY.addCommandLineOption(
+ args,
+ parameters
+ .socketFamily()
+ .orElseGet(() -> getJavaVersion() >= 16.0f ? SocketFamily.unix : SocketFamily.inet)
.toString());
parameters.discriminatingCommandLineOptions(args);
args.add(MavenDaemon.class.getName());
command = String.join(" ", args);
- LOGGER.debug("Starting daemon process: id = {}, workingDir = {}, daemonArgs: {}", daemonId, workingDir, command);
- ProcessBuilder.Redirect redirect = ProcessBuilder.Redirect.appendTo(parameters.daemonOutLog(daemonId).toFile());
+ LOGGER.debug(
+ "Starting daemon process: id = {}, workingDir = {}, daemonArgs: {}", daemonId, workingDir, command);
+ ProcessBuilder.Redirect redirect = ProcessBuilder.Redirect.appendTo(
+ parameters.daemonOutLog(daemonId).toFile());
ProcessBuilder processBuilder = new ProcessBuilder();
- processBuilder.environment().put(Environment.JDK_JAVA_OPTIONS.getEnvironmentVariable(), parameters.jdkJavaOpts());
+ processBuilder
+ .environment()
+ .put(Environment.JDK_JAVA_OPTIONS.getEnvironmentVariable(), parameters.jdkJavaOpts());
Process process = processBuilder
.directory(workingDir.toFile())
.command(args)
@@ -391,7 +418,8 @@ public class DaemonConnector {
return process;
} catch (Exception e) {
throw new DaemonException.StartException(
- String.format("Error starting daemon: id = %s, workingDir = %s, daemonArgs: %s",
+ String.format(
+ "Error starting daemon: id = %s, workingDir = %s, daemonArgs: %s",
daemonId, workingDir, command),
e);
}
@@ -432,14 +460,15 @@ public class DaemonConnector {
return connectToDaemon(daemonInfo, new CleanupOnStaleAddress(daemonInfo), newDaemon);
} catch (DaemonException.ConnectException e) {
DaemonDiagnostics diag = new DaemonDiagnostics(daemon, parameters);
- throw new DaemonException.ConnectException("Could not connect to the Maven daemon.\n" + diag.describe(), e);
+ throw new DaemonException.ConnectException(
+ "Could not connect to the Maven daemon.\n" + diag.describe(), e);
}
}
return null;
}
- private DaemonClientConnection connectToDaemon(DaemonInfo daemon,
- DaemonClientConnection.StaleAddressDetector staleAddressDetector, boolean newDaemon)
+ private DaemonClientConnection connectToDaemon(
+ DaemonInfo daemon, DaemonClientConnection.StaleAddressDetector staleAddressDetector, boolean newDaemon)
throws DaemonException.ConnectException {
LOGGER.debug("Connecting to Daemon");
try {
@@ -462,10 +491,11 @@ public class DaemonConnector {
@Override
public boolean maybeStaleAddress(Exception failure) {
- LOGGER.debug("Removing daemon from the registry due to communication failure. Daemon information: {}", daemon);
+ LOGGER.debug(
+ "Removing daemon from the registry due to communication failure. Daemon information: {}", daemon);
final long timestamp = System.currentTimeMillis();
- final DaemonStopEvent stopEvent = new DaemonStopEvent(daemon.getId(), timestamp, null,
- "by user or operating system");
+ final DaemonStopEvent stopEvent =
+ new DaemonStopEvent(daemon.getId(), timestamp, null, "by user or operating system");
registry.storeStopEvent(stopEvent);
registry.remove(daemon.getId());
return true;
@@ -500,7 +530,8 @@ public class DaemonConnector {
// socket.connect(address, CONNECT_TIMEOUT);
// if (socket.getLocalSocketAddress().equals(socket.getRemoteSocketAddress())) {
// socketChannel.close();
- // throw new DaemonException.ConnectException(String.format("Socket connected to itself on %s.", address));
+ // throw new DaemonException.ConnectException(String.format("Socket connected to itself on
+ // %s.", address));
// }
LOGGER.debug("Connected to address {}.", socketChannel.getRemoteAddress());
@@ -517,5 +548,4 @@ public class DaemonConnector {
throw new DaemonException.ConnectException(String.format("Could not connect to server %s.", address), e);
}
}
-
}
diff --git a/client/src/main/java/org/mvndaemon/mvnd/client/DaemonDiagnostics.java b/client/src/main/java/org/mvndaemon/mvnd/client/DaemonDiagnostics.java
index 4c22c2c3..a2135e6a 100644
--- a/client/src/main/java/org/mvndaemon/mvnd/client/DaemonDiagnostics.java
+++ b/client/src/main/java/org/mvndaemon/mvnd/client/DaemonDiagnostics.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2009 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.client;
@@ -32,7 +35,7 @@ import java.util.stream.Collector;
*/
public class DaemonDiagnostics {
- private final static int TAIL_SIZE = 200;
+ private static final int TAIL_SIZE = 200;
private final String id;
private final DaemonParameters parameters;
@@ -44,10 +47,7 @@ public class DaemonDiagnostics {
@Override
public String toString() {
- return "{"
- + "id=" + id
- + ", parameters=" + parameters
- + '}';
+ return "{" + "id=" + id + ", parameters=" + parameters + '}';
}
public String describe() {
@@ -62,14 +62,21 @@ public class DaemonDiagnostics {
try {
String tail = tail(log);
sb.append(" ").append(name).append(": ").append(log).append("\n");
- sb.append("----- Last " + TAIL_SIZE + " lines from daemon ").append(name).append(" - ").append(log)
+ sb.append("----- Last " + TAIL_SIZE + " lines from daemon ")
+ .append(name)
+ .append(" - ")
+ .append(log)
.append(" -----\n");
sb.append(tail);
sb.append("----- End of the daemon ").append(name).append(" -----\n");
} catch (NoSuchFileException e) {
sb.append(" no ").append(name).append(" at: ").append(log).append("\n");
} catch (IOException e) {
- sb.append(" unable to read from the daemon ").append(name).append(": ").append(log).append(", because of: ")
+ sb.append(" unable to read from the daemon ")
+ .append(name)
+ .append(": ")
+ .append(log)
+ .append(", because of: ")
.append(e);
}
}
@@ -86,16 +93,18 @@ public class DaemonDiagnostics {
}
static <T> Collector<T, ?, List<T>> lastN(int n) {
- return Collector.<T, Deque<T>, List<T>> of(ArrayDeque::new, (acc, t) -> {
- if (acc.size() == n)
- acc.pollFirst();
- acc.add(t);
- }, (acc1, acc2) -> {
- while (acc2.size() < n && !acc1.isEmpty()) {
- acc2.addFirst(acc1.pollLast());
- }
- return acc2;
- }, ArrayList::new);
+ return Collector.<T, Deque<T>, List<T>>of(
+ ArrayDeque::new,
+ (acc, t) -> {
+ if (acc.size() == n) acc.pollFirst();
+ acc.add(t);
+ },
+ (acc1, acc2) -> {
+ while (acc2.size() < n && !acc1.isEmpty()) {
+ acc2.addFirst(acc1.pollLast());
+ }
+ return acc2;
+ },
+ ArrayList::new);
}
-
}
diff --git a/client/src/main/java/org/mvndaemon/mvnd/client/DaemonParameters.java b/client/src/main/java/org/mvndaemon/mvnd/client/DaemonParameters.java
index 102fb823..e0fc8b98 100644
--- a/client/src/main/java/org/mvndaemon/mvnd/client/DaemonParameters.java
+++ b/client/src/main/java/org/mvndaemon/mvnd/client/DaemonParameters.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.client;
@@ -63,8 +66,8 @@ public class DaemonParameters {
private static final String ENV_PREFIX = "env.";
protected final Map<Path, Properties> mvndProperties = new ConcurrentHashMap<>();
- protected final Function<Path, Properties> provider = path -> mvndProperties.computeIfAbsent(path,
- p -> loadProperties(path));
+ protected final Function<Path, Properties> provider =
+ path -> mvndProperties.computeIfAbsent(path, p -> loadProperties(path));
private final Map<String, String> properties;
public DaemonParameters() {
@@ -83,9 +86,7 @@ public class DaemonParameters {
public Map<String, String> getDaemonOptsMap() {
return discriminatingValues()
- .collect(Collectors.toMap(
- envValue -> envValue.envKey.getProperty(),
- EnvValue::asString));
+ .collect(Collectors.toMap(envValue -> envValue.envKey.getProperty(), EnvValue::asString));
}
Stream<EnvValue> discriminatingValues() {
@@ -96,8 +97,7 @@ public class DaemonParameters {
}
public void discriminatingCommandLineOptions(List<String> args) {
- discriminatingValues()
- .forEach(envValue -> envValue.envKey.addCommandLineOption(args, envValue.asString()));
+ discriminatingValues().forEach(envValue -> envValue.envKey.addCommandLineOption(args, envValue.asString()));
}
public Path mvndHome() {
@@ -112,7 +112,8 @@ public class DaemonParameters {
.orEnvironmentVariable()
.orFail()
.asPath()
- .toAbsolutePath().normalize();
+ .toAbsolutePath()
+ .normalize();
}
private String mvndHomeFromExecutable() {
@@ -120,8 +121,8 @@ public class DaemonParameters {
if (Environment.isNative() && cmd.isPresent()) {
final Path mvndH = Paths.get(cmd.get()).getParent().getParent();
if (mvndH != null) {
- final Path mvndDaemonLib = mvndH
- .resolve("mvn/lib/ext/mvnd-daemon-" + BuildProperties.getInstance().getVersion() + ".jar");
+ final Path mvndDaemonLib = mvndH.resolve("mvn/lib/ext/mvnd-daemon-"
+ + BuildProperties.getInstance().getVersion() + ".jar");
if (Files.exists(mvndDaemonLib)) {
return mvndH.toString();
}
@@ -138,9 +139,7 @@ public class DaemonParameters {
.orLocalProperty(provider, globalPropertiesPath())
.orSystemProperty()
.orEnvironmentVariable()
- .or(new ValueSource(
- description -> description.append("java command"),
- this::javaHomeFromPath))
+ .or(new ValueSource(description -> description.append("java command"), this::javaHomeFromPath))
.orFail()
.asPath();
try {
@@ -159,19 +158,11 @@ public class DaemonParameters {
}
public Path userDir() {
- return value(Environment.USER_DIR)
- .orSystemProperty()
- .orFail()
- .asPath()
- .toAbsolutePath();
+ return value(Environment.USER_DIR).orSystemProperty().orFail().asPath().toAbsolutePath();
}
public Path userHome() {
- return value(Environment.USER_HOME)
- .orSystemProperty()
- .orFail()
- .asPath()
- .toAbsolutePath();
+ return value(Environment.USER_HOME).orSystemProperty().orFail().asPath().toAbsolutePath();
}
public Path suppliedPropertiesPath() {
@@ -207,8 +198,10 @@ public class DaemonParameters {
.orSystemProperty()
.orLocalProperty(provider, globalPropertiesPath())
.orEnvironmentVariable()
- .orDefault(
- () -> userHome().resolve(".m2/mvnd/registry/" + BuildProperties.getInstance().getVersion()).toString())
+ .orDefault(() -> userHome()
+ .resolve(".m2/mvnd/registry/"
+ + BuildProperties.getInstance().getVersion())
+ .toString())
.asPath();
}
@@ -233,7 +226,8 @@ public class DaemonParameters {
.orSystemProperty()
.orDefault(() -> findDefaultMultimoduleProjectDirectory(projectDir))
.asPath()
- .toAbsolutePath().normalize();
+ .toAbsolutePath()
+ .normalize();
}
public Path logbackConfigurationPath() {
@@ -317,10 +311,7 @@ public class DaemonParameters {
* @return if mvnd should behave as maven
*/
public boolean serial() {
- return value(Environment.SERIAL)
- .orSystemProperty()
- .orDefault()
- .asBoolean();
+ return value(Environment.SERIAL).orSystemProperty().orDefault().asBoolean();
}
/**
@@ -333,14 +324,14 @@ public class DaemonParameters {
public DaemonParameters withJdkJavaOpts(String opts, boolean before) {
String org = this.properties.getOrDefault(Environment.JDK_JAVA_OPTIONS.getProperty(), "");
- return derive(b -> b.put(Environment.JDK_JAVA_OPTIONS,
- org.isEmpty() ? opts : before ? opts + " " + org : org + " " + opts));
+ return derive(b -> b.put(
+ Environment.JDK_JAVA_OPTIONS, org.isEmpty() ? opts : before ? opts + " " + org : org + " " + opts));
}
public DaemonParameters withJvmArgs(String opts, boolean before) {
String org = this.properties.getOrDefault(Environment.MVND_JVM_ARGS.getProperty(), "");
- return derive(b -> b.put(Environment.MVND_JVM_ARGS,
- org.isEmpty() ? opts : before ? opts + " " + org : org + " " + opts));
+ return derive(b ->
+ b.put(Environment.MVND_JVM_ARGS, org.isEmpty() ? opts : before ? opts + " " + org : org + " " + opts));
}
protected DaemonParameters derive(Consumer<PropertiesBuilder> customizer) {
@@ -400,9 +391,11 @@ public class DaemonParameters {
}
protected EnvValue value(Environment env) {
- return new EnvValue(env, new ValueSource(
- description -> description.append("value: ").append(env.getProperty()),
- () -> properties.get(env.getProperty())));
+ return new EnvValue(
+ env,
+ new ValueSource(
+ description -> description.append("value: ").append(env.getProperty()),
+ () -> properties.get(env.getProperty())));
}
public static EnvValue systemProperty(Environment env) {
@@ -519,7 +512,6 @@ public class DaemonParameters {
public String toString() {
return descriptionFunction.apply(new StringBuilder()).toString();
}
-
}
/**
@@ -548,7 +540,8 @@ public class DaemonParameters {
private static ValueSource systemPropertySource(Environment env) {
String property = env.getProperty();
if (property == null) {
- throw new IllegalStateException("Cannot use " + Environment.class.getName() + " for getting a system property");
+ throw new IllegalStateException(
+ "Cannot use " + Environment.class.getName() + " for getting a system property");
}
return new ValueSource(
description -> description.append("system property ").append(property),
@@ -558,9 +551,8 @@ public class DaemonParameters {
private static ValueSource environmentVariableSource(Environment env) {
String envVar = env.getEnvironmentVariable();
if (envVar == null) {
- throw new IllegalStateException(
- "Cannot use " + Environment.class.getName() + "." + env.name()
- + " for getting an environment variable");
+ throw new IllegalStateException("Cannot use " + Environment.class.getName() + "." + env.name()
+ + " for getting an environment variable");
}
return new ValueSource(
description -> description.append("environment variable ").append(envVar),
@@ -573,10 +565,16 @@ public class DaemonParameters {
public EnvValue orLocalProperty(Function<Path, Properties> provider, Path localPropertiesPath) {
if (localPropertiesPath != null) {
- return new EnvValue(this, envKey, new ValueSource(
- description -> description.append("property ").append(envKey.getProperty()).append(" in ")
- .append(localPropertiesPath),
- () -> provider.apply(localPropertiesPath).getProperty(envKey.getProperty())));
+ return new EnvValue(
+ this,
+ envKey,
+ new ValueSource(
+ description -> description
+ .append("property ")
+ .append(envKey.getProperty())
+ .append(" in ")
+ .append(localPropertiesPath),
+ () -> provider.apply(localPropertiesPath).getProperty(envKey.getProperty())));
} else {
return this;
}
@@ -595,7 +593,9 @@ public class DaemonParameters {
}
public EnvValue orDefault(Supplier<String> defaultSupplier) {
- return new EnvValue(this, envKey,
+ return new EnvValue(
+ this,
+ envKey,
new ValueSource(sb -> sb.append("default: ").append(defaultSupplier.get()), defaultSupplier));
}
@@ -609,7 +609,9 @@ public class DaemonParameters {
EnvValue val = this;
final StringBuilder sb = new StringBuilder("Could not get value for ")
.append(Environment.class.getSimpleName())
- .append(".").append(envKey.name()).append(" from any of the following sources: ");
+ .append(".")
+ .append(envKey.name())
+ .append(" from any of the following sources: ");
/*
* Compose the description functions to invert the order thus getting the resolution order in the
@@ -640,9 +642,7 @@ public class DaemonParameters {
.append(envKey.name())
.append("] from ");
valueSource.descriptionFunction.apply(sb);
- sb.append(": [")
- .append(result)
- .append(']');
+ sb.append(": [").append(result).append(']');
LOG.trace(sb.toString());
}
return result;
@@ -690,6 +690,5 @@ public class DaemonParameters {
throw couldNotgetValue();
}
}
-
}
}
diff --git a/client/src/main/java/org/mvndaemon/mvnd/client/DefaultClient.java b/client/src/main/java/org/mvndaemon/mvnd/client/DefaultClient.java
index 58f91db6..9c4774da 100644
--- a/client/src/main/java/org/mvndaemon/mvnd/client/DefaultClient.java
+++ b/client/src/main/java/org/mvndaemon/mvnd/client/DefaultClient.java
@@ -1,20 +1,25 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.client;
+import static org.mvndaemon.mvnd.client.DaemonParameters.LOG_EXTENSION;
+
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
@@ -56,8 +61,6 @@ import org.mvndaemon.mvnd.common.logging.TerminalOutput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.mvndaemon.mvnd.client.DaemonParameters.LOG_EXTENSION;
-
public class DefaultClient implements Client {
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultClient.class);
@@ -88,7 +91,8 @@ public class DefaultClient implements Client {
|| Environment.COMPLETION.hasCommandLineOption(args);
// Color
- Color styleColor = Color.of(Environment.MAVEN_COLOR.removeCommandLineOption(args)).orElse(Color.auto);
+ Color styleColor =
+ Color.of(Environment.MAVEN_COLOR.removeCommandLineOption(args)).orElse(Color.auto);
if (styleColor == Color.auto) {
/* Translate from auto to either always or never */
/* stdout is not a terminal e.g. when stdout is redirected to a file */
@@ -114,7 +118,8 @@ public class DefaultClient implements Client {
System.setProperty(Environment.MVND_NO_BUFERING.getProperty(), Boolean.toString(true));
}
- System.setProperty(Environment.MVND_HOME.getProperty(), parameters.mvndHome().toString());
+ System.setProperty(
+ Environment.MVND_HOME.getProperty(), parameters.mvndHome().toString());
Path dir;
if (Environment.MAVEN_FILE.hasCommandLineOption(args)) {
@@ -126,7 +131,8 @@ public class DefaultClient implements Client {
} else {
dir = parameters.userDir();
}
- System.setProperty(Environment.MAVEN_MULTIMODULE_PROJECT_DIRECTORY.getProperty(),
+ System.setProperty(
+ Environment.MAVEN_MULTIMODULE_PROJECT_DIRECTORY.getProperty(),
parameters.multiModuleProjectDirectory(dir).toString());
// .mvn/jvm.config
@@ -158,7 +164,8 @@ public class DefaultClient implements Client {
boolean defineIsEmpty = false;
while (iterator.hasNext()) {
final String arg = iterator.next();
- String val = Environment.MAVEN_DEFINE.removeCommandLineOption(new ArrayList<>(Collections.singletonList(arg)));
+ String val =
+ Environment.MAVEN_DEFINE.removeCommandLineOption(new ArrayList<>(Collections.singletonList(arg)));
/* not -D or --define and pre define is empty */
if (val == null && defineIsEmpty) {
defineIsEmpty = false;
@@ -187,8 +194,7 @@ public class DefaultClient implements Client {
private static boolean maybeDefineCommandLineOption(String arg) {
// if arg maybe MAVEN_DEFINE value
- return EnumSet.allOf(Environment.class)
- .stream()
+ return EnumSet.allOf(Environment.class).stream()
.filter(e -> e != Environment.MAVEN_DEFINE)
.noneMatch(e -> e.hasCommandLineOption(Collections.singletonList(arg)));
}
@@ -245,15 +251,19 @@ public class DefaultClient implements Client {
try (DaemonRegistry registry = new DaemonRegistry(parameters.registry())) {
if (Environment.STATUS.removeCommandLineOption(args) != null) {
final String template = "%8s %7s %24s %7s %5s %23s %s";
- output.accept(Message.out(String.format(template,
- "ID", "PID", "Address", "Status", "RSS", "Last activity", "Java home")));
+ output.accept(Message.out(String.format(
+ template, "ID", "PID", "Address", "Status", "RSS", "Last activity", "Java home")));
for (DaemonInfo d : registry.getAll()) {
if (ProcessHandle.of(d.getPid()).isEmpty()) {
/* The process does not exist anymore - remove it from the registry */
registry.remove(d.getId());
} else {
- output.accept(Message.out(String.format(template,
- d.getId(), d.getPid(), d.getAddress(), d.getState(),
+ output.accept(Message.out(String.format(
+ template,
+ d.getId(),
+ d.getPid(),
+ d.getAddress(),
+ d.getState(),
OsUtils.kbTohumanReadable(OsUtils.findProcessRssInKb(d.getPid())),
LocalDateTime.ofInstant(
Instant.ofEpochMilli(Math.max(d.getLastIdle(), d.getLastBusy())),
@@ -318,14 +328,16 @@ public class DefaultClient implements Client {
parameters.multiModuleProjectDirectory().toString(),
System.getenv()));
- output.accept(Message
- .buildStatus("Connected to daemon " + daemon.getDaemon().getId() + ", scanning for projects..."));
+ output.accept(Message.buildStatus(
+ "Connected to daemon " + daemon.getDaemon().getId() + ", scanning for projects..."));
// We've sent the request, so it gives us a bit of time to purge the logs
AtomicReference<String> purgeMessage = new AtomicReference<>();
- Thread purgeLog = new Thread(() -> {
- purgeMessage.set(purgeLogs());
- }, "Log purge");
+ Thread purgeLog = new Thread(
+ () -> {
+ purgeMessage.set(purgeLogs());
+ },
+ "Log purge");
purgeLog.setDaemon(true);
purgeLog.start();
@@ -335,16 +347,18 @@ public class DefaultClient implements Client {
output.accept(messages);
for (Message m : messages) {
switch (m.getType()) {
- case Message.CANCEL_BUILD:
- return new DefaultResult(argv,
- new InterruptedException("The build was canceled"), 130);
- case Message.BUILD_EXCEPTION:
- final BuildException e = (BuildException) m;
- return new DefaultResult(argv,
- new Exception(e.getClassName() + ": " + e.getMessage() + "\n" + e.getStackTrace()),
- 1);
- case Message.BUILD_FINISHED:
- return new DefaultResult(argv, null, ((BuildFinished) m).getExitCode());
+ case Message.CANCEL_BUILD:
+ return new DefaultResult(
+ argv, new InterruptedException("The build was canceled"), 130);
+ case Message.BUILD_EXCEPTION:
+ final BuildException e = (BuildException) m;
+ return new DefaultResult(
+ argv,
+ new Exception(e.getClassName() + ": " + e.getMessage() + "\n"
+ + e.getStackTrace()),
+ 1);
+ case Message.BUILD_FINISHED:
+ return new DefaultResult(argv, null, ((BuildFinished) m).getExitCode());
}
}
}
@@ -364,13 +378,16 @@ public class DefaultClient implements Client {
if (!Files.isDirectory(storage) || !TimeUtils.isPositive(purgeLogPeriod)) {
return null;
}
- String date = DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(Instant.now());
+ String date = DateTimeFormatter.ofPattern("yyyy-MM-dd")
+ .withZone(ZoneId.systemDefault())
+ .format(Instant.now());
Path log = storage.resolve("purge-" + date + ".log");
List<Path> deleted = new ArrayList<>();
List<Throwable> exceptions = new ArrayList<>();
FileTime limit = FileTime.from(Instant.now().minus(purgeLogPeriod));
try (Stream<Path> storagePath = Files.list(storage)) {
- storagePath.filter(p -> p.getFileName().toString().endsWith(LOG_EXTENSION))
+ storagePath
+ .filter(p -> p.getFileName().toString().endsWith(LOG_EXTENSION))
.filter(p -> !log.equals(p))
.filter(p -> {
try {
@@ -396,8 +413,8 @@ public class DefaultClient implements Client {
return null;
}
String logMessage;
- try (PrintWriter w = new PrintWriter(Files.newBufferedWriter(log,
- StandardOpenOption.WRITE, StandardOpenOption.APPEND, StandardOpenOption.CREATE))) {
+ try (PrintWriter w = new PrintWriter(Files.newBufferedWriter(
+ log, StandardOpenOption.WRITE, StandardOpenOption.APPEND, StandardOpenOption.CREATE))) {
w.printf("Purge executed at %s%n", Instant.now().toString());
if (deleted.isEmpty()) {
w.printf("No files deleted.%n");
@@ -423,7 +440,8 @@ public class DefaultClient implements Client {
if (exceptions.isEmpty()) {
return String.format("Purged %d log files (%s)", deleted.size(), logMessage);
} else {
- return String.format("Purged %d log files with %d exceptions (%s)", deleted.size(), exceptions.size(), logMessage);
+ return String.format(
+ "Purged %d log files with %d exceptions (%s)", deleted.size(), exceptions.size(), logMessage);
}
}
@@ -447,13 +465,17 @@ public class DefaultClient implements Client {
@Override
public ExecutionResult assertSuccess() {
if (exception != null) {
- throw new AssertionError(ExecutionResult.appendCommand(new StringBuilder("Build failed: "), args).toString(),
+ throw new AssertionError(
+ ExecutionResult.appendCommand(new StringBuilder("Build failed: "), args)
+ .toString(),
exception);
}
if (exitCode != 0) {
throw new AssertionError(
ExecutionResult.appendCommand(
- new StringBuilder("Build exited with non-zero exit code " + exitCode + ": "), args).toString(),
+ new StringBuilder("Build exited with non-zero exit code " + exitCode + ": "),
+ args)
+ .toString(),
exception);
}
return this;
@@ -462,7 +484,8 @@ public class DefaultClient implements Client {
@Override
public ExecutionResult assertFailure() {
if (exception == null && exitCode == 0) {
- throw new AssertionError(ExecutionResult.appendCommand(new StringBuilder("Build did not fail: "), args));
+ throw new AssertionError(
+ ExecutionResult.appendCommand(new StringBuilder("Build did not fail: "), args));
}
return this;
}
@@ -476,7 +499,5 @@ public class DefaultClient implements Client {
public boolean isSuccess() {
return exception == null;
}
-
}
-
}
diff --git a/client/src/main/java/org/mvndaemon/mvnd/client/ExecutionResult.java b/client/src/main/java/org/mvndaemon/mvnd/client/ExecutionResult.java
index 0c87f011..55106fd0 100644
--- a/client/src/main/java/org/mvndaemon/mvnd/client/ExecutionResult.java
+++ b/client/src/main/java/org/mvndaemon/mvnd/client/ExecutionResult.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.client;
@@ -37,5 +40,4 @@ public interface ExecutionResult {
}
return sb;
}
-
}
diff --git a/client/src/main/java/org/mvndaemon/mvnd/client/svm/ReflectionRegistration.java b/client/src/main/java/org/mvndaemon/mvnd/client/svm/ReflectionRegistration.java
index 97c1b577..3f46b716 100644
--- a/client/src/main/java/org/mvndaemon/mvnd/client/svm/ReflectionRegistration.java
+++ b/client/src/main/java/org/mvndaemon/mvnd/client/svm/ReflectionRegistration.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.client.svm;
diff --git a/client/src/main/java/org/mvndaemon/mvnd/client/svm/StaticMDCBinderSubstitution.java b/client/src/main/java/org/mvndaemon/mvnd/client/svm/StaticMDCBinderSubstitution.java
index 5a0fcd9f..e2371474 100644
--- a/client/src/main/java/org/mvndaemon/mvnd/client/svm/StaticMDCBinderSubstitution.java
+++ b/client/src/main/java/org/mvndaemon/mvnd/client/svm/StaticMDCBinderSubstitution.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.client.svm;
@@ -28,5 +31,4 @@ final class StaticMDCBinderSubstitution {
private static MDCAdapter bwCompatibleGetMDCAdapterFromBinder() throws NoClassDefFoundError {
return StaticMDCBinder.SINGLETON.getMDCA();
}
-
}
diff --git a/client/src/test/java/org/mvndaemon/mvnd/client/CompletionGeneratorTest.java b/client/src/test/java/org/mvndaemon/mvnd/client/CompletionGeneratorTest.java
index 03a9036b..1f5f4afb 100644
--- a/client/src/test/java/org/mvndaemon/mvnd/client/CompletionGeneratorTest.java
+++ b/client/src/test/java/org/mvndaemon/mvnd/client/CompletionGeneratorTest.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.client;
@@ -34,8 +37,8 @@ public class CompletionGeneratorTest {
@Test
void generate() throws IOException {
- String template = IoUtils.readResource(Completion.class.getClassLoader(),
- "completion-templates/mvnd-bash-completion.bash");
+ String template = IoUtils.readResource(
+ Completion.class.getClassLoader(), "completion-templates/mvnd-bash-completion.bash");
final String shortOpts = Stream.of(Environment.values())
.filter(env -> !env.isInternal())
@@ -71,7 +74,5 @@ public class CompletionGeneratorTest {
final byte[] bytes = template.getBytes(StandardCharsets.UTF_8);
Files.write(baseDir.resolve("../dist/src/main/distro/bin/mvnd-bash-completion.bash"), bytes);
-
}
-
}
diff --git a/client/src/test/java/org/mvndaemon/mvnd/client/DaemonConnectorTest.java b/client/src/test/java/org/mvndaemon/mvnd/client/DaemonConnectorTest.java
index 11eaf55d..2e28d084 100644
--- a/client/src/test/java/org/mvndaemon/mvnd/client/DaemonConnectorTest.java
+++ b/client/src/test/java/org/mvndaemon/mvnd/client/DaemonConnectorTest.java
@@ -1,25 +1,28 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.client;
-import org.junit.jupiter.api.Test;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import org.junit.jupiter.api.Test;
+
public class DaemonConnectorTest {
@Test
diff --git a/client/src/test/java/org/mvndaemon/mvnd/client/EnvironmentTest.java b/client/src/test/java/org/mvndaemon/mvnd/client/EnvironmentTest.java
index 5dca9740..0d14670d 100644
--- a/client/src/test/java/org/mvndaemon/mvnd/client/EnvironmentTest.java
+++ b/client/src/test/java/org/mvndaemon/mvnd/client/EnvironmentTest.java
@@ -1,20 +1,25 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.client;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
@@ -28,8 +33,6 @@ import org.mvndaemon.mvnd.client.DaemonParameters.EnvValue;
import org.mvndaemon.mvnd.client.DaemonParameters.ValueSource;
import org.mvndaemon.mvnd.common.Environment;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class EnvironmentTest {
@Test
@@ -57,7 +60,9 @@ public class EnvironmentTest {
void prop() {
try (EnvironmentResource env = new EnvironmentResource()) {
env.props("mvnd.home", "/maven/home/prop");
- assertEquals("/maven/home/prop", DaemonParameters.systemProperty(Environment.MVND_HOME).asString());
+ assertEquals(
+ "/maven/home/prop",
+ DaemonParameters.systemProperty(Environment.MVND_HOME).asString());
}
}
@@ -65,7 +70,9 @@ public class EnvironmentTest {
void env() {
try (EnvironmentResource env = new EnvironmentResource()) {
env.env("MVND_HOME", "/maven/home/env");
- assertEquals("/maven/home/env", DaemonParameters.environmentVariable(Environment.MVND_HOME).asString());
+ assertEquals(
+ "/maven/home/env",
+ DaemonParameters.environmentVariable(Environment.MVND_HOME).asString());
}
}
@@ -74,9 +81,9 @@ public class EnvironmentTest {
try (EnvironmentResource env = new EnvironmentResource()) {
final Properties localProps = new Properties();
localProps.put("mvnd.home", "/maven/home/local");
- assertEquals(Paths.get("/maven/home/local"),
- DaemonParameters
- .environmentVariable(Environment.MVND_HOME)
+ assertEquals(
+ Paths.get("/maven/home/local"),
+ DaemonParameters.environmentVariable(Environment.MVND_HOME)
.orSystemProperty()
.orLocalProperty(path -> localProps, Paths.get("/local/properties"))
.orFail()
@@ -89,9 +96,9 @@ public class EnvironmentTest {
try (EnvironmentResource env = new EnvironmentResource()) {
env.props("mvnd.home", "/maven/home/prop");
env.env("MVND_HOME", "/maven/home/env");
- assertEquals("/maven/home/env",
- DaemonParameters
- .environmentVariable(Environment.MVND_HOME)
+ assertEquals(
+ "/maven/home/env",
+ DaemonParameters.environmentVariable(Environment.MVND_HOME)
.orSystemProperty()
.asString());
}
@@ -101,9 +108,9 @@ public class EnvironmentTest {
void fail() {
try (EnvironmentResource env = new EnvironmentResource()) {
try {
- assertEquals("/maven/home/env",
- DaemonParameters
- .environmentVariable(Environment.MVND_HOME)
+ assertEquals(
+ "/maven/home/env",
+ DaemonParameters.environmentVariable(Environment.MVND_HOME)
.orSystemProperty()
.orFail()
.asString());
@@ -124,7 +131,8 @@ public class EnvironmentTest {
@Test
void emptyBooleanEnvValueIsTrue() {
final String EMPTY_STRING = "";
- final EnvValue envVal = new EnvValue(Environment.MVND_NO_BUFERING,
+ final EnvValue envVal = new EnvValue(
+ Environment.MVND_NO_BUFERING,
new ValueSource(sb -> sb.append("envValueAsBoolean"), () -> EMPTY_STRING));
assertEquals(true, envVal.asBoolean());
}
@@ -158,7 +166,5 @@ public class EnvironmentTest {
DaemonParameters.EnvValue.env = System.getenv();
Environment.setProperties(System.getProperties());
}
-
}
-
}
diff --git a/client/src/test/java/org/mvndaemon/mvnd/client/OsUtilsTest.java b/client/src/test/java/org/mvndaemon/mvnd/client/OsUtilsTest.java
index d32d630c..c2fdf6a4 100644
--- a/client/src/test/java/org/mvndaemon/mvnd/client/OsUtilsTest.java
+++ b/client/src/test/java/org/mvndaemon/mvnd/client/OsUtilsTest.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.client;
diff --git a/common/pom.xml b/common/pom.xml
index c103b140..9d040397 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2019 the original author or authors.
@@ -15,184 +16,183 @@
limitations under the License.
-->
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.maven.daemon</groupId>
- <artifactId>mvnd</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.maven.daemon</groupId>
+ <artifactId>mvnd</artifactId>
+ <version>0.9.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>mvnd-common</artifactId>
- <artifactId>mvnd-common</artifactId>
+ <packaging>jar</packaging>
+ <name>Maven Daemon - Common</name>
- <packaging>jar</packaging>
- <name>Maven Daemon - Common</name>
+ <dependencies>
- <dependencies>
+ <dependency>
+ <groupId>org.jline</groupId>
+ <artifactId>jline-terminal</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jline</groupId>
+ <artifactId>jline-terminal-jansi</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.jline</groupId>
- <artifactId>jline-terminal</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jline</groupId>
- <artifactId>jline-terminal-jansi</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.daemon</groupId>
+ <artifactId>mvnd-build-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>doc</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
- <build>
+ <profiles>
+ <profile>
+ <id>jdk11-15</id>
+ <activation>
+ <jdk>[11,15)</jdk>
+ </activation>
+ <build>
<plugins>
- <plugin>
- <groupId>org.apache.maven.daemon</groupId>
- <artifactId>mvnd-build-maven-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>doc</goal>
- </goals>
- <phase>generate-resources</phase>
- </execution>
- </executions>
- </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default</id>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+ <fork>true</fork>
+ <compilerArgs>
+ <arg>-XDignore.symbol.file</arg>
+ </compilerArgs>
+ </configuration>
+ </execution>
+ <execution>
+ <id>jdk11</id>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+ <fork>true</fork>
+ <compilerArgs>
+ <arg>-XDignore.symbol.file</arg>
+ </compilerArgs>
+ <release>11</release>
+ <multiReleaseOutput>true</multiReleaseOutput>
+ <compileSourceRoots>
+ <root>${project.basedir}/src/main/java11</root>
+ </compileSourceRoots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Multi-Release>true</Multi-Release>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
</plugins>
- </build>
-
- <profiles>
- <profile>
- <id>jdk11-15</id>
- <activation>
- <jdk>[11,15)</jdk>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <executions>
- <execution>
- <id>default</id>
- <goals>
- <goal>compile</goal>
- </goals>
- <configuration>
- <fork>true</fork>
- <compilerArgs>
- <arg>-XDignore.symbol.file</arg>
- </compilerArgs>
- </configuration>
- </execution>
- <execution>
- <id>jdk11</id>
- <goals>
- <goal>compile</goal>
- </goals>
- <configuration>
- <fork>true</fork>
- <compilerArgs>
- <arg>-XDignore.symbol.file</arg>
- </compilerArgs>
- <release>11</release>
- <multiReleaseOutput>true</multiReleaseOutput>
- <compileSourceRoots>
- <root>${project.basedir}/src/main/java11</root>
- </compileSourceRoots>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifestEntries>
- <Multi-Release>true</Multi-Release>
- </manifestEntries>
- </archive>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>jdk16+</id>
- <activation>
- <jdk>[16,)</jdk>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <executions>
- <execution>
- <id>default</id>
- <goals>
- <goal>compile</goal>
- </goals>
- <configuration>
- <fork>true</fork>
- <compilerArgs>
- <arg>-XDignore.symbol.file</arg>
- </compilerArgs>
- </configuration>
- </execution>
- <execution>
- <id>jdk11</id>
- <goals>
- <goal>compile</goal>
- </goals>
- <configuration>
- <fork>true</fork>
- <compilerArgs>
- <arg>-XDignore.symbol.file</arg>
- </compilerArgs>
- <release>11</release>
- <multiReleaseOutput>true</multiReleaseOutput>
- <compileSourceRoots>
- <root>${project.basedir}/src/main/java11</root>
- </compileSourceRoots>
- </configuration>
- </execution>
- <execution>
- <id>jdk16</id>
- <goals>
- <goal>compile</goal>
- </goals>
- <configuration>
- <fork>true</fork>
- <compilerArgs>
- <arg>-XDignore.symbol.file</arg>
- </compilerArgs>
- <release>16</release>
- <multiReleaseOutput>true</multiReleaseOutput>
- <compileSourceRoots>
- <root>${project.basedir}/src/main/java16</root>
- </compileSourceRoots>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
+ </build>
+ </profile>
+ <profile>
+ <id>jdk16+</id>
+ <activation>
+ <jdk>[16,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default</id>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+ <fork>true</fork>
+ <compilerArgs>
+ <arg>-XDignore.symbol.file</arg>
+ </compilerArgs>
+ </configuration>
+ </execution>
+ <execution>
+ <id>jdk11</id>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+ <fork>true</fork>
+ <compilerArgs>
+ <arg>-XDignore.symbol.file</arg>
+ </compilerArgs>
+ <release>11</release>
+ <multiReleaseOutput>true</multiReleaseOutput>
+ <compileSourceRoots>
+ <root>${project.basedir}/src/main/java11</root>
+ </compileSourceRoots>
+ </configuration>
+ </execution>
+ <execution>
+ <id>jdk16</id>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+ <fork>true</fork>
+ <compilerArgs>
+ <arg>-XDignore.symbol.file</arg>
+ </compilerArgs>
+ <release>16</release>
+ <multiReleaseOutput>true</multiReleaseOutput>
+ <compileSourceRoots>
+ <root>${project.basedir}/src/main/java16</root>
+ </compileSourceRoots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
-</project>
\ No newline at end of file
+</project>
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/BufferCaster.java b/common/src/main/java/org/mvndaemon/mvnd/common/BufferCaster.java
index e0bc9a67..38d2ff52 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/BufferCaster.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/BufferCaster.java
@@ -1,19 +1,21 @@
/*
- * Copyright 2018 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
import java.nio.Buffer;
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/BufferHelper.java b/common/src/main/java/org/mvndaemon/mvnd/common/BufferHelper.java
index 31f46357..ef5acac0 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/BufferHelper.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/BufferHelper.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
@@ -28,7 +31,8 @@ import java.util.function.Consumer;
*/
public class BufferHelper {
- private static boolean PRE_JAVA_9 = System.getProperty("java.specification.version", "9").startsWith("1.");
+ private static boolean PRE_JAVA_9 =
+ System.getProperty("java.specification.version", "9").startsWith("1.");
/** The DirectByteBuffer.cleaner() method. */
private static Method directByteBufferCleanerMethod;
@@ -74,7 +78,7 @@ public class BufferHelper {
// Ignore
}
} else {
- //boolean jdkSuccess = false;
+ // boolean jdkSuccess = false;
// // TODO: This feature is in incubation now -- enable after it leaves incubation.
// // To enable this feature, need to:
// // -- add whatever the "jdk.incubator.foreign" module name is replaced with to <Import-Package>
@@ -94,7 +98,7 @@ public class BufferHelper {
// } catch (ClassNotFoundException | NoSuchMethodException | SecurityException e1) {
// // Fall through
// }
- //if (!jdk14Success) { // In JDK9+, calling sun.misc.Cleaner.clean() gives a reflection warning on stderr,
+ // if (!jdk14Success) { // In JDK9+, calling sun.misc.Cleaner.clean() gives a reflection warning on stderr,
// so we need to call Unsafe.theUnsafe.invokeCleaner(byteBuffer) instead, which makes
// the same call, but does not print the reflection warning.
try {
@@ -117,7 +121,7 @@ public class BufferHelper {
} catch (final ReflectiveOperationException | LinkageError ex) {
// Ignore
}
- //}
+ // }
}
}
@@ -261,5 +265,4 @@ public class BufferHelper {
return false;
}
}
-
}
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/ByteChannelWrapper.java b/common/src/main/java/org/mvndaemon/mvnd/common/ByteChannelWrapper.java
index b2991513..f74fc3f0 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/ByteChannelWrapper.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/ByteChannelWrapper.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonCompatibilitySpec.java b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonCompatibilitySpec.java
index eae53bef..d18e45dd 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonCompatibilitySpec.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonCompatibilitySpec.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2011 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
@@ -68,8 +71,7 @@ public class DaemonCompatibilitySpec {
}
private boolean daemonOptsMatch(DaemonInfo daemon) {
- return daemon.getOptions().containsAll(options)
- && daemon.getOptions().size() == options.size();
+ return daemon.getOptions().containsAll(options) && daemon.getOptions().size() == options.size();
}
private boolean javaHomeMatches(DaemonInfo daemon) {
@@ -77,13 +79,14 @@ public class DaemonCompatibilitySpec {
}
StringBuilder appendFields(StringBuilder sb) {
- return sb.append("javaHome=").append(javaHome)
- .append(", options=").append(options);
+ return sb.append("javaHome=").append(javaHome).append(", options=").append(options);
}
@Override
public String toString() {
- return appendFields(new StringBuilder("DaemonCompatibilitySpec{")).append('}').toString();
+ return appendFields(new StringBuilder("DaemonCompatibilitySpec{"))
+ .append('}')
+ .toString();
}
public static class Result {
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonConnection.java b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonConnection.java
index 66f1d3b9..ba79896e 100755
--- a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonConnection.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonConnection.java
@@ -1,19 +1,21 @@
/*
- * Copyright 2016 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
import java.io.Closeable;
@@ -82,7 +84,8 @@ public class DaemonConnection implements AutoCloseable {
throw new DaemonException.RecoverableMessageIOException(
String.format("Could not read message from '%s'.", remoteAddress), e);
} catch (Throwable e) {
- throw new DaemonException.MessageIOException(String.format("Could not read message from '%s'.", remoteAddress), e);
+ throw new DaemonException.MessageIOException(
+ String.format("Could not read message from '%s'.", remoteAddress), e);
}
}
@@ -94,7 +97,8 @@ public class DaemonConnection implements AutoCloseable {
if (Objects.equals(e.getMessage(), "An existing connection was forcibly closed by the remote host")) {
return true;
}
- if (Objects.equals(e.getMessage(), "An established connection was aborted by the software in your host machine")) {
+ if (Objects.equals(
+ e.getMessage(), "An established connection was aborted by the software in your host machine")) {
return true;
}
if (Objects.equals(e.getMessage(), "Connection reset by peer")) {
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonException.java b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonException.java
index adf90e1f..c6177e25 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonException.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonException.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
@@ -84,5 +87,4 @@ public class DaemonException extends RuntimeException {
super(message, cause);
}
}
-
}
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonExpirationStatus.java b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonExpirationStatus.java
index e844074c..57b07d5a 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonExpirationStatus.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonExpirationStatus.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2016 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonInfo.java b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonInfo.java
index c0f69073..3d435a97 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonInfo.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonInfo.java
@@ -1,25 +1,28 @@
/*
- * Copyright 2011 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
-import java.util.List;
-
import static org.mvndaemon.mvnd.common.DaemonState.Busy;
import static org.mvndaemon.mvnd.common.DaemonState.Idle;
+import java.util.List;
+
/**
* File origin:
* https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/registry/DaemonInfo.java
@@ -40,10 +43,18 @@ public class DaemonInfo {
private final long lastIdle;
private final long lastBusy;
- public DaemonInfo(String id, String javaHome, String mavenHome,
- int pid, String address, byte[] token,
- String locale, List<String> options,
- DaemonState state, long lastIdle, long lastBusy) {
+ public DaemonInfo(
+ String id,
+ String javaHome,
+ String mavenHome,
+ int pid,
+ String address,
+ byte[] token,
+ String locale,
+ List<String> options,
+ DaemonState state,
+ long lastIdle,
+ long lastBusy) {
this.id = id;
this.javaHome = javaHome;
this.mvndHome = mavenHome;
@@ -113,8 +124,7 @@ public class DaemonInfo {
li = lastIdle;
lb = lastBusy;
}
- return new DaemonInfo(id, javaHome, mvndHome, pid, address,
- token, locale, options, state, li, lb);
+ return new DaemonInfo(id, javaHome, mvndHome, pid, address, token, locale, options, state, li, lb);
}
@Override
@@ -125,14 +135,23 @@ public class DaemonInfo {
}
public StringBuilder appendNonKeyFields(StringBuilder sb) {
- return sb.append("javaHome=").append(javaHome)
- .append(", options=").append(options)
- .append(", mavenHome=").append(mvndHome)
- .append(", pid=").append(pid)
- .append(", address=").append(address)
- .append(", locale=").append(locale)
- .append(", state=").append(state)
- .append(", lastIdle=").append(lastIdle)
- .append(", lastBusy=").append(lastBusy);
+ return sb.append("javaHome=")
+ .append(javaHome)
+ .append(", options=")
+ .append(options)
+ .append(", mavenHome=")
+ .append(mvndHome)
+ .append(", pid=")
+ .append(pid)
+ .append(", address=")
+ .append(address)
+ .append(", locale=")
+ .append(locale)
+ .append(", state=")
+ .append(state)
+ .append(", lastIdle=")
+ .append(lastIdle)
+ .append(", lastBusy=")
+ .append(lastBusy);
}
}
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonRegistry.java b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonRegistry.java
index c488f51c..449e3f1a 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonRegistry.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonRegistry.java
@@ -1,21 +1,26 @@
/*
- * Copyright 2011 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
+import static org.mvndaemon.mvnd.common.DaemonState.Canceled;
+import static org.mvndaemon.mvnd.common.DaemonState.Idle;
+
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.nio.BufferOverflowException;
@@ -40,9 +45,6 @@ import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.mvndaemon.mvnd.common.DaemonState.Canceled;
-import static org.mvndaemon.mvnd.common.DaemonState.Idle;
-
/**
* Access to daemon registry files. Useful also for testing.
*
@@ -76,8 +78,8 @@ public class DaemonRegistry implements AutoCloseable {
Files.createDirectories(absPath.getParent());
}
}
- channel = FileChannel.open(absPath,
- StandardOpenOption.CREATE, StandardOpenOption.READ, StandardOpenOption.WRITE);
+ channel = FileChannel.open(
+ absPath, StandardOpenOption.CREATE, StandardOpenOption.READ, StandardOpenOption.WRITE);
size = nextPowerOf2(channel.size(), MAX_LENGTH);
buffer = channel.map(FileChannel.MapMode.READ_WRITE, 0, size);
} catch (IOException e) {
@@ -117,15 +119,11 @@ public class DaemonRegistry implements AutoCloseable {
public List<DaemonInfo> getIdle() {
read();
- return infosMap.values().stream()
- .filter(di -> di.getState() == Idle)
- .collect(Collectors.toList());
+ return infosMap.values().stream().filter(di -> di.getState() == Idle).collect(Collectors.toList());
}
public List<DaemonInfo> getNotIdle() {
- return infosMap.values().stream()
- .filter(di -> di.getState() != Idle)
- .collect(Collectors.toList());
+ return infosMap.values().stream().filter(di -> di.getState() != Idle).collect(Collectors.toList());
}
public List<DaemonInfo> getCanceled() {
@@ -211,8 +209,9 @@ public class DaemonRegistry implements AutoCloseable {
DaemonState state = DaemonState.values()[buffer.get()];
long lastIdle = buffer.getLong();
long lastBusy = buffer.getLong();
- DaemonInfo di = new DaemonInfo(daemonId, javaHome, mavenHome, pid, address, token, locale,
- opts, state, lastIdle, lastBusy);
+ DaemonInfo di = new DaemonInfo(
+ daemonId, javaHome, mavenHome, pid, address, token, locale, opts, state, lastIdle,
+ lastBusy);
infosMap.putIfAbsent(di.getId(), di);
}
stopEvents.clear();
@@ -251,7 +250,10 @@ public class DaemonRegistry implements AutoCloseable {
for (DaemonStopEvent dse : stopEvents) {
writeString(dse.getDaemonId());
buffer.putLong(dse.getTimestamp());
- buffer.put((byte) (dse.getStatus() == null ? -1 : dse.getStatus().ordinal()));
+ buffer.put((byte)
+ (dse.getStatus() == null
+ ? -1
+ : dse.getStatus().ordinal()));
writeString(dse.getReason());
}
}
@@ -285,14 +287,16 @@ public class DaemonRegistry implements AutoCloseable {
throw new DaemonException("Could not resize registry " + registryFile, ex);
}
} catch (IOException e) {
- throw new DaemonException("Exception while "
- + (updater != null ? "updating " : "reading ") + registryFile, e);
+ throw new DaemonException(
+ "Exception while " + (updater != null ? "updating " : "reading ") + registryFile, e);
} catch (IllegalStateException | ArrayIndexOutOfBoundsException | BufferUnderflowException e) {
String absPath = registryFile.toAbsolutePath().normalize().toString();
- LOGGER.warn("Invalid daemon registry info, " +
- "trying to recover from this issue. " +
- "If you keep getting this warning, " +
- "try deleting the `registry.bin` file at [" + absPath + "]", e);
+ LOGGER.warn(
+ "Invalid daemon registry info, " + "trying to recover from this issue. "
+ + "If you keep getting this warning, "
+ + "try deleting the `registry.bin` file at ["
+ + absPath + "]",
+ e);
this.reset();
return;
}
@@ -347,7 +351,8 @@ public class DaemonRegistry implements AutoCloseable {
return Integer.parseInt(pid);
} catch (NumberFormatException x) {
int rpid = new Random().nextInt(1 << 16);
- LOGGER.warn("Unable to determine PID from malformed VM name `" + vmname + "`, picked a random number=" + rpid);
+ LOGGER.warn(
+ "Unable to determine PID from malformed VM name `" + vmname + "`, picked a random number=" + rpid);
return rpid;
}
}
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonState.java b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonState.java
index 808b4983..5c4158c0 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonState.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonState.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2012 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
@@ -20,7 +23,6 @@ package org.mvndaemon.mvnd.common;
* https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/server/api/DaemonStateControl.java
*/
public enum DaemonState {
-
Idle,
Busy,
Canceled,
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonStopEvent.java b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonStopEvent.java
index 45201308..e36e5d35 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/DaemonStopEvent.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/DaemonStopEvent.java
@@ -1,19 +1,21 @@
/*
- * Copyright 2016 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
import java.io.Serializable;
@@ -59,10 +61,8 @@ public class DaemonStopEvent implements Serializable {
@Override
public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
DaemonStopEvent that = (DaemonStopEvent) o;
return Objects.equals(daemonId, that.daemonId)
&& timestamp == that.timestamp
@@ -84,5 +84,4 @@ public class DaemonStopEvent implements Serializable {
+ ", reason=" + reason
+ "}";
}
-
}
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java b/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java
index c703059e..6181dc9c 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2020 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
@@ -214,7 +217,8 @@ public enum Environment {
* The <code>-Xss</code> value to pass to the daemon.
* This option takes precedence over options specified in {@link #MVND_JVM_ARGS}.
*/
- MVND_THREAD_STACK_SIZE("mvnd.threadStackSize", null, null, OptionType.MEMORY_SIZE, Flags.DISCRIMINATING | Flags.OPTIONAL),
+ MVND_THREAD_STACK_SIZE(
+ "mvnd.threadStackSize", null, null, OptionType.MEMORY_SIZE, Flags.DISCRIMINATING | Flags.OPTIONAL),
/**
* Additional JVM args to pass to the daemon.
* The content of the <code>.mvn/jvm.config</code> file will prepended (and thus with
@@ -230,13 +234,14 @@ public enum Environment {
/**
* The daemon will check this often whether it should exit.
*/
- MVND_EXPIRATION_CHECK_DELAY("mvnd.expirationCheckDelay", null, "10 seconds", OptionType.DURATION, Flags.DISCRIMINATING),
+ MVND_EXPIRATION_CHECK_DELAY(
+ "mvnd.expirationCheckDelay", null, "10 seconds", OptionType.DURATION, Flags.DISCRIMINATING),
/**
* Period after which idle duplicate daemons will be shut down. Duplicate daemons are daemons with the same set of
* discriminating start parameters.
*/
- MVND_DUPLICATE_DAEMON_GRACE_PERIOD("mvnd.duplicateDaemonGracePeriod", null, "10 seconds", OptionType.DURATION,
- Flags.DISCRIMINATING),
+ MVND_DUPLICATE_DAEMON_GRACE_PERIOD(
+ "mvnd.duplicateDaemonGracePeriod", null, "10 seconds", OptionType.DURATION, Flags.DISCRIMINATING),
/**
* Internal property to tell the daemon the width of the terminal
*/
@@ -289,7 +294,12 @@ public enum Environment {
private final OptionType type;
private final Map<String, OptionOrigin> options;
- Environment(String property, String environmentVariable, Object default_, OptionType type, int flags,
+ Environment(
+ String property,
+ String environmentVariable,
+ Object default_,
+ OptionType type,
+ int flags,
String... options) {
if (property == null && options.length == 0) {
throw new IllegalArgumentException(
@@ -305,7 +315,8 @@ public enum Environment {
} else {
final Map<String, OptionOrigin> optMap = new LinkedHashMap<>();
for (String opt : options) {
- OPTION_ORIGIN_SEARCH: {
+ OPTION_ORIGIN_SEARCH:
+ {
for (OptionOrigin oo : OptionOrigin.values()) {
if (opt.startsWith(oo.prefix)) {
optMap.put(opt.substring(oo.prefix.length()), oo);
@@ -314,7 +325,9 @@ public enum Environment {
}
throw new IllegalArgumentException(
"Unexpected option prefix: '" + opt + "'; Options should start with any of "
- + Stream.of(OptionOrigin.values()).map(oo -> oo.prefix).collect(Collectors.joining(",")));
+ + Stream.of(OptionOrigin.values())
+ .map(oo -> oo.prefix)
+ .collect(Collectors.joining(",")));
}
}
this.options = Collections.unmodifiableMap(optMap);
@@ -425,7 +438,7 @@ public enum Environment {
String getCommandLineOption(Collection<String> args, boolean remove) {
final String[] prefixes = getPrefixes();
String value = null;
- for (Iterator<String> it = args.iterator(); it.hasNext();) {
+ for (Iterator<String> it = args.iterator(); it.hasNext(); ) {
String arg = it.next();
if (Stream.of(prefixes).anyMatch(arg::startsWith)) {
if (remove) {
@@ -434,8 +447,10 @@ public enum Environment {
if (type == OptionType.VOID) {
value = "";
} else {
- String opt = Stream.of(prefixes).filter(arg::startsWith)
- .max(Comparator.comparing(String::length)).get();
+ String opt = Stream.of(prefixes)
+ .filter(arg::startsWith)
+ .max(Comparator.comparing(String::length))
+ .get();
value = arg.substring(opt.length());
if (value.isEmpty()) {
if (it.hasNext()) {
@@ -458,7 +473,7 @@ public enum Environment {
private String[] getPrefixes() {
final String[] prefixes;
if (options.isEmpty()) {
- prefixes = new String[] { "-D" + property + "=" };
+ prefixes = new String[] {"-D" + property + "="};
} else if (property != null) {
prefixes = new String[options.size() + 1];
options.keySet().toArray(prefixes);
@@ -493,13 +508,16 @@ public enum Environment {
}
return Stream.of(values)
.filter(env -> !env.isInternal())
- .sorted(Comparator.<Environment, String> comparing(env -> env.property != null ? env.property : "")
- .thenComparing(env -> !env.options.isEmpty() ? env.options.keySet().iterator().next() : ""))
+ .sorted(Comparator.<Environment, String>comparing(env -> env.property != null ? env.property : "")
+ .thenComparing(env -> !env.options.isEmpty()
+ ? env.options.keySet().iterator().next()
+ : ""))
.map(env -> new DocumentedEnumEntry<>(env, props.getProperty(env.name())));
}
public enum OptionOrigin {
- mvn, mvnd;
+ mvn,
+ mvnd;
private final String prefix;
@@ -512,7 +530,9 @@ public enum Environment {
* The values of {@link Environment#MAVEN_COLOR} option.
*/
public enum Color {
- always, never, auto;
+ always,
+ never,
+ auto;
public static Optional<Color> of(String color) {
return color == null ? Optional.empty() : Optional.of(Color.valueOf(color));
@@ -544,5 +564,4 @@ public enum Environment {
private static final int INTERNAL = 0b10;
private static final int OPTIONAL = 0b100;
}
-
}
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/InterpolationHelper.java b/common/src/main/java/org/mvndaemon/mvnd/common/InterpolationHelper.java
index 7e0a7e6b..138b0cbd 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/InterpolationHelper.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/InterpolationHelper.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.mvndaemon.mvnd.common;
@@ -30,8 +32,7 @@ import java.util.Properties;
*/
public class InterpolationHelper {
- private InterpolationHelper() {
- }
+ private InterpolationHelper() {}
private static final char ESCAPE_CHAR = '\\';
private static final String DELIM_START = "${";
@@ -45,7 +46,6 @@ public class InterpolationHelper {
public interface SubstitutionCallback {
String getValue(String key);
-
}
/**
@@ -57,7 +57,8 @@ public class InterpolationHelper {
* @param defaultsToEmptyString sets an empty string if a replacement value is not found, leaves intact
* otherwise
*/
- public static void performSubstitution(Properties properties,
+ public static void performSubstitution(
+ Properties properties,
SubstitutionCallback callback,
boolean substituteFromConfig,
boolean defaultsToEmptyString) {
@@ -65,9 +66,8 @@ public class InterpolationHelper {
properties.stringPropertyNames().forEach(n -> org.put(n, properties.getProperty(n)));
for (String name : properties.stringPropertyNames()) {
String value = properties.getProperty(name);
- properties.setProperty(name,
- substVars(value, name, null, org, callback, substituteFromConfig,
- defaultsToEmptyString));
+ properties.setProperty(
+ name, substVars(value, name, null, org, callback, substituteFromConfig, defaultsToEmptyString));
}
}
@@ -97,7 +97,8 @@ public class InterpolationHelper {
* @throws IllegalArgumentException If there was a syntax error in the
* property placeholder syntax or a recursive variable reference.
**/
- public static String substVars(String val,
+ public static String substVars(
+ String val,
String currentKey,
Map<String, String> cycleMap,
Map<String, String> configProps,
@@ -105,11 +106,12 @@ public class InterpolationHelper {
boolean substituteFromConfig,
boolean defaultsToEmptyString)
throws IllegalArgumentException {
- return unescape(doSubstVars(val, currentKey, cycleMap, configProps, callback, substituteFromConfig,
- defaultsToEmptyString));
+ return unescape(doSubstVars(
+ val, currentKey, cycleMap, configProps, callback, substituteFromConfig, defaultsToEmptyString));
}
- private static String doSubstVars(String val,
+ private static String doSubstVars(
+ String val,
String currentKey,
Map<String, String> cycleMap,
Map<String, String> configProps,
@@ -231,8 +233,8 @@ public class InterpolationHelper {
// Now perform substitution again, since there could still
// be substitutions to make.
- val = doSubstVars(val, currentKey, cycleMap, configProps, callback, substituteFromConfig,
- defaultsToEmptyString);
+ val = doSubstVars(
+ val, currentKey, cycleMap, configProps, callback, substituteFromConfig, defaultsToEmptyString);
cycleMap.remove(currentKey);
@@ -252,5 +254,4 @@ public class InterpolationHelper {
}
return val;
}
-
}
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/IoUtils.java b/common/src/main/java/org/mvndaemon/mvnd/common/IoUtils.java
index 0d7f0555..0779d239 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/IoUtils.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/IoUtils.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
@@ -26,10 +29,7 @@ public class IoUtils {
final StringBuilder result = new StringBuilder();
final int bufSize = 1024;
try (Reader in = new BufferedReader(
- new InputStreamReader(
- cl.getResourceAsStream(resourcePath),
- StandardCharsets.UTF_8),
- bufSize)) {
+ new InputStreamReader(cl.getResourceAsStream(resourcePath), StandardCharsets.UTF_8), bufSize)) {
int len = 0;
char[] buf = new char[bufSize];
while ((len = in.read(buf)) >= 0) {
@@ -39,6 +39,5 @@ public class IoUtils {
throw new RuntimeException("Could not read a class path resource: " + resourcePath, e);
}
return result.toString();
-
}
}
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/JavaVersion.java b/common/src/main/java/org/mvndaemon/mvnd/common/JavaVersion.java
index 1854d8b4..e6eb3d1c 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/JavaVersion.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/JavaVersion.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/MavenDaemon.java b/common/src/main/java/org/mvndaemon/mvnd/common/MavenDaemon.java
index d94779f1..cf4bb133 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/MavenDaemon.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/MavenDaemon.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
@@ -27,24 +30,23 @@ public class MavenDaemon {
public static void main(String[] args) throws Exception {
final Path mvndHome = Environment.MVND_HOME.asPath();
URL[] classpath = Stream.concat(
- /* jars */
- Stream.of("mvn/lib/ext", "mvn/lib", "mvn/boot")
- .map(mvndHome::resolve)
- .flatMap((Path p) -> {
- try {
- return Files.list(p);
- } catch (java.io.IOException e) {
- throw new RuntimeException("Could not list " + p, e);
- }
- })
- .filter(p -> {
- final String fileName = p.getFileName().toString();
- return fileName.endsWith(".jar") && !fileName.startsWith("mvnd-client-");
- })
- .filter(Files::isRegularFile),
- /* resources */
- Stream.of(mvndHome.resolve("mvn/conf"), mvndHome.resolve("mvn/conf/logging")))
-
+ /* jars */
+ Stream.of("mvn/lib/ext", "mvn/lib", "mvn/boot")
+ .map(mvndHome::resolve)
+ .flatMap((Path p) -> {
+ try {
+ return Files.list(p);
+ } catch (java.io.IOException e) {
+ throw new RuntimeException("Could not list " + p, e);
+ }
+ })
+ .filter(p -> {
+ final String fileName = p.getFileName().toString();
+ return fileName.endsWith(".jar") && !fileName.startsWith("mvnd-client-");
+ })
+ .filter(Files::isRegularFile),
+ /* resources */
+ Stream.of(mvndHome.resolve("mvn/conf"), mvndHome.resolve("mvn/conf/logging")))
.map(Path::normalize)
.map(Path::toUri)
.map(uri -> {
@@ -80,5 +82,4 @@ public class MavenDaemon {
((Runnable) server).run();
}
}
-
}
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/Message.java b/common/src/main/java/org/mvndaemon/mvnd/common/Message.java
index c1ffa7dd..e983b321 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/Message.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/Message.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
@@ -37,6 +40,7 @@ public abstract class Message {
public static final int PROJECT_STARTED = 4;
/** A {@link StringMessage} bearing the {@code artifactId} of the project whose build just finished */
public static final int PROJECT_STOPPED = 5;
+
public static final int MOJO_STARTED = 6;
public static final int PROJECT_LOG_MESSAGE = 7;
public static final int BUILD_LOG_MESSAGE = 8;
@@ -71,46 +75,46 @@ public abstract class Message {
return null;
}
switch (type) {
- case BUILD_REQUEST:
- return BuildRequest.read(input);
- case BUILD_STARTED:
- return BuildStarted.read(input);
- case BUILD_FINISHED:
- return BuildFinished.read(input);
- case MOJO_STARTED:
- return MojoStartedEvent.read(input);
- case PROJECT_LOG_MESSAGE:
- case DISPLAY:
- return ProjectEvent.read(type, input);
- case BUILD_EXCEPTION:
- return BuildException.read(input);
- case KEEP_ALIVE:
- return BareMessage.KEEP_ALIVE_SINGLETON;
- case STOP:
- return BareMessage.STOP_SINGLETON;
- case PROMPT:
- return Prompt.read(input);
- case PROMPT_RESPONSE:
- return PromptResponse.read(input);
- case PROJECT_STARTED:
- case PROJECT_STOPPED:
- case BUILD_STATUS:
- case BUILD_LOG_MESSAGE:
- return StringMessage.read(type, input);
- case CANCEL_BUILD:
- return BareMessage.CANCEL_BUILD_SINGLETON;
- case TRANSFER_INITIATED:
- case TRANSFER_STARTED:
- case TRANSFER_PROGRESSED:
- case TRANSFER_CORRUPTED:
- case TRANSFER_SUCCEEDED:
- case TRANSFER_FAILED:
- return TransferEvent.read(type, input);
- case EXECUTION_FAILURE:
- return ExecutionFailureEvent.read(input);
- case PRINT_OUT:
- case PRINT_ERR:
- return StringMessage.read(type, input);
+ case BUILD_REQUEST:
+ return BuildRequest.read(input);
+ case BUILD_STARTED:
+ return BuildStarted.read(input);
+ case BUILD_FINISHED:
+ return BuildFinished.read(input);
+ case MOJO_STARTED:
+ return MojoStartedEvent.read(input);
+ case PROJECT_LOG_MESSAGE:
+ case DISPLAY:
+ return ProjectEvent.read(type, input);
+ case BUILD_EXCEPTION:
+ return BuildException.read(input);
+ case KEEP_ALIVE:
+ return BareMessage.KEEP_ALIVE_SINGLETON;
+ case STOP:
+ return BareMessage.STOP_SINGLETON;
+ case PROMPT:
+ return Prompt.read(input);
+ case PROMPT_RESPONSE:
+ return PromptResponse.read(input);
+ case PROJECT_STARTED:
+ case PROJECT_STOPPED:
+ case BUILD_STATUS:
+ case BUILD_LOG_MESSAGE:
+ return StringMessage.read(type, input);
+ case CANCEL_BUILD:
+ return BareMessage.CANCEL_BUILD_SINGLETON;
+ case TRANSFER_INITIATED:
+ case TRANSFER_STARTED:
+ case TRANSFER_PROGRESSED:
+ case TRANSFER_CORRUPTED:
+ case TRANSFER_SUCCEEDED:
+ case TRANSFER_FAILED:
+ return TransferEvent.read(type, input);
+ case EXECUTION_FAILURE:
+ return ExecutionFailureEvent.read(input);
+ case PRINT_OUT:
+ case PRINT_ERR:
+ return StringMessage.read(type, input);
}
throw new IllegalStateException("Unexpected message type: " + type);
}
@@ -123,46 +127,46 @@ public abstract class Message {
public static int getClassOrder(Message m) {
switch (m.getType()) {
- case KEEP_ALIVE:
- case BUILD_REQUEST:
- return 0;
- case BUILD_STARTED:
- return 1;
- case PROMPT:
- case PROMPT_RESPONSE:
- case DISPLAY:
- case PRINT_OUT:
- case PRINT_ERR:
- return 2;
- case PROJECT_STARTED:
- return 3;
- case MOJO_STARTED:
- return 4;
- case EXECUTION_FAILURE:
- return 10;
- case TRANSFER_INITIATED:
- case TRANSFER_STARTED:
- return 40;
- case TRANSFER_PROGRESSED:
- return 41;
- case TRANSFER_CORRUPTED:
- case TRANSFER_SUCCEEDED:
- case TRANSFER_FAILED:
- return 42;
- case PROJECT_LOG_MESSAGE:
- return 50;
- case BUILD_LOG_MESSAGE:
- return 51;
- case PROJECT_STOPPED:
- return 95;
- case BUILD_FINISHED:
- return 96;
- case BUILD_EXCEPTION:
- return 97;
- case STOP:
- return 99;
- default:
- throw new IllegalStateException("Unexpected message type " + m.getType() + ": " + m);
+ case KEEP_ALIVE:
+ case BUILD_REQUEST:
+ return 0;
+ case BUILD_STARTED:
+ return 1;
+ case PROMPT:
+ case PROMPT_RESPONSE:
+ case DISPLAY:
+ case PRINT_OUT:
+ case PRINT_ERR:
+ return 2;
+ case PROJECT_STARTED:
+ return 3;
+ case MOJO_STARTED:
+ return 4;
+ case EXECUTION_FAILURE:
+ return 10;
+ case TRANSFER_INITIATED:
+ case TRANSFER_STARTED:
+ return 40;
+ case TRANSFER_PROGRESSED:
+ return 41;
+ case TRANSFER_CORRUPTED:
+ case TRANSFER_SUCCEEDED:
+ case TRANSFER_FAILED:
+ return 42;
+ case PROJECT_LOG_MESSAGE:
+ return 50;
+ case BUILD_LOG_MESSAGE:
+ return 51;
+ case PROJECT_STOPPED:
+ return 95;
+ case BUILD_FINISHED:
+ return 96;
+ case BUILD_EXCEPTION:
+ return 97;
+ case STOP:
+ return 99;
+ default:
+ throw new IllegalStateException("Unexpected message type " + m.getType() + ": " + m);
}
}
@@ -352,12 +356,11 @@ public abstract class Message {
@Override
public String toString() {
- return "BuildRequest{" +
- "args=" + args +
- ", workingDir='" + workingDir + '\'' +
- ", projectDir='" + projectDir + '\'' +
- ", env='" + env + '\'' +
- '}';
+ return "BuildRequest{" + "args="
+ + args + ", workingDir='"
+ + workingDir + '\'' + ", projectDir='"
+ + projectDir + '\'' + ", env='"
+ + env + '\'' + '}';
}
@Override
@@ -442,11 +445,10 @@ public abstract class Message {
@Override
public String toString() {
- return "BuildException{" +
- "message='" + message + '\'' +
- ", className='" + className + '\'' +
- ", stackTrace='" + stackTrace + '\'' +
- '}';
+ return "BuildException{" + "message='"
+ + message + '\'' + ", className='"
+ + className + '\'' + ", stackTrace='"
+ + stackTrace + '\'' + '}';
}
@Override
@@ -484,18 +486,15 @@ public abstract class Message {
@Override
public String toString() {
- return mnemonic() + "{" +
- "projectId='" + projectId + '\'' +
- ", message='" + message + '\'' +
- '}';
+ return mnemonic() + "{" + "projectId='" + projectId + '\'' + ", message='" + message + '\'' + '}';
}
private String mnemonic() {
switch (type) {
- case PROJECT_LOG_MESSAGE:
- return "ProjectLogMessage";
- default:
- throw new IllegalStateException("Unexpected type " + type);
+ case PROJECT_LOG_MESSAGE:
+ return "ProjectLogMessage";
+ default:
+ throw new IllegalStateException("Unexpected type " + type);
}
}
@@ -525,8 +524,13 @@ public abstract class Message {
return new MojoStartedEvent(artifactId, pluginGroupId, pluginArtifactId, pluginVersion, mojo, executionId);
}
- public MojoStartedEvent(String artifactId, String pluginGroupId, String pluginArtifactId,
- String pluginVersion, String mojo, String executionId) {
+ public MojoStartedEvent(
+ String artifactId,
+ String pluginGroupId,
+ String pluginArtifactId,
+ String pluginVersion,
+ String mojo,
+ String executionId) {
super(Message.MOJO_STARTED);
this.artifactId = Objects.requireNonNull(artifactId, "artifactId cannot be null");
this.pluginGroupId = Objects.requireNonNull(pluginGroupId, "pluginGroupId cannot be null");
@@ -562,14 +566,13 @@ public abstract class Message {
@Override
public String toString() {
- return "MojoStarted{" +
- "artifactId='" + artifactId + '\'' +
- ", pluginGroupId='" + pluginGroupId + '\'' +
- ", pluginArtifactId='" + pluginArtifactId + '\'' +
- ", pluginVersion='" + pluginVersion + '\'' +
- ", mojo='" + mojo + '\'' +
- ", executionId='" + executionId + '\'' +
- '}';
+ return "MojoStarted{" + "artifactId='"
+ + artifactId + '\'' + ", pluginGroupId='"
+ + pluginGroupId + '\'' + ", pluginArtifactId='"
+ + pluginArtifactId + '\'' + ", pluginVersion='"
+ + pluginVersion + '\'' + ", mojo='"
+ + mojo + '\'' + ", executionId='"
+ + executionId + '\'' + '}';
}
@Override
@@ -625,9 +628,9 @@ public abstract class Message {
@Override
public String toString() {
- return "BuildStarted{" +
- "projectId='" + projectId + "', projectCount=" + projectCount +
- ", maxThreads=" + maxThreads + ", artifactIdDisplayLength=" + artifactIdDisplayLength + "}";
+ return "BuildStarted{" + "projectId='"
+ + projectId + "', projectCount=" + projectCount + ", maxThreads="
+ + maxThreads + ", artifactIdDisplayLength=" + artifactIdDisplayLength + "}";
}
@Override
@@ -638,7 +641,6 @@ public abstract class Message {
output.writeInt(maxThreads);
output.writeInt(artifactIdDisplayLength);
}
-
}
public static class BareMessage extends Message {
@@ -654,19 +656,18 @@ public abstract class Message {
@Override
public String toString() {
switch (type) {
- case KEEP_ALIVE:
- return "KeepAlive";
- case BUILD_FINISHED:
- return "BuildStopped";
- case STOP:
- return "Stop";
- case CANCEL_BUILD:
- return "BuildCanceled";
- default:
- throw new IllegalStateException("Unexpected type " + type);
+ case KEEP_ALIVE:
+ return "KeepAlive";
+ case BUILD_FINISHED:
+ return "BuildStopped";
+ case STOP:
+ return "Stop";
+ case CANCEL_BUILD:
+ return "BuildCanceled";
+ default:
+ throw new IllegalStateException("Unexpected type " + type);
}
}
-
}
public static class StringMessage extends Message {
@@ -700,27 +701,26 @@ public abstract class Message {
private String mnemonic() {
switch (type) {
- case PROJECT_STARTED:
- return "ProjectStarted";
- case PROJECT_STOPPED:
- return "ProjectStopped";
- case BUILD_STATUS:
- return "BuildStatus";
- case KEYBOARD_INPUT:
- return "KeyboardInput";
- case BUILD_LOG_MESSAGE:
- return "BuildLogMessage";
- case DISPLAY:
- return "Display";
- case PRINT_OUT:
- return "PrintOut";
- case PRINT_ERR:
- return "PrintErr";
- default:
- throw new IllegalStateException("Unexpected type " + type);
+ case PROJECT_STARTED:
+ return "ProjectStarted";
+ case PROJECT_STOPPED:
+ return "ProjectStopped";
+ case BUILD_STATUS:
+ return "BuildStatus";
+ case KEYBOARD_INPUT:
+ return "KeyboardInput";
+ case BUILD_LOG_MESSAGE:
+ return "BuildLogMessage";
+ case DISPLAY:
+ return "Display";
+ case PRINT_OUT:
+ return "PrintOut";
+ case PRINT_ERR:
+ return "PrintErr";
+ default:
+ throw new IllegalStateException("Unexpected type " + type);
}
}
-
}
public static class Prompt extends Message {
@@ -764,12 +764,11 @@ public abstract class Message {
@Override
public String toString() {
- return "Prompt{" +
- "projectId='" + projectId + '\'' +
- ", uid='" + uid + '\'' +
- ", message='" + message + '\'' +
- ", password=" + password +
- '}';
+ return "Prompt{" + "projectId='"
+ + projectId + '\'' + ", uid='"
+ + uid + '\'' + ", message='"
+ + message + '\'' + ", password="
+ + password + '}';
}
@Override
@@ -784,7 +783,6 @@ public abstract class Message {
public PromptResponse response(String message) {
return new PromptResponse(projectId, uid, message);
}
-
}
public static class PromptResponse extends Message {
@@ -821,11 +819,10 @@ public abstract class Message {
@Override
public String toString() {
- return "PromptResponse{" +
- "projectId='" + projectId + '\'' +
- ", uid='" + uid + '\'' +
- ", message='" + message + '\'' +
- '}';
+ return "PromptResponse{" + "projectId='"
+ + projectId + '\'' + ", uid='"
+ + uid + '\'' + ", message='"
+ + message + '\'' + '}';
}
@Override
@@ -864,11 +861,10 @@ public abstract class Message {
@Override
public String toString() {
- return "ExecutionFailure{" +
- "projectId='" + projectId + '\'' +
- ", halted=" + halted +
- ", exception='" + exception + '\'' +
- '}';
+ return "ExecutionFailure{" + "projectId='"
+ + projectId + '\'' + ", halted="
+ + halted + ", exception='"
+ + exception + '\'' + '}';
}
@Override
@@ -909,9 +905,15 @@ public abstract class Message {
final long transferredBytes;
final String exception;
- private TransferEvent(int type, String projectId, int requestType,
- String repositoryId, String repositoryUrl,
- String resourceName, long contentLength, long transferredBytes,
+ private TransferEvent(
+ int type,
+ String projectId,
+ int requestType,
+ String repositoryId,
+ String repositoryUrl,
+ String resourceName,
+ long contentLength,
+ long transferredBytes,
String exception) {
super(type);
this.projectId = projectId;
@@ -958,34 +960,33 @@ public abstract class Message {
@Override
public String toString() {
- return mnemonic() + "{" +
- "projectId=" + projectId +
- ", requestType=" + requestType +
- ", repositoryId='" + repositoryId + '\'' +
- ", repositoryUrl='" + repositoryUrl + '\'' +
- ", resourceName='" + resourceName + '\'' +
- ", contentLength=" + contentLength +
- ", transferredBytes=" + transferredBytes +
- ", exception='" + exception + '\'' +
- '}';
+ return mnemonic() + "{" + "projectId="
+ + projectId + ", requestType="
+ + requestType + ", repositoryId='"
+ + repositoryId + '\'' + ", repositoryUrl='"
+ + repositoryUrl + '\'' + ", resourceName='"
+ + resourceName + '\'' + ", contentLength="
+ + contentLength + ", transferredBytes="
+ + transferredBytes + ", exception='"
+ + exception + '\'' + '}';
}
private String mnemonic() {
switch (type) {
- case TRANSFER_INITIATED:
- return "TransferInitiated";
- case TRANSFER_STARTED:
- return "TransferStarted";
- case TRANSFER_PROGRESSED:
- return "TransferProgressed";
- case TRANSFER_CORRUPTED:
- return "TransferCorrupted";
- case TRANSFER_SUCCEEDED:
- return "TransferSucceeded";
- case TRANSFER_FAILED:
- return "TransferFailed";
- default:
- throw new IllegalStateException("Unexpected type " + type);
+ case TRANSFER_INITIATED:
+ return "TransferInitiated";
+ case TRANSFER_STARTED:
+ return "TransferStarted";
+ case TRANSFER_PROGRESSED:
+ return "TransferProgressed";
+ case TRANSFER_CORRUPTED:
+ return "TransferCorrupted";
+ case TRANSFER_SUCCEEDED:
+ return "TransferSucceeded";
+ case TRANSFER_FAILED:
+ return "TransferFailed";
+ default:
+ throw new IllegalStateException("Unexpected type " + type);
}
}
@@ -1011,8 +1012,16 @@ public abstract class Message {
long contentLength = input.readLong();
long transferredBytes = input.readLong();
String exception = readUTF(input);
- return new TransferEvent(type, projectId, request, repositoryId, repositoryUrl, resourceName,
- contentLength, transferredBytes, exception);
+ return new TransferEvent(
+ type,
+ projectId,
+ request,
+ repositoryId,
+ repositoryUrl,
+ resourceName,
+ contentLength,
+ transferredBytes,
+ exception);
}
}
@@ -1060,8 +1069,13 @@ public abstract class Message {
return new ExecutionFailureEvent(projectId, halted, exception);
}
- public static Message mojoStarted(String artifactId, String pluginGroupId, String pluginArtifactId,
- String pluginVersion, String mojo, String executionId) {
+ public static Message mojoStarted(
+ String artifactId,
+ String pluginGroupId,
+ String pluginArtifactId,
+ String pluginVersion,
+ String mojo,
+ String executionId) {
return new MojoStartedEvent(artifactId, pluginGroupId, pluginArtifactId, pluginVersion, mojo, executionId);
}
@@ -1069,12 +1083,25 @@ public abstract class Message {
return new ProjectEvent(Message.DISPLAY, projectId, message);
}
- public static TransferEvent transfer(String projectId, int transferEventType, int requestType,
- String repositoryId, String repositoryUrl,
- String resourceName, long contentLength, long transferredBytes,
+ public static TransferEvent transfer(
+ String projectId,
+ int transferEventType,
+ int requestType,
+ String repositoryId,
+ String repositoryUrl,
+ String resourceName,
+ long contentLength,
+ long transferredBytes,
String exception) {
- return new TransferEvent(transferEventType, projectId, requestType,
- repositoryId, repositoryUrl, resourceName, contentLength, transferredBytes, exception);
+ return new TransferEvent(
+ transferEventType,
+ projectId,
+ requestType,
+ repositoryId,
+ repositoryUrl,
+ resourceName,
+ contentLength,
+ transferredBytes,
+ exception);
}
-
}
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/OptionType.java b/common/src/main/java/org/mvndaemon/mvnd/common/OptionType.java
index cbf49ec3..9f73fdec 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/OptionType.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/OptionType.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/Os.java b/common/src/main/java/org/mvndaemon/mvnd/common/Os.java
index 68701631..cef74ffa 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/Os.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/Os.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
@@ -22,6 +25,7 @@ public enum Os {
MAC(true),
WINDOWS(false) {
private boolean cygwin;
+
{
String pwd = System.getenv("PWD");
cygwin = pwd != null && pwd.startsWith("/");
@@ -38,10 +42,10 @@ public enum Os {
public boolean isUnixLike() {
throw new UnsupportedOperationException("Cannot tell isUnixLike() for an " + UNKNOWN.name() + " OS");
}
-
};
private static final Os CURRENT;
+
static {
final String osName = System.getProperty("os.name").toLowerCase(Locale.ROOT);
if (osName.startsWith("osx") || osName.startsWith("mac os x")) {
@@ -72,5 +76,4 @@ public enum Os {
public boolean isCygwin() {
return false;
}
-
}
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/OsUtils.java b/common/src/main/java/org/mvndaemon/mvnd/common/OsUtils.java
index fd4170e7..eb0569db 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/OsUtils.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/OsUtils.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
@@ -35,9 +38,7 @@ public class OsUtils {
private static final long KB = 1024;
private static final String UNITS = "Bkmgt";
- private OsUtils() {
-
- }
+ private OsUtils() {}
public static String bytesTohumanReadable(long bytes) {
int unit = 0;
@@ -46,7 +47,10 @@ public class OsUtils {
unit++;
}
String kbString = String.valueOf(bytes);
- return new StringBuilder(kbString.length() + 1).append(kbString).append(UNITS.charAt(unit)).toString();
+ return new StringBuilder(kbString.length() + 1)
+ .append(kbString)
+ .append(UNITS.charAt(unit))
+ .toString();
}
public static String kbTohumanReadable(long kb) {
@@ -56,22 +60,26 @@ public class OsUtils {
unit++;
}
String kbString = String.valueOf(kb);
- return new StringBuilder(kbString.length() + 1).append(kbString).append(UNITS.charAt(unit)).toString();
+ return new StringBuilder(kbString.length() + 1)
+ .append(kbString)
+ .append(UNITS.charAt(unit))
+ .toString();
}
public static long findProcessRssInKb(long pid) {
final Os os = Os.current();
if (os.isUnixLike()) {
- String[] cmd = { "ps", "-o", "rss=", "-p", String.valueOf(pid) };
+ String[] cmd = {"ps", "-o", "rss=", "-p", String.valueOf(pid)};
final List<String> output = new ArrayList<String>(1);
exec(cmd, output);
if (output.size() == 1) {
try {
return Long.parseLong(output.get(0).trim());
} catch (NumberFormatException e) {
- LOGGER.warn("Could not parse the output of " + Stream.of(cmd).collect(Collectors.joining(" "))
- + " as a long:\n"
- + output.stream().collect(Collectors.joining("\n")));
+ LOGGER.warn(
+ "Could not parse the output of " + Stream.of(cmd).collect(Collectors.joining(" "))
+ + " as a long:\n"
+ + output.stream().collect(Collectors.joining("\n")));
}
} else {
LOGGER.warn("Unexpected output of " + Stream.of(cmd).collect(Collectors.joining(" ")) + ":\n"
@@ -79,15 +87,17 @@ public class OsUtils {
}
return -1;
} else if (os == Os.WINDOWS) {
- String[] cmd = { "wmic", "process", "where", "processid=" + pid, "get", "WorkingSetSize" };
+ String[] cmd = {"wmic", "process", "where", "processid=" + pid, "get", "WorkingSetSize"};
final List<String> output = new ArrayList<String>(1);
exec(cmd, output);
- final List<String> nonEmptyLines = output.stream().filter(l -> !l.isEmpty()).collect(Collectors.toList());
+ final List<String> nonEmptyLines =
+ output.stream().filter(l -> !l.isEmpty()).collect(Collectors.toList());
if (nonEmptyLines.size() >= 2) {
try {
return Long.parseLong(nonEmptyLines.get(1).trim()) / KB;
} catch (NumberFormatException e) {
- LOGGER.warn("Could not parse the second line of " + Stream.of(cmd).collect(Collectors.joining(" "))
+ LOGGER.warn("Could not parse the second line of "
+ + Stream.of(cmd).collect(Collectors.joining(" "))
+ " output as a long:\n"
+ nonEmptyLines.stream().collect(Collectors.joining("\n")));
}
@@ -102,11 +112,11 @@ public class OsUtils {
}
public static String findJavaHomeFromPath() {
- String[] cmd = { "java", "-XshowSettings:properties", "-version" };
+ String[] cmd = {"java", "-XshowSettings:properties", "-version"};
final List<String> output = new ArrayList<String>(1);
exec(cmd, output);
- List<String> javaHomeLines = output.stream().filter(l -> l.contains(" java.home = "))
- .collect(Collectors.toList());
+ List<String> javaHomeLines =
+ output.stream().filter(l -> l.contains(" java.home = ")).collect(Collectors.toList());
if (javaHomeLines.size() == 1) {
return javaHomeLines.get(0).trim().replaceFirst("java.home = ", "");
}
@@ -210,6 +220,5 @@ public class OsUtils {
final int exitCode = timeouted ? TIMEOUT_EXIT_CODE : process.exitValue();
return exitCode;
}
-
}
}
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/ProcessHelper.java b/common/src/main/java/org/mvndaemon/mvnd/common/ProcessHelper.java
index 17acbdb8..97bbd7fa 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/ProcessHelper.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/ProcessHelper.java
@@ -1,23 +1,24 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
public class ProcessHelper {
- public static void killChildrenProcesses() {
- }
-
+ public static void killChildrenProcesses() {}
}
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/SocketFamily.java b/common/src/main/java/org/mvndaemon/mvnd/common/SocketFamily.java
index 1a8cb9ec..243244da 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/SocketFamily.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/SocketFamily.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
@@ -32,23 +35,23 @@ public enum SocketFamily {
public SocketChannel openSocket() throws IOException {
switch (this) {
- case inet:
- return SocketChannel.open();
- case unix:
- return SocketHelper.openUnixSocket();
- default:
- throw new IllegalStateException();
+ case inet:
+ return SocketChannel.open();
+ case unix:
+ return SocketHelper.openUnixSocket();
+ default:
+ throw new IllegalStateException();
}
}
public ServerSocketChannel openServerSocket() throws IOException {
switch (this) {
- case inet:
- return ServerSocketChannel.open().bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0);
- case unix:
- return SocketHelper.openUnixServerSocket();
- default:
- throw new IllegalStateException();
+ case inet:
+ return ServerSocketChannel.open().bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0);
+ case unix:
+ return SocketHelper.openUnixServerSocket();
+ default:
+ throw new IllegalStateException();
}
}
@@ -105,26 +108,26 @@ public enum SocketFamily {
public static String toString(SocketAddress address) {
switch (familyOf(address)) {
- case inet:
- InetSocketAddress isa = (InetSocketAddress) address;
- String host = isa.getHostString();
- InetAddress addr = isa.getAddress();
- int port = isa.getPort();
- String formatted;
- if (addr == null) {
- formatted = host + "/<unresolved>";
- } else {
- formatted = addr.toString();
- if (addr instanceof Inet6Address) {
- int i = formatted.lastIndexOf("/");
- formatted = formatted.substring(0, i + 1) + "[" + formatted.substring(i + 1) + "]";
+ case inet:
+ InetSocketAddress isa = (InetSocketAddress) address;
+ String host = isa.getHostString();
+ InetAddress addr = isa.getAddress();
+ int port = isa.getPort();
+ String formatted;
+ if (addr == null) {
+ formatted = host + "/<unresolved>";
+ } else {
+ formatted = addr.toString();
+ if (addr instanceof Inet6Address) {
+ int i = formatted.lastIndexOf("/");
+ formatted = formatted.substring(0, i + 1) + "[" + formatted.substring(i + 1) + "]";
+ }
}
- }
- return "inet:" + formatted + ":" + port;
- case unix:
- return "unix:" + address;
- default:
- throw new IllegalArgumentException("Unsupported socket address: '" + address + "'");
+ return "inet:" + formatted + ":" + port;
+ case unix:
+ return "unix:" + address;
+ default:
+ throw new IllegalArgumentException("Unsupported socket address: '" + address + "'");
}
}
@@ -137,5 +140,4 @@ public enum SocketFamily {
throw new IllegalArgumentException("Unsupported socket address '" + address + "'");
}
}
-
}
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/SocketHelper.java b/common/src/main/java/org/mvndaemon/mvnd/common/SocketHelper.java
index 765777bc..96b1dbbc 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/SocketHelper.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/SocketHelper.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/TimeUtils.java b/common/src/main/java/org/mvndaemon/mvnd/common/TimeUtils.java
index d5abefd0..8d676aea 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/TimeUtils.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/TimeUtils.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2020 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
@@ -32,19 +35,17 @@ public final class TimeUtils {
public static final long SECONDS_MILLIS = TimeUnit.SECONDS.toMillis(ONE_UNIT);
private static final Pattern DURATION_PATTERN = Pattern.compile(
- "(?<n>-?\\d+)" +
- "|" +
- "(" +
- "((?<d>\\d+)\\s*d(ay(s)?)?)?" + "\\s*" +
- "((?<h>\\d+)\\s*h(our(s)?)?)?" + "\\s*" +
- "((?<m>\\d+)\\s*m(in(ute(s)?)?)?)?" + "\\s*" +
- "((?<s>\\d+(\\.\\d+)?)\\s*s(ec(ond(s)?)?)?)?" + "\\s*" +
- "((?<l>\\d+(\\.\\d+)?)\\s*m(illi)?s(ec(ond)?(s)?)?)?" +
- ")",
+ "(?<n>-?\\d+)" + "|"
+ + "("
+ + "((?<d>\\d+)\\s*d(ay(s)?)?)?"
+ + "\\s*" + "((?<h>\\d+)\\s*h(our(s)?)?)?"
+ + "\\s*" + "((?<m>\\d+)\\s*m(in(ute(s)?)?)?)?"
+ + "\\s*" + "((?<s>\\d+(\\.\\d+)?)\\s*s(ec(ond(s)?)?)?)?"
+ + "\\s*" + "((?<l>\\d+(\\.\\d+)?)\\s*m(illi)?s(ec(ond)?(s)?)?)?"
+ + ")",
Pattern.CASE_INSENSITIVE);
- private TimeUtils() {
- }
+ private TimeUtils() {}
public static boolean isPositive(Duration dur) {
return dur.getSeconds() > 0 || dur.getNano() != 0;
@@ -117,5 +118,4 @@ public final class TimeUtils {
+ (l != null ? TimeUnit.MILLISECONDS.toMillis(Long.parseLong(l)) : 0);
}
}
-
}
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/logging/ClientOutput.java b/common/src/main/java/org/mvndaemon/mvnd/common/logging/ClientOutput.java
index 9d55552a..0d1425a4 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/logging/ClientOutput.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/logging/ClientOutput.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common.logging;
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/logging/TerminalOutput.java b/common/src/main/java/org/mvndaemon/mvnd/common/logging/TerminalOutput.java
index e5feec21..d5393cb7 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/logging/TerminalOutput.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/logging/TerminalOutput.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2020 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common.logging;
@@ -122,10 +125,12 @@ public class TerminalOutput implements ClientOutput {
private int totalProjects;
/** String format for formatting the number of projects done with padding based on {@link #totalProjects} */
private String projectsDoneFomat;
+
private int maxThreads;
private String artifactIdFormat;
/** String format for formatting the actual/hidden/max thread counts */
private String threadsFormat;
+
private int linesPerProject = 0;
private int doneProjects = 0;
private String buildStatus;
@@ -164,8 +169,8 @@ public class TerminalOutput implements ClientOutput {
mainThread.interrupt();
}
};
- this.previousIntHandler = terminal.handle(Terminal.Signal.INT,
- sig -> daemonDispatch.accept(Message.BareMessage.CANCEL_BUILD_SINGLETON));
+ this.previousIntHandler = terminal.handle(
+ Terminal.Signal.INT, sig -> daemonDispatch.accept(Message.BareMessage.CANCEL_BUILD_SINGLETON));
this.display = new Display(terminal, false);
this.log = logFile == null ? new MessageCollector() : new FileLog(logFile);
if (!dumb) {
@@ -214,228 +219,230 @@ public class TerminalOutput implements ClientOutput {
private boolean doAccept(Message entry) {
switch (entry.getType()) {
- case Message.BUILD_STARTED: {
- BuildStarted bs = (BuildStarted) entry;
- this.name = bs.getProjectId();
- this.totalProjects = bs.getProjectCount();
- final int totalProjectsDigits = (int) (Math.log10(totalProjects) + 1);
- this.projectsDoneFomat = "%" + totalProjectsDigits + "d";
- this.maxThreads = bs.getMaxThreads();
- this.artifactIdFormat = "%-" + bs.getArtifactIdDisplayLength() + "s ";
- final int maxThreadsDigits = (int) (Math.log10(maxThreads) + 1);
- this.threadsFormat = "%" + (maxThreadsDigits * 3 + 2) + "s";
- if (maxThreads <= 1 || totalProjects <= 1) {
- this.noBuffering = true;
- display.update(Collections.emptyList(), 0);
- applyNoBuffering();
- }
- break;
- }
- case Message.CANCEL_BUILD: {
- projects.values().stream().flatMap(p -> p.log.stream()).forEach(log);
- clearDisplay();
- try {
- log.close();
- } catch (IOException e1) {
- throw new RuntimeException(e1);
- }
- final AttributedStyle s = new AttributedStyle().bold().foreground(AttributedStyle.RED);
- new AttributedString("The build was canceled", s).println(terminal);
- terminal.flush();
- return false;
- }
- case Message.BUILD_EXCEPTION: {
- final BuildException e = (BuildException) entry;
- final String msg;
- if ("org.apache.commons.cli.UnrecognizedOptionException".equals(e.getClassName())) {
- msg = "Unable to parse command line options: " + e.getMessage();
- } else {
- msg = e.getClassName() + ": " + e.getMessage();
+ case Message.BUILD_STARTED: {
+ BuildStarted bs = (BuildStarted) entry;
+ this.name = bs.getProjectId();
+ this.totalProjects = bs.getProjectCount();
+ final int totalProjectsDigits = (int) (Math.log10(totalProjects) + 1);
+ this.projectsDoneFomat = "%" + totalProjectsDigits + "d";
+ this.maxThreads = bs.getMaxThreads();
+ this.artifactIdFormat = "%-" + bs.getArtifactIdDisplayLength() + "s ";
+ final int maxThreadsDigits = (int) (Math.log10(maxThreads) + 1);
+ this.threadsFormat = "%" + (maxThreadsDigits * 3 + 2) + "s";
+ if (maxThreads <= 1 || totalProjects <= 1) {
+ this.noBuffering = true;
+ display.update(Collections.emptyList(), 0);
+ applyNoBuffering();
+ }
+ break;
}
- projects.values().stream().flatMap(p -> p.log.stream()).forEach(log);
- clearDisplay();
- try {
- log.close();
- } catch (IOException e1) {
- throw new RuntimeException(e1);
+ case Message.CANCEL_BUILD: {
+ projects.values().stream().flatMap(p -> p.log.stream()).forEach(log);
+ clearDisplay();
+ try {
+ log.close();
+ } catch (IOException e1) {
+ throw new RuntimeException(e1);
+ }
+ final AttributedStyle s = new AttributedStyle().bold().foreground(AttributedStyle.RED);
+ new AttributedString("The build was canceled", s).println(terminal);
+ terminal.flush();
+ return false;
}
- final AttributedStyle s = new AttributedStyle().bold().foreground(AttributedStyle.RED);
- new AttributedString(msg, s).println(terminal);
- terminal.flush();
- return false;
- }
- case Message.PROJECT_STARTED: {
- StringMessage be = (StringMessage) entry;
- final String artifactId = be.getMessage();
- projects.put(artifactId, new Project(artifactId));
- break;
- }
- case Message.MOJO_STARTED: {
- final MojoStartedEvent execution = (MojoStartedEvent) entry;
- final Project prj = projects.computeIfAbsent(execution.getArtifactId(), Project::new);
- prj.runningExecution = execution;
- break;
- }
- case Message.PROJECT_STOPPED: {
- StringMessage be = (StringMessage) entry;
- final String artifactId = be.getMessage();
- Project prj = projects.remove(artifactId);
- if (prj != null) {
- prj.log.forEach(log);
- }
- doneProjects++;
- displayDone();
- break;
- }
- case Message.BUILD_STATUS: {
- this.buildStatus = ((StringMessage) entry).getMessage();
- break;
- }
- case Message.BUILD_FINISHED: {
- projects.values().stream().flatMap(p -> p.log.stream()).forEach(log);
- clearDisplay();
- try {
- log.close();
- } catch (IOException e) {
- throw new RuntimeException(e);
- } finally {
+ case Message.BUILD_EXCEPTION: {
+ final BuildException e = (BuildException) entry;
+ final String msg;
+ if ("org.apache.commons.cli.UnrecognizedOptionException".equals(e.getClassName())) {
+ msg = "Unable to parse command line options: " + e.getMessage();
+ } else {
+ msg = e.getClassName() + ": " + e.getMessage();
+ }
+ projects.values().stream().flatMap(p -> p.log.stream()).forEach(log);
+ clearDisplay();
+ try {
+ log.close();
+ } catch (IOException e1) {
+ throw new RuntimeException(e1);
+ }
+ final AttributedStyle s = new AttributedStyle().bold().foreground(AttributedStyle.RED);
+ new AttributedString(msg, s).println(terminal);
terminal.flush();
+ return false;
}
- return false;
- }
- case Message.KEEP_ALIVE: {
- break;
- }
- case Message.DISPLAY: {
- Message.StringMessage d = (Message.StringMessage) entry;
- clearDisplay();
- terminal.writer().printf("%s%n", d.getMessage());
- break;
- }
- case Message.PRINT_OUT: {
- Message.StringMessage d = (Message.StringMessage) entry;
- clearDisplay();
- System.out.printf("%s%n", d.getMessage());
- break;
- }
- case Message.PRINT_ERR: {
- Message.StringMessage d = (Message.StringMessage) entry;
- clearDisplay();
- System.err.printf("%s%n", d.getMessage());
- break;
- }
- case Message.PROMPT: {
- Message.Prompt prompt = (Message.Prompt) entry;
- if (dumb) {
- terminal.writer().println("");
+ case Message.PROJECT_STARTED: {
+ StringMessage be = (StringMessage) entry;
+ final String artifactId = be.getMessage();
+ projects.put(artifactId, new Project(artifactId));
break;
}
- readInput.writeLock().lock();
- try {
+ case Message.MOJO_STARTED: {
+ final MojoStartedEvent execution = (MojoStartedEvent) entry;
+ final Project prj = projects.computeIfAbsent(execution.getArtifactId(), Project::new);
+ prj.runningExecution = execution;
+ break;
+ }
+ case Message.PROJECT_STOPPED: {
+ StringMessage be = (StringMessage) entry;
+ final String artifactId = be.getMessage();
+ Project prj = projects.remove(artifactId);
+ if (prj != null) {
+ prj.log.forEach(log);
+ }
+ doneProjects++;
+ displayDone();
+ break;
+ }
+ case Message.BUILD_STATUS: {
+ this.buildStatus = ((StringMessage) entry).getMessage();
+ break;
+ }
+ case Message.BUILD_FINISHED: {
+ projects.values().stream().flatMap(p -> p.log.stream()).forEach(log);
clearDisplay();
- terminal.writer().printf("[%s] %s", prompt.getProjectId(), prompt.getMessage());
- terminal.flush();
- StringBuilder sb = new StringBuilder();
- while (true) {
- int c = terminal.reader().read();
- if (c < 0) {
- break;
- } else if (c == '\n' || c == '\r') {
- terminal.writer().println();
- daemonDispatch.accept(prompt.response(sb.toString()));
- break;
- } else if (c == 127) {
- if (sb.length() > 0) {
- sb.setLength(sb.length() - 1);
- terminal.writer().write("\b \b");
+ try {
+ log.close();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ terminal.flush();
+ }
+ return false;
+ }
+ case Message.KEEP_ALIVE: {
+ break;
+ }
+ case Message.DISPLAY: {
+ Message.StringMessage d = (Message.StringMessage) entry;
+ clearDisplay();
+ terminal.writer().printf("%s%n", d.getMessage());
+ break;
+ }
+ case Message.PRINT_OUT: {
+ Message.StringMessage d = (Message.StringMessage) entry;
+ clearDisplay();
+ System.out.printf("%s%n", d.getMessage());
+ break;
+ }
+ case Message.PRINT_ERR: {
+ Message.StringMessage d = (Message.StringMessage) entry;
+ clearDisplay();
+ System.err.printf("%s%n", d.getMessage());
+ break;
+ }
+ case Message.PROMPT: {
+ Message.Prompt prompt = (Message.Prompt) entry;
+ if (dumb) {
+ terminal.writer().println("");
+ break;
+ }
+ readInput.writeLock().lock();
+ try {
+ clearDisplay();
+ terminal.writer().printf("[%s] %s", prompt.getProjectId(), prompt.getMessage());
+ terminal.flush();
+ StringBuilder sb = new StringBuilder();
+ while (true) {
+ int c = terminal.reader().read();
+ if (c < 0) {
+ break;
+ } else if (c == '\n' || c == '\r') {
+ terminal.writer().println();
+ daemonDispatch.accept(prompt.response(sb.toString()));
+ break;
+ } else if (c == 127) {
+ if (sb.length() > 0) {
+ sb.setLength(sb.length() - 1);
+ terminal.writer().write("\b \b");
+ terminal.writer().flush();
+ }
+ } else {
+ terminal.writer().print((char) c);
terminal.writer().flush();
+ sb.append((char) c);
}
- } else {
- terminal.writer().print((char) c);
- terminal.writer().flush();
- sb.append((char) c);
}
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ readInput.writeLock().unlock();
}
- } catch (IOException e) {
- throw new RuntimeException(e);
- } finally {
- readInput.writeLock().unlock();
- }
- break;
- }
- case Message.BUILD_LOG_MESSAGE: {
- StringMessage sm = (StringMessage) entry;
- log.accept(sm.getMessage());
- break;
- }
- case Message.PROJECT_LOG_MESSAGE: {
- final ProjectEvent bm = (ProjectEvent) entry;
- final Project prj = projects.get(bm.getProjectId());
- if (prj == null) {
- log.accept(bm.getMessage());
- } else if (noBuffering || dumb) {
- String msg;
- if (maxThreads > 1) {
- msg = String.format("[%s] %s", bm.getProjectId(), bm.getMessage());
- } else {
- msg = bm.getMessage();
- }
- log.accept(msg);
- } else {
- prj.log.add(bm.getMessage());
- }
- break;
- }
- case Message.KEYBOARD_INPUT: {
- char keyStroke = ((StringMessage) entry).getMessage().charAt(0);
- switch (keyStroke) {
- case KEY_PLUS:
- linesPerProject = Math.min(10, linesPerProject + 1);
break;
- case KEY_MINUS:
- linesPerProject = Math.max(0, linesPerProject - 1);
+ }
+ case Message.BUILD_LOG_MESSAGE: {
+ StringMessage sm = (StringMessage) entry;
+ log.accept(sm.getMessage());
break;
- case KEY_CTRL_B:
- noBuffering = !noBuffering;
- if (noBuffering) {
- applyNoBuffering();
+ }
+ case Message.PROJECT_LOG_MESSAGE: {
+ final ProjectEvent bm = (ProjectEvent) entry;
+ final Project prj = projects.get(bm.getProjectId());
+ if (prj == null) {
+ log.accept(bm.getMessage());
+ } else if (noBuffering || dumb) {
+ String msg;
+ if (maxThreads > 1) {
+ msg = String.format("[%s] %s", bm.getProjectId(), bm.getMessage());
+ } else {
+ msg = bm.getMessage();
+ }
+ log.accept(msg);
} else {
- clearDisplay();
+ prj.log.add(bm.getMessage());
}
break;
- case KEY_CTRL_L:
- clearDisplay();
+ }
+ case Message.KEYBOARD_INPUT: {
+ char keyStroke = ((StringMessage) entry).getMessage().charAt(0);
+ switch (keyStroke) {
+ case KEY_PLUS:
+ linesPerProject = Math.min(10, linesPerProject + 1);
+ break;
+ case KEY_MINUS:
+ linesPerProject = Math.max(0, linesPerProject - 1);
+ break;
+ case KEY_CTRL_B:
+ noBuffering = !noBuffering;
+ if (noBuffering) {
+ applyNoBuffering();
+ } else {
+ clearDisplay();
+ }
+ break;
+ case KEY_CTRL_L:
+ clearDisplay();
+ break;
+ case KEY_CTRL_M:
+ displayDone = !displayDone;
+ displayDone();
+ break;
+ }
break;
- case KEY_CTRL_M:
- displayDone = !displayDone;
- displayDone();
+ }
+ case Message.TRANSFER_INITIATED:
+ case Message.TRANSFER_STARTED:
+ case Message.TRANSFER_PROGRESSED: {
+ final TransferEvent te = (TransferEvent) entry;
+ transfers
+ .computeIfAbsent(orEmpty(te.getProjectId()), p -> new LinkedHashMap<>())
+ .put(te.getResourceName(), te);
break;
}
- break;
- }
- case Message.TRANSFER_INITIATED:
- case Message.TRANSFER_STARTED:
- case Message.TRANSFER_PROGRESSED: {
- final TransferEvent te = (TransferEvent) entry;
- transfers.computeIfAbsent(orEmpty(te.getProjectId()), p -> new LinkedHashMap<>())
- .put(te.getResourceName(), te);
- break;
- }
- case Message.TRANSFER_CORRUPTED:
- case Message.TRANSFER_SUCCEEDED:
- case Message.TRANSFER_FAILED: {
- final TransferEvent te = (TransferEvent) entry;
- transfers.computeIfAbsent(orEmpty(te.getProjectId()), p -> new LinkedHashMap<>())
- .remove(te.getResourceName());
- break;
- }
- case Message.EXECUTION_FAILURE: {
- final ExecutionFailureEvent efe = (ExecutionFailureEvent) entry;
- failures.add(efe);
- break;
- }
- default:
- throw new IllegalStateException("Unexpected message " + entry);
+ case Message.TRANSFER_CORRUPTED:
+ case Message.TRANSFER_SUCCEEDED:
+ case Message.TRANSFER_FAILED: {
+ final TransferEvent te = (TransferEvent) entry;
+ transfers
+ .computeIfAbsent(orEmpty(te.getProjectId()), p -> new LinkedHashMap<>())
+ .remove(te.getResourceName());
+ break;
+ }
+ case Message.EXECUTION_FAILURE: {
+ final ExecutionFailureEvent efe = (ExecutionFailureEvent) entry;
+ failures.add(efe);
+ break;
+ }
+ default:
+ throw new IllegalStateException("Unexpected message " + entry);
}
return true;
@@ -455,7 +462,11 @@ public class TerminalOutput implements ClientOutput {
StringBuilder sb = new StringBuilder();
sb.append("Terminal: ").append(terminal != null ? terminal.getClass().getName() : null);
if (terminal instanceof AbstractPosixTerminal) {
- sb.append(" with pty ").append(((AbstractPosixTerminal) terminal).getPty().getClass().getName());
+ sb.append(" with pty ")
+ .append(((AbstractPosixTerminal) terminal)
+ .getPty()
+ .getClass()
+ .getName());
}
this.accept(Message.log(sb.toString()));
}
@@ -589,9 +600,8 @@ public class TerminalOutput implements ClientOutput {
}
}
}
- List<AttributedString> trimmed = lines.stream()
- .map(s -> s.columnSubSequence(0, cols))
- .collect(Collectors.toList());
+ List<AttributedString> trimmed =
+ lines.stream().map(s -> s.columnSubSequence(0, cols)).collect(Collectors.toList());
display.update(trimmed, -1);
}
@@ -612,14 +622,15 @@ public class TerminalOutput implements ClientOutput {
String exception = efe.getException();
if (exception != null) {
if (exception.startsWith("org.apache.maven.lifecycle.LifecycleExecutionException: ")) {
- exception = exception
- .substring("org.apache.maven.lifecycle.LifecycleExecutionException: ".length());
+ exception =
+ exception.substring("org.apache.maven.lifecycle.LifecycleExecutionException: ".length());
}
asb.append(": ").append(exception);
}
} else {
asb.append(String.valueOf(failures.size())).append(" projects failed: ");
- asb.append(failures.stream().map(ExecutionFailureEvent::getProjectId).collect(Collectors.joining(", ")));
+ asb.append(
+ failures.stream().map(ExecutionFailureEvent::getProjectId).collect(Collectors.joining(", ")));
}
AttributedString as = asb.toAttributedString();
if (as.columnLength() >= getTerminalWidth() - 1) {
@@ -633,7 +644,8 @@ public class TerminalOutput implements ClientOutput {
}
private AttributedString formatTransfers(String projectId) {
- Collection<TransferEvent> transfers = this.transfers.getOrDefault(projectId, Collections.emptyMap()).values();
+ Collection<TransferEvent> transfers =
+ this.transfers.getOrDefault(projectId, Collections.emptyMap()).values();
if (transfers.isEmpty()) {
return null;
}
@@ -675,7 +687,8 @@ public class TerminalOutput implements ClientOutput {
String artifactIdVersion = artifactId + "-" + version;
StringBuilder sb = new StringBuilder();
if (p[p.length - 1].charAt(artifactIdVersion.length()) == '-') {
- classifier = p[p.length - 1].substring(artifactIdVersion.length() + 1, p[p.length - 1].lastIndexOf('.'));
+ classifier =
+ p[p.length - 1].substring(artifactIdVersion.length() + 1, p[p.length - 1].lastIndexOf('.'));
} else {
classifier = null;
}
@@ -711,30 +724,27 @@ public class TerminalOutput implements ClientOutput {
asb.style(AttributedStyle.DEFAULT);
/* Daemon ID */
- asb
- .append(" daemon: ")
+ asb.append(" daemon: ")
.style(AttributedStyle.BOLD)
.append(daemonId)
.style(AttributedStyle.DEFAULT);
/* Threads */
- asb
- .append(" threads used/hidden/max: ")
+ asb.append(" threads used/hidden/max: ")
.style(AttributedStyle.BOLD)
- .append(
- String.format(
- threadsFormat,
- new StringBuilder(threadsFormat.length())
- .append(projectsCount)
- .append('/')
- .append(Math.max(0, projectsCount - dispLines))
- .append('/')
- .append(maxThreads).toString()))
+ .append(String.format(
+ threadsFormat,
+ new StringBuilder(threadsFormat.length())
+ .append(projectsCount)
+ .append('/')
+ .append(Math.max(0, projectsCount - dispLines))
+ .append('/')
+ .append(maxThreads)
+ .toString()))
.style(AttributedStyle.DEFAULT);
/* Progress */
- asb
- .append(" progress: ")
+ asb.append(" progress: ")
.style(AttributedStyle.BOLD)
.append(String.format(projectsDoneFomat, doneProjects))
.append('/')
@@ -745,16 +755,12 @@ public class TerminalOutput implements ClientOutput {
.style(AttributedStyle.DEFAULT);
} else if (buildStatus != null) {
- asb
- .style(AttributedStyle.BOLD)
- .append(buildStatus)
- .style(AttributedStyle.DEFAULT);
+ asb.style(AttributedStyle.BOLD).append(buildStatus).style(AttributedStyle.DEFAULT);
}
/* Time */
long sec = (System.currentTimeMillis() - this.start) / 1000;
- asb
- .append(" time: ")
+ asb.append(" time: ")
.style(AttributedStyle.BOLD)
.append(String.format("%02d:%02d", sec / 60, sec % 60))
.style(AttributedStyle.DEFAULT);
@@ -768,20 +774,15 @@ public class TerminalOutput implements ClientOutput {
final AttributedStringBuilder asb = new AttributedStringBuilder();
AttributedString transfer = formatTransfers(prj.id);
if (transfer != null) {
- asb
- .append(':')
+ asb.append(':')
.style(CYAN_FOREGROUND)
.append(String.format(artifactIdFormat, prj.id))
.style(AttributedStyle.DEFAULT)
.append(transfer);
} else if (execution == null) {
- asb
- .append(':')
- .style(CYAN_FOREGROUND)
- .append(prj.id);
+ asb.append(':').style(CYAN_FOREGROUND).append(prj.id);
} else {
- asb
- .append(':')
+ asb.append(':')
.style(CYAN_FOREGROUND)
.append(String.format(artifactIdFormat, prj.id))
.style(GREEN_FOREGROUND)
@@ -802,18 +803,21 @@ public class TerminalOutput implements ClientOutput {
}
private static <T> Collector<T, ?, List<T>> lastN(int n) {
- return Collector.<T, Deque<T>, List<T>> of(ArrayDeque::new, (acc, t) -> {
- if (n > 0) {
- if (acc.size() == n)
- acc.pollFirst();
- acc.add(t);
- }
- }, (acc1, acc2) -> {
- while (acc2.size() < n && !acc1.isEmpty()) {
- acc2.addFirst(acc1.pollLast());
- }
- return acc2;
- }, ArrayList::new);
+ return Collector.<T, Deque<T>, List<T>>of(
+ ArrayDeque::new,
+ (acc, t) -> {
+ if (n > 0) {
+ if (acc.size() == n) acc.pollFirst();
+ acc.add(t);
+ }
+ },
+ (acc1, acc2) -> {
+ while (acc2.size() < n && !acc1.isEmpty()) {
+ acc2.addFirst(acc1.pollLast());
+ }
+ return acc2;
+ },
+ ArrayList::new);
}
private static AttributedString concat(String s1, AttributedString s2) {
@@ -868,7 +872,6 @@ public class TerminalOutput implements ClientOutput {
public void close() throws IOException {
out.close();
}
-
}
/**
@@ -896,6 +899,5 @@ public class TerminalOutput implements ClientOutput {
public void close() {
flush();
}
-
}
}
diff --git a/common/src/test/java/org/mvndaemon/mvnd/common/DaemonRegistryTest.java b/common/src/test/java/org/mvndaemon/mvnd/common/DaemonRegistryTest.java
index 0af81621..4f50732a 100644
--- a/common/src/test/java/org/mvndaemon/mvnd/common/DaemonRegistryTest.java
+++ b/common/src/test/java/org/mvndaemon/mvnd/common/DaemonRegistryTest.java
@@ -1,20 +1,27 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
+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.File;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -29,10 +36,6 @@ import java.util.Random;
import java.util.UUID;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
public class DaemonRegistryTest {
@Test
@@ -47,10 +50,18 @@ public class DaemonRegistryTest {
byte[] token = new byte[16];
new Random().nextBytes(token);
- reg1.store(new DaemonInfo("12345678", "/java/home/",
- "/data/reg/", 0x12345678, "inet:/127.0.0.1:7502", token,
- Locale.getDefault().toLanguageTag(), Arrays.asList("-Xmx"),
- DaemonState.Idle, System.currentTimeMillis(), System.currentTimeMillis()));
+ reg1.store(new DaemonInfo(
+ "12345678",
+ "/java/home/",
+ "/data/reg/",
+ 0x12345678,
+ "inet:/127.0.0.1:7502",
+ token,
+ Locale.getDefault().toLanguageTag(),
+ Arrays.asList("-Xmx"),
+ DaemonState.Idle,
+ System.currentTimeMillis(),
+ System.currentTimeMillis()));
assertNotNull(reg1.getAll());
assertEquals(1, reg1.getAll().size());
@@ -69,10 +80,18 @@ public class DaemonRegistryTest {
for (int i = 0; i < nbDaemons; i++) {
byte[] token = new byte[16];
random.nextBytes(token);
- reg.store(new DaemonInfo(UUID.randomUUID().toString(), "/java/home/",
- "/data/reg/", random.nextInt(), "inet:/127.0.0.1:7502", token,
- Locale.getDefault().toLanguageTag(), Collections.singletonList("-Xmx"),
- DaemonState.Idle, System.currentTimeMillis(), System.currentTimeMillis()));
+ reg.store(new DaemonInfo(
+ UUID.randomUUID().toString(),
+ "/java/home/",
+ "/data/reg/",
+ random.nextInt(),
+ "inet:/127.0.0.1:7502",
+ token,
+ Locale.getDefault().toLanguageTag(),
+ Collections.singletonList("-Xmx"),
+ DaemonState.Idle,
+ System.currentTimeMillis(),
+ System.currentTimeMillis()));
}
}
@@ -94,7 +113,6 @@ public class DaemonRegistryTest {
try (DaemonRegistry reg = new DaemonRegistry(temp)) {
assertEquals(nbDaemons / 2, reg.getAll().size());
}
-
}
@Test
@@ -105,20 +123,26 @@ public class DaemonRegistryTest {
// first store daemon
byte[] token = new byte[16];
new Random().nextBytes(token);
- reg1.store(new DaemonInfo("12345678", "/java/home/",
- "/data/reg/", 0x12345678, "inet:/127.0.0.1:7502", token,
- Locale.getDefault().toLanguageTag(), Arrays.asList("-Xmx"),
- DaemonState.Idle, System.currentTimeMillis(), System.currentTimeMillis()));
+ reg1.store(new DaemonInfo(
+ "12345678",
+ "/java/home/",
+ "/data/reg/",
+ 0x12345678,
+ "inet:/127.0.0.1:7502",
+ token,
+ Locale.getDefault().toLanguageTag(),
+ Arrays.asList("-Xmx"),
+ DaemonState.Idle,
+ System.currentTimeMillis(),
+ System.currentTimeMillis()));
assertEquals(1, reg1.getAll().size());
// store an invalid event to trigger recovery
StringBuilder sb = new StringBuilder(1024);
for (int i = 0; i < 1024; i++) {
sb.append('…');
}
- reg1.storeStopEvent(new DaemonStopEvent("11111",
- System.currentTimeMillis(),
- DaemonExpirationStatus.QUIET_EXPIRE,
- sb.toString()));
+ reg1.storeStopEvent(new DaemonStopEvent(
+ "11111", System.currentTimeMillis(), DaemonExpirationStatus.QUIET_EXPIRE, sb.toString()));
assertEquals(1, reg1.doGetDaemonStopEvents().size());
// check if registry is reset
assertEquals(0, reg1.getAll().size());
@@ -143,5 +167,4 @@ public class DaemonRegistryTest {
}
}
}
-
}
diff --git a/common/src/test/java/org/mvndaemon/mvnd/common/MessageTest.java b/common/src/test/java/org/mvndaemon/mvnd/common/MessageTest.java
index 65f5e3ec..7d6fdb6b 100644
--- a/common/src/test/java/org/mvndaemon/mvnd/common/MessageTest.java
+++ b/common/src/test/java/org/mvndaemon/mvnd/common/MessageTest.java
@@ -1,20 +1,27 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
@@ -22,10 +29,6 @@ import java.io.DataOutputStream;
import java.io.IOException;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
public class MessageTest {
@Test
diff --git a/common/src/test/java/org/mvndaemon/mvnd/common/OsUtilsTest.java b/common/src/test/java/org/mvndaemon/mvnd/common/OsUtilsTest.java
index 3d176aff..41cb71bd 100644
--- a/common/src/test/java/org/mvndaemon/mvnd/common/OsUtilsTest.java
+++ b/common/src/test/java/org/mvndaemon/mvnd/common/OsUtilsTest.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
@@ -28,5 +31,4 @@ public class OsUtilsTest {
Assertions.assertEquals("1g", OsUtils.kbTohumanReadable(1024 * 1024));
Assertions.assertEquals("1t", OsUtils.kbTohumanReadable(1024 * 1024 * 1024));
}
-
}
diff --git a/common/src/test/java/org/mvndaemon/mvnd/common/SocketFamilyTest.java b/common/src/test/java/org/mvndaemon/mvnd/common/SocketFamilyTest.java
index e8fc1fdf..e6f9fa28 100644
--- a/common/src/test/java/org/mvndaemon/mvnd/common/SocketFamilyTest.java
+++ b/common/src/test/java/org/mvndaemon/mvnd/common/SocketFamilyTest.java
@@ -1,20 +1,25 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
@@ -24,14 +29,12 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class SocketFamilyTest {
@Test
void testInetNullHost() throws UnknownHostException {
- InetSocketAddress i4a = new InetSocketAddress(
- InetAddress.getByAddress(null, new byte[] { (byte) 192, (byte) 168, 0, 1 }), 8080);
+ InetSocketAddress i4a =
+ new InetSocketAddress(InetAddress.getByAddress(null, new byte[] {(byte) 192, (byte) 168, 0, 1}), 8080);
assertEquals("inet:/192.168.0.1:8080", SocketFamily.toString(i4a));
assertEquals(i4a, SocketFamily.fromString("inet:/192.168.0.1:8080"));
@@ -40,7 +43,7 @@ public class SocketFamilyTest {
@Test
void testInetDummyHost() throws UnknownHostException {
InetSocketAddress i4a = new InetSocketAddress(
- InetAddress.getByAddress("dummy.org", new byte[] { (byte) 192, (byte) 168, 0, 1 }), 8080);
+ InetAddress.getByAddress("dummy.org", new byte[] {(byte) 192, (byte) 168, 0, 1}), 8080);
assertEquals("inet:dummy.org/192.168.0.1:8080", SocketFamily.toString(i4a));
assertEquals(i4a, SocketFamily.fromString("inet:dummy.org/192.168.0.1:8080"));
@@ -70,5 +73,4 @@ public class SocketFamilyTest {
assertEquals(SocketFamily.unix, SocketFamily.familyOf(address));
assertEquals("unix:/tmp/foo-0123456.socket", SocketFamily.toString(address));
}
-
}
diff --git a/common/src/test/java/org/mvndaemon/mvnd/common/TimeUtilsTest.java b/common/src/test/java/org/mvndaemon/mvnd/common/TimeUtilsTest.java
index 26e3f83a..6c9a0831 100644
--- a/common/src/test/java/org/mvndaemon/mvnd/common/TimeUtilsTest.java
+++ b/common/src/test/java/org/mvndaemon/mvnd/common/TimeUtilsTest.java
@@ -1,25 +1,28 @@
/*
- * Copyright 2020 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.common;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.time.Duration;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class TimeUtilsTest {
@Test
@@ -33,8 +36,8 @@ public class TimeUtilsTest {
assertEquals("5m10s300ms", TimeUtils.printDuration(310300));
assertEquals("5s500ms", TimeUtils.printDuration(5500));
assertEquals("1h50m", TimeUtils.printDuration(6600000));
- assertEquals("2d3h4m", TimeUtils.printDuration(Duration.parse("P2DT3H4M").toMillis()));
+ assertEquals(
+ "2d3h4m", TimeUtils.printDuration(Duration.parse("P2DT3H4M").toMillis()));
assertEquals("2d4m", TimeUtils.printDuration(Duration.parse("P2DT4M").toMillis()));
}
-
}
diff --git a/daemon/pom.xml b/daemon/pom.xml
index 2d6f6e0c..b41136d2 100644
--- a/daemon/pom.xml
+++ b/daemon/pom.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2019 the original author or authors.
@@ -15,113 +16,110 @@
limitations under the License.
-->
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.maven.daemon</groupId>
- <artifactId>mvnd</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.maven.daemon</groupId>
+ <artifactId>mvnd</artifactId>
+ <version>0.9.0-SNAPSHOT</version>
+ </parent>
- <artifactId>mvnd-daemon</artifactId>
+ <artifactId>mvnd-daemon</artifactId>
- <packaging>jar</packaging>
- <name>Maven Daemon</name>
+ <packaging>jar</packaging>
+ <name>Maven Daemon</name>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.daemon</groupId>
- <artifactId>mvnd-common</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.daemon</groupId>
- <artifactId>mvnd-native</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-embedder</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-interactivity-api</artifactId>
- <version>1.0</version>
- <exclusions>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.daemon</groupId>
+ <artifactId>mvnd-common</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.daemon</groupId>
+ <artifactId>mvnd-native</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-embedder</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-interactivity-api</artifactId>
+ <version>1.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
- <!-- Logging -->
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>log4j-over-slf4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- </dependency>
+ <!-- Logging -->
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jul-to-slf4j</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.jline</groupId>
- <artifactId>jline-terminal</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.jline</groupId>
+ <artifactId>jline-terminal</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.eclipse.sisu</groupId>
- <artifactId>org.eclipse.sisu.inject</artifactId>
- <version>${sisu.version}</version>
- <scope>compile</scope>
- </dependency>
+ <dependency>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>org.eclipse.sisu.inject</artifactId>
+ <version>${sisu.version}</version>
+ <scope>compile</scope>
+ </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
- <build>
- <resources>
- <resource>
- <directory>${basedir}/src/main/resources</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <redirectTestOutputToFile>true</redirectTestOutputToFile>
- <forkCount>1</forkCount>
- <reuseForks>true</reuseForks>
- <argLine>
- --add-opens java.base/java.io=ALL-UNNAMED
+ <build>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>${basedir}/src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <forkCount>1</forkCount>
+ <reuseForks>true</reuseForks>
+ <argLine>--add-opens java.base/java.io=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
- --add-opens java.base/sun.nio.fs=ALL-UNNAMED
- </argLine>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ --add-opens java.base/sun.nio.fs=ALL-UNNAMED</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
-</project>
\ No newline at end of file
+</project>
diff --git a/daemon/src/main/java/org/apache/maven/classrealm/MvndClassRealmManager.java b/daemon/src/main/java/org/apache/maven/classrealm/MvndClassRealmManager.java
index cddc0077..90e03d18 100644
--- a/daemon/src/main/java/org/apache/maven/classrealm/MvndClassRealmManager.java
+++ b/daemon/src/main/java/org/apache/maven/classrealm/MvndClassRealmManager.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.classrealm;
@@ -55,8 +58,7 @@ import org.eclipse.sisu.Priority;
@Named
@Singleton
@Priority(10)
-public class MvndClassRealmManager
- implements ClassRealmManager {
+public class MvndClassRealmManager implements ClassRealmManager {
public static final String API_REALMID = "maven.api";
/**
@@ -87,8 +89,11 @@ public class MvndClassRealmManager
private final Set<String> providedArtifacts;
@Inject
- public MvndClassRealmManager(Logger logger, PlexusContainer container,
- List<ClassRealmManagerDelegate> delegates, CoreExportsProvider exports) {
+ public MvndClassRealmManager(
+ Logger logger,
+ PlexusContainer container,
+ List<ClassRealmManagerDelegate> delegates,
+ CoreExportsProvider exports) {
this.logger = logger;
this.world = ((MutablePlexusContainer) container).getClassWorld();
this.containerRealm = container.getContainerRealm();
@@ -96,9 +101,13 @@ public class MvndClassRealmManager
Map<String, ClassLoader> foreignImports = exports.get().getExportedPackages();
- this.mavenApiRealm = createRealm(API_REALMID, ClassRealmRequest.RealmType.Core, null /* parent */,
+ this.mavenApiRealm = createRealm(
+ API_REALMID,
+ ClassRealmRequest.RealmType.Core,
+ null /* parent */,
null /* parentImports */,
- foreignImports, null /* artifacts */ );
+ foreignImports,
+ null /* artifacts */);
this.providedArtifacts = exports.get().getExportedArtifacts();
}
@@ -141,9 +150,13 @@ public class MvndClassRealmManager
* missing file) will automatically be excluded from the realm.
* @return The created class realm, never {@code null}.
*/
- private ClassRealm createRealm(String baseRealmId, ClassRealmRequest.RealmType type, ClassLoader parent,
+ private ClassRealm createRealm(
+ String baseRealmId,
+ ClassRealmRequest.RealmType type,
+ ClassLoader parent,
List<String> parentImports,
- Map<String, ClassLoader> foreignImports, List<Artifact> artifacts) {
+ Map<String, ClassLoader> foreignImports,
+ List<Artifact> artifacts) {
Set<String> artifactIds = new LinkedHashSet<>();
List<ClassRealmConstituent> constituents = new ArrayList<>();
@@ -215,25 +228,34 @@ public class MvndClassRealmManager
ClassLoader parent = PARENT_CLASSLOADER;
- Map<String, ClassLoader> foreignImports = Collections.<String, ClassLoader> singletonMap("", getMavenApiRealm());
+ Map<String, ClassLoader> foreignImports = Collections.<String, ClassLoader>singletonMap("", getMavenApiRealm());
- return createRealm(getKey(plugin, true), ClassRealmRequest.RealmType.Extension, parent, null, foreignImports,
- artifacts);
+ return createRealm(
+ getKey(plugin, true), ClassRealmRequest.RealmType.Extension, parent, null, foreignImports, artifacts);
}
private boolean isProvidedArtifact(Artifact artifact) {
return providedArtifacts.contains(artifact.getGroupId() + ":" + artifact.getArtifactId());
}
- public ClassRealm createPluginRealm(Plugin plugin, ClassLoader parent, List<String> parentImports,
- Map<String, ClassLoader> foreignImports, List<Artifact> artifacts) {
+ public ClassRealm createPluginRealm(
+ Plugin plugin,
+ ClassLoader parent,
+ List<String> parentImports,
+ Map<String, ClassLoader> foreignImports,
+ List<Artifact> artifacts) {
Objects.requireNonNull(plugin, "plugin cannot be null");
if (parent == null) {
parent = PARENT_CLASSLOADER;
}
- return createRealm(getKey(plugin, false), ClassRealmRequest.RealmType.Plugin, parent, parentImports, foreignImports,
+ return createRealm(
+ getKey(plugin, false),
+ ClassRealmRequest.RealmType.Plugin,
+ parent,
+ parentImports,
+ foreignImports,
artifacts);
}
@@ -244,33 +266,48 @@ public class MvndClassRealmManager
}
private static String getId(Artifact artifact) {
- return getId(artifact.getGroupId(), artifact.getArtifactId(), artifact.getExtension(),
- artifact.getClassifier(), artifact.getBaseVersion());
+ return getId(
+ artifact.getGroupId(),
+ artifact.getArtifactId(),
+ artifact.getExtension(),
+ artifact.getClassifier(),
+ artifact.getBaseVersion());
}
private static String getId(ClassRealmConstituent constituent) {
- return getId(constituent.getGroupId(), constituent.getArtifactId(), constituent.getType(),
- constituent.getClassifier(), constituent.getVersion());
+ return getId(
+ constituent.getGroupId(),
+ constituent.getArtifactId(),
+ constituent.getType(),
+ constituent.getClassifier(),
+ constituent.getVersion());
}
private static String getId(String gid, String aid, String type, String cls, String ver) {
return gid + ':' + aid + ':' + type + (StringUtils.isNotEmpty(cls) ? ':' + cls : "") + ':' + ver;
}
- private void callDelegates(ClassRealm classRealm, ClassRealmRequest.RealmType type, ClassLoader parent,
+ private void callDelegates(
+ ClassRealm classRealm,
+ ClassRealmRequest.RealmType type,
+ ClassLoader parent,
List<String> parentImports,
- Map<String, ClassLoader> foreignImports, List<ClassRealmConstituent> constituents) {
+ Map<String, ClassLoader> foreignImports,
+ List<ClassRealmConstituent> constituents) {
List<ClassRealmManagerDelegate> delegates = new ArrayList<>(this.delegates);
if (!delegates.isEmpty()) {
- ClassRealmRequest request = new DefaultClassRealmRequest(type, parent, parentImports, foreignImports, constituents);
+ ClassRealmRequest request =
+ new DefaultClassRealmRequest(type, parent, parentImports, foreignImports, constituents);
for (ClassRealmManagerDelegate delegate : delegates) {
try {
delegate.setupRealm(classRealm, request);
} catch (Exception e) {
- logger.error(delegate.getClass().getName() + " failed to setup class realm " + classRealm + ": "
- + e.getMessage(), e);
+ logger.error(
+ delegate.getClass().getName() + " failed to setup class realm " + classRealm + ": "
+ + e.getMessage(),
+ e);
}
}
}
@@ -343,5 +380,4 @@ public class MvndClassRealmManager
}
return String.valueOf(classLoader);
}
-
}
diff --git a/daemon/src/main/java/org/apache/maven/cli/DaemonMavenCli.java b/daemon/src/main/java/org/apache/maven/cli/DaemonMavenCli.java
index 5d23c9a4..2dbf3f2d 100644
--- a/daemon/src/main/java/org/apache/maven/cli/DaemonMavenCli.java
+++ b/daemon/src/main/java/org/apache/maven/cli/DaemonMavenCli.java
@@ -7,7 +7,7 @@
* "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
@@ -18,6 +18,9 @@
*/
package org.apache.maven.cli;
+import static java.util.Comparator.comparing;
+import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
+
import com.google.inject.AbstractModule;
import java.io.File;
import java.io.FileNotFoundException;
@@ -117,9 +120,6 @@ import org.slf4j.LoggerFactory;
import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher;
import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher;
-import static java.util.Comparator.comparing;
-import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
-
/**
* File origin:
* https://github.com/apache/maven/blob/maven-3.6.2/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
@@ -137,7 +137,8 @@ public class DaemonMavenCli {
public static final File DEFAULT_USER_TOOLCHAINS_FILE = new File(USER_MAVEN_CONFIGURATION_HOME, "toolchains.xml");
- public static final File DEFAULT_GLOBAL_TOOLCHAINS_FILE = new File(System.getProperty("maven.conf"), "toolchains.xml");
+ public static final File DEFAULT_GLOBAL_TOOLCHAINS_FILE =
+ new File(System.getProperty("maven.conf"), "toolchains.xml");
private static final String EXT_CLASS_PATH = "maven.ext.class.path";
@@ -198,14 +199,15 @@ public class DaemonMavenCli {
toolchainsBuilder = container.lookup(ToolchainsBuilder.class);
dispatcher = (DefaultSecDispatcher) container.lookup(SecDispatcher.class, "maven");
executionListener = container.lookup(LoggingExecutionListener.class);
-
}
- public int main(List<String> arguments,
+ public int main(
+ List<String> arguments,
String workingDirectory,
String projectDirectory,
Map<String, String> clientEnv,
- BuildEventListener buildEventListener) throws Exception {
+ BuildEventListener buildEventListener)
+ throws Exception {
this.buildEventListener = buildEventListener;
try {
CliRequest req = new CliRequest(null, null);
@@ -246,8 +248,7 @@ public class DaemonMavenCli {
}
}
- void initialize(CliRequest cliRequest)
- throws ExitException {
+ void initialize(CliRequest cliRequest) throws ExitException {
cliRequest.classWorld = classWorld;
if (cliRequest.workingDirectory == null) {
@@ -255,15 +256,13 @@ public class DaemonMavenCli {
}
if (cliRequest.multiModuleProjectDirectory == null) {
- buildEventListener.log(String.format(
- "-D%s system property is not set.", MULTIMODULE_PROJECT_DIRECTORY));
+ buildEventListener.log(String.format("-D%s system property is not set.", MULTIMODULE_PROJECT_DIRECTORY));
throw new ExitException(1);
}
System.setProperty("maven.multiModuleProjectDirectory", cliRequest.multiModuleProjectDirectory.toString());
}
- void cli(CliRequest cliRequest)
- throws Exception {
+ void cli(CliRequest cliRequest) throws Exception {
CLIManager cliManager = newCLIManager();
List<String> args = new ArrayList<>();
@@ -312,10 +311,15 @@ public class DaemonMavenCli {
private CLIManager newCLIManager() {
CLIManager cliManager = new CLIManager();
- cliManager.options.addOption(Option.builder(RESUME).longOpt("resume").desc("Resume reactor from " +
- "the last failed project, using the resume.properties file in the build directory").build());
- cliManager.options.addOption(Option.builder().longOpt(RAW_STREAMS).desc("Do not decorate output and " +
- "error streams").build());
+ cliManager.options.addOption(Option.builder(RESUME)
+ .longOpt("resume")
+ .desc("Resume reactor from "
+ + "the last failed project, using the resume.properties file in the build directory")
+ .build());
+ cliManager.options.addOption(Option.builder()
+ .longOpt(RAW_STREAMS)
+ .desc("Do not decorate output and " + "error streams")
+ .build());
return cliManager;
}
@@ -383,8 +387,8 @@ public class DaemonMavenCli {
}
// Workaround for https://github.com/apache/maven-mvnd/issues/39
- final ch.qos.logback.classic.Logger mvndLogger = (ch.qos.logback.classic.Logger) slf4jLoggerFactory
- .getLogger("org.mvndaemon.mvnd");
+ final ch.qos.logback.classic.Logger mvndLogger =
+ (ch.qos.logback.classic.Logger) slf4jLoggerFactory.getLogger("org.mvndaemon.mvnd");
mvndLogger.setLevel(ch.qos.logback.classic.Level.toLevel(System.getProperty("mvnd.log.level"), null));
// LOG STREAMS
@@ -403,8 +407,10 @@ public class DaemonMavenCli {
//
}
} else if (!cliRequest.commandLine.hasOption(RAW_STREAMS)) {
- ch.qos.logback.classic.Logger stdout = (ch.qos.logback.classic.Logger) slf4jLoggerFactory.getLogger("stdout");
- ch.qos.logback.classic.Logger stderr = (ch.qos.logback.classic.Logger) slf4jLoggerFactory.getLogger("stderr");
+ ch.qos.logback.classic.Logger stdout =
+ (ch.qos.logback.classic.Logger) slf4jLoggerFactory.getLogger("stdout");
+ ch.qos.logback.classic.Logger stderr =
+ (ch.qos.logback.classic.Logger) slf4jLoggerFactory.getLogger("stderr");
stdout.setLevel(ch.qos.logback.classic.Level.INFO);
stderr.setLevel(ch.qos.logback.classic.Level.INFO);
System.setOut(new LoggingOutputStream(s -> stdout.info("[stdout] " + s)).printStream());
@@ -452,8 +458,8 @@ public class DaemonMavenCli {
}
}
- //Needed to make this method package visible to make writing a unit test possible
- //Maybe it's better to move some of those methods to separate class (SoC).
+ // Needed to make this method package visible to make writing a unit test possible
+ // Maybe it's better to move some of those methods to separate class (SoC).
void properties(CliRequest cliRequest) {
populateProperties(cliRequest.commandLine, cliRequest.systemProperties, cliRequest.userProperties);
}
@@ -468,22 +474,21 @@ public class DaemonMavenCli {
eventSpyDispatcher.init(() -> data);
}
- DefaultPlexusContainer container()
- throws Exception {
+ DefaultPlexusContainer container() throws Exception {
ClassRealm coreRealm = classWorld.getClassRealm("plexus.core");
if (coreRealm == null) {
coreRealm = classWorld.getRealms().iterator().next();
}
- List<File> extClassPath = Stream
- .of(Environment.MVND_EXT_CLASSPATH.asString().split(","))
+ List<File> extClassPath = Stream.of(
+ Environment.MVND_EXT_CLASSPATH.asString().split(","))
.map(File::new)
.collect(Collectors.toList());
CoreExtensionEntry coreEntry = CoreExtensionEntry.discoverFrom(coreRealm);
- List<CoreExtension> extensions = Stream
- .of(Environment.MVND_CORE_EXTENSIONS.asString().split(";"))
+ List<CoreExtension> extensions = Stream.of(
+ Environment.MVND_CORE_EXTENSIONS.asString().split(";"))
.filter(s -> s != null && !s.isEmpty())
.map(s -> {
String[] parts = s.split(":");
@@ -494,13 +499,17 @@ public class DaemonMavenCli {
return ce;
})
.collect(Collectors.toList());
- List<CoreExtensionEntry> extensionsEntries = loadCoreExtensions(extensions, coreRealm,
- coreEntry.getExportedArtifacts());
+ List<CoreExtensionEntry> extensionsEntries =
+ loadCoreExtensions(extensions, coreRealm, coreEntry.getExportedArtifacts());
ClassRealm containerRealm = setupContainerRealm(classWorld, coreRealm, extClassPath, extensionsEntries);
- ContainerConfiguration cc = new DefaultContainerConfiguration().setClassWorld(classWorld)
- .setRealm(containerRealm).setClassPathScanning(PlexusConstants.SCANNING_INDEX).setAutoWiring(true)
- .setJSR250Lifecycle(true).setName("maven");
+ ContainerConfiguration cc = new DefaultContainerConfiguration()
+ .setClassWorld(classWorld)
+ .setRealm(containerRealm)
+ .setClassPathScanning(PlexusConstants.SCANNING_INDEX)
+ .setAutoWiring(true)
+ .setJSR250Lifecycle(true)
+ .setName("maven");
Set<String> exportedArtifacts = new HashSet<>(coreEntry.getExportedArtifacts());
Set<String> exportedPackages = new HashSet<>(coreEntry.getExportedPackages());
@@ -535,14 +544,16 @@ public class DaemonMavenCli {
container.setLoggerManager(plexusLoggerManager);
for (CoreExtensionEntry extension : extensionsEntries) {
- container.discoverComponents(extension.getClassRealm(), new SessionScopeModule(container),
+ container.discoverComponents(
+ extension.getClassRealm(),
+ new SessionScopeModule(container),
new MojoExecutionScopeModule(container));
}
return container;
}
- private List<CoreExtensionEntry> loadCoreExtensions(List<CoreExtension> extensions, ClassRealm containerRealm,
- Set<String> providedArtifacts) {
+ private List<CoreExtensionEntry> loadCoreExtensions(
+ List<CoreExtension> extensions, ClassRealm containerRealm, Set<String> providedArtifacts) {
try {
if (extensions.isEmpty()) {
return Collections.emptyList();
@@ -570,19 +581,25 @@ public class DaemonMavenCli {
container.getLoggerManager().setThresholds(cliRequest.request.getLoggingLevel());
Thread.currentThread().setContextClassLoader(container.getContainerRealm());
executionRequestPopulator = container.lookup(MavenExecutionRequestPopulator.class);
- final Map<String, ConfigurationProcessor> configurationProcessors = container
- .lookupMap(ConfigurationProcessor.class);
+ final Map<String, ConfigurationProcessor> configurationProcessors =
+ container.lookupMap(ConfigurationProcessor.class);
final EventSpyDispatcher eventSpyDispatcher = container.lookup(EventSpyDispatcher.class);
properties(cliRequest);
configure(cliRequest, eventSpyDispatcher, configurationProcessors);
LoggingExecutionListener executionListener = container.lookup(LoggingExecutionListener.class);
- populateRequest(cliRequest, cliRequest.request, slf4jLogger, eventSpyDispatcher,
- container.lookup(ModelProcessor.class), createTransferListener(cliRequest), buildEventListener,
+ populateRequest(
+ cliRequest,
+ cliRequest.request,
+ slf4jLogger,
+ eventSpyDispatcher,
+ container.lookup(ModelProcessor.class),
+ createTransferListener(cliRequest),
+ buildEventListener,
executionListener);
executionRequestPopulator.populateDefaults(cliRequest.request);
BootstrapCoreExtensionManager resolver = container.lookup(BootstrapCoreExtensionManager.class);
- return Collections
- .unmodifiableList(resolver.loadCoreExtensions(cliRequest.request, providedArtifacts, extensions));
+ return Collections.unmodifiableList(
+ resolver.loadCoreExtensions(cliRequest.request, providedArtifacts, extensions));
} finally {
executionRequestPopulator = null;
container.dispose();
@@ -596,8 +613,9 @@ public class DaemonMavenCli {
return Collections.emptyList();
}
- private ClassRealm setupContainerRealm(ClassWorld classWorld, ClassRealm coreRealm, List<File> extClassPath,
- List<CoreExtensionEntry> extensions) throws Exception {
+ private ClassRealm setupContainerRealm(
+ ClassWorld classWorld, ClassRealm coreRealm, List<File> extClassPath, List<CoreExtensionEntry> extensions)
+ throws Exception {
if (!extClassPath.isEmpty() || !extensions.isEmpty()) {
ClassRealm extRealm = classWorld.newRealm("maven.ext", null);
extRealm.setParentRealm(coreRealm);
@@ -652,8 +670,7 @@ public class DaemonMavenCli {
//
// This should probably be a separate tool and not be baked into Maven.
//
- private void encryption(CliRequest cliRequest)
- throws Exception {
+ private void encryption(CliRequest cliRequest) throws Exception {
if (cliRequest.commandLine.hasOption(CLIManager.ENCRYPT_MASTER_PASSWORD)) {
throw new UnsupportedOperationException("Unsupported option: " + CLIManager.ENCRYPT_MASTER_PASSWORD);
} else if (cliRequest.commandLine.hasOption(CLIManager.ENCRYPT_PASSWORD)) {
@@ -661,10 +678,9 @@ public class DaemonMavenCli {
}
}
- private void repository(CliRequest cliRequest)
- throws Exception {
- if (cliRequest.commandLine.hasOption(CLIManager.LEGACY_LOCAL_REPOSITORY) || Boolean.getBoolean(
- "maven.legacyLocalRepo")) {
+ private void repository(CliRequest cliRequest) throws Exception {
+ if (cliRequest.commandLine.hasOption(CLIManager.LEGACY_LOCAL_REPOSITORY)
+ || Boolean.getBoolean("maven.legacyLocalRepo")) {
cliRequest.request.setUseLegacyLocalRepository(true);
}
}
@@ -673,8 +689,7 @@ public class DaemonMavenCli {
EnvHelper.environment(workingDir, clientEnv);
}
- private int execute(CliRequest cliRequest)
- throws MavenExecutionRequestPopulationException {
+ private int execute(CliRequest cliRequest) throws MavenExecutionRequestPopulationException {
commands(cliRequest);
MavenExecutionRequest request = executionRequestPopulator.populateDefaults(cliRequest.request);
@@ -682,7 +697,8 @@ public class DaemonMavenCli {
eventSpyDispatcher.onEvent(request);
slf4jLogger.info(buffer().a("Processing build on daemon ")
- .strong(Environment.MVND_ID.asString()).toString());
+ .strong(Environment.MVND_ID.asString())
+ .toString());
MavenExecutionResult result = maven.execute(request);
@@ -711,12 +727,13 @@ public class DaemonMavenCli {
slf4jLogger.error("");
if (!cliRequest.showErrors) {
- slf4jLogger.error("To see the full stack trace of the errors, re-run Maven with the {} switch.",
+ slf4jLogger.error(
+ "To see the full stack trace of the errors, re-run Maven with the {} switch.",
buffer().strong("-e"));
}
if (!slf4jLogger.isDebugEnabled()) {
- slf4jLogger.error("Re-run Maven using the {} switch to enable full debug logging.",
- buffer().strong("-X"));
+ slf4jLogger.error(
+ "Re-run Maven using the {} switch to enable full debug logging.", buffer().strong("-X"));
}
if (!references.isEmpty()) {
@@ -729,16 +746,20 @@ public class DaemonMavenCli {
}
}
- boolean canResume = new DefaultBuildResumptionAnalyzer().determineBuildResumptionData(result).map(resumption -> {
- try {
- Path directory = Paths.get(request.getBaseDirectory()).resolve("target");
- new DefaultBuildResumptionDataRepository().persistResumptionData(directory, resumption);
- return true;
- } catch (BuildResumptionPersistenceException e) {
- slf4jLogger.warn("Could not persist build resumption data", e);
- }
- return false;
- }).orElse(false);
+ boolean canResume = new DefaultBuildResumptionAnalyzer()
+ .determineBuildResumptionData(result)
+ .map(resumption -> {
+ try {
+ Path directory =
+ Paths.get(request.getBaseDirectory()).resolve("target");
+ new DefaultBuildResumptionDataRepository().persistResumptionData(directory, resumption);
+ return true;
+ } catch (BuildResumptionPersistenceException e) {
+ slf4jLogger.warn("Could not persist build resumption data", e);
+ }
+ return false;
+ })
+ .orElse(false);
if (canResume) {
logBuildResumeHint("mvn <args> -r");
@@ -794,16 +815,16 @@ public class DaemonMavenCli {
*/
private String getResumeFromSelector(List<MavenProject> mavenProjects, MavenProject failedProject) {
for (MavenProject buildProject : mavenProjects) {
- if (failedProject.getArtifactId().equals(buildProject.getArtifactId()) && !failedProject.equals(
- buildProject)) {
+ if (failedProject.getArtifactId().equals(buildProject.getArtifactId())
+ && !failedProject.equals(buildProject)) {
return failedProject.getGroupId() + ":" + failedProject.getArtifactId();
}
}
return ":" + failedProject.getArtifactId();
}
- private void logSummary(ExceptionSummary summary, Map<String, String> references, String indent,
- boolean showErrors) {
+ private void logSummary(
+ ExceptionSummary summary, Map<String, String> references, String indent, boolean showErrors) {
String referenceKey = "";
if (StringUtils.isNotEmpty(summary.getReference())) {
@@ -845,8 +866,7 @@ public class DaemonMavenCli {
// effective line, with indent and reset if end is colored
line = indent + line + ("".equals(nextColor) ? "" : ANSI_RESET);
- if ((i == lines.length - 1) && (showErrors
- || (summary.getException() instanceof InternalErrorException))) {
+ if ((i == lines.length - 1) && (showErrors || (summary.getException() instanceof InternalErrorException))) {
slf4jLogger.error(line, summary.getException());
} else {
slf4jLogger.error(line);
@@ -909,14 +929,15 @@ public class DaemonMavenCli {
//
// There are too many ConfigurationProcessors so we don't know which one to run so report the error.
//
- StringBuilder sb = new StringBuilder(
- String.format("\nThere can only be one user supplied ConfigurationProcessor, there are %s:\n\n",
- userSuppliedConfigurationProcessorCount));
+ StringBuilder sb = new StringBuilder(String.format(
+ "\nThere can only be one user supplied ConfigurationProcessor, there are %s:\n\n",
+ userSuppliedConfigurationProcessorCount));
for (Entry<String, ConfigurationProcessor> entry : configurationProcessors.entrySet()) {
String hint = entry.getKey();
if (!hint.equals(SettingsXmlConfigurationProcessor.HINT)) {
ConfigurationProcessor configurationProcessor = entry.getValue();
- sb.append(String.format("%s\n", configurationProcessor.getClass().getName()));
+ sb.append(String.format(
+ "%s\n", configurationProcessor.getClass().getName()));
}
}
sb.append("\n");
@@ -924,8 +945,7 @@ public class DaemonMavenCli {
}
}
- void toolchains(CliRequest cliRequest)
- throws Exception {
+ void toolchains(CliRequest cliRequest) throws Exception {
File userToolchainsFile;
if (cliRequest.commandLine.hasOption(CLIManager.ALTERNATE_USER_TOOLCHAINS)) {
@@ -943,7 +963,8 @@ public class DaemonMavenCli {
File globalToolchainsFile;
if (cliRequest.commandLine.hasOption(CLIManager.ALTERNATE_GLOBAL_TOOLCHAINS)) {
- globalToolchainsFile = new File(cliRequest.commandLine.getOptionValue(CLIManager.ALTERNATE_GLOBAL_TOOLCHAINS));
+ globalToolchainsFile =
+ new File(cliRequest.commandLine.getOptionValue(CLIManager.ALTERNATE_GLOBAL_TOOLCHAINS));
globalToolchainsFile = resolveFile(globalToolchainsFile, cliRequest.workingDirectory);
if (!globalToolchainsFile.isFile()) {
@@ -967,17 +988,18 @@ public class DaemonMavenCli {
eventSpyDispatcher.onEvent(toolchainsRequest);
- slf4jLogger.debug("Reading global toolchains from {}",
+ slf4jLogger.debug(
+ "Reading global toolchains from {}",
getLocation(toolchainsRequest.getGlobalToolchainsSource(), globalToolchainsFile));
- slf4jLogger.debug("Reading user toolchains from {}",
+ slf4jLogger.debug(
+ "Reading user toolchains from {}",
getLocation(toolchainsRequest.getUserToolchainsSource(), userToolchainsFile));
ToolchainsBuildingResult toolchainsResult = toolchainsBuilder.build(toolchainsRequest);
eventSpyDispatcher.onEvent(toolchainsResult);
- executionRequestPopulator.populateFromToolchains(cliRequest.request,
- toolchainsResult.getEffectiveToolchains());
+ executionRequestPopulator.populateFromToolchains(cliRequest.request, toolchainsResult.getEffectiveToolchains());
if (!toolchainsResult.getProblems().isEmpty() && slf4jLogger.isWarnEnabled()) {
slf4jLogger.warn("");
@@ -999,8 +1021,15 @@ public class DaemonMavenCli {
}
private void populateRequest(CliRequest cliRequest) {
- populateRequest(cliRequest, cliRequest.request, slf4jLogger, eventSpyDispatcher, modelProcessor,
- createTransferListener(cliRequest), buildEventListener, executionListener);
+ populateRequest(
+ cliRequest,
+ cliRequest.request,
+ slf4jLogger,
+ eventSpyDispatcher,
+ modelProcessor,
+ createTransferListener(cliRequest),
+ buildEventListener,
+ executionListener);
}
private static void populateRequest(
@@ -1016,10 +1045,11 @@ public class DaemonMavenCli {
String workingDirectory = cliRequest.workingDirectory;
boolean showErrors = cliRequest.showErrors;
- String[] deprecatedOptions = { "up", "npu", "cpu", "npr" };
+ String[] deprecatedOptions = {"up", "npu", "cpu", "npr"};
for (String deprecatedOption : deprecatedOptions) {
if (commandLine.hasOption(deprecatedOption)) {
- slf4jLogger.warn("Command line option -{} is deprecated and will be removed in future Maven versions.",
+ slf4jLogger.warn(
+ "Command line option -{} is deprecated and will be removed in future Maven versions.",
deprecatedOption);
}
}
@@ -1111,9 +1141,7 @@ public class DaemonMavenCli {
}
ExecutionEventLogger executionEventLogger = new ExecutionEventLogger();
- executionListener.init(
- eventSpyDispatcher.chainListener(executionEventLogger),
- buildEventListener);
+ executionListener.init(eventSpyDispatcher.chainListener(executionEventLogger), buildEventListener);
String alternatePomFile = null;
if (commandLine.hasOption(CLIManager.ALTERNATE_POM_FILE)) {
@@ -1157,7 +1185,8 @@ public class DaemonMavenCli {
if (commandLine.hasOption(RESUME)) {
new DefaultBuildResumptionDataRepository()
- .applyResumptionData(request, Paths.get(request.getBaseDirectory()).resolve("target"));
+ .applyResumptionData(
+ request, Paths.get(request.getBaseDirectory()).resolve("target"));
}
if (commandLine.hasOption(CLIManager.RESUME_FROM)) {
@@ -1192,14 +1221,13 @@ public class DaemonMavenCli {
request.setExcludedProjects(exclProjects);
}
- if (commandLine.hasOption(CLIManager.ALSO_MAKE) && !commandLine.hasOption(
- CLIManager.ALSO_MAKE_DEPENDENTS)) {
+ if (commandLine.hasOption(CLIManager.ALSO_MAKE) && !commandLine.hasOption(CLIManager.ALSO_MAKE_DEPENDENTS)) {
request.setMakeBehavior(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM);
- } else if (!commandLine.hasOption(CLIManager.ALSO_MAKE) && commandLine.hasOption(
- CLIManager.ALSO_MAKE_DEPENDENTS)) {
+ } else if (!commandLine.hasOption(CLIManager.ALSO_MAKE)
+ && commandLine.hasOption(CLIManager.ALSO_MAKE_DEPENDENTS)) {
request.setMakeBehavior(MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM);
- } else if (commandLine.hasOption(CLIManager.ALSO_MAKE) && commandLine.hasOption(
- CLIManager.ALSO_MAKE_DEPENDENTS)) {
+ } else if (commandLine.hasOption(CLIManager.ALSO_MAKE)
+ && commandLine.hasOption(CLIManager.ALSO_MAKE_DEPENDENTS)) {
request.setMakeBehavior(MavenExecutionRequest.REACTOR_MAKE_BOTH);
}
@@ -1224,9 +1252,8 @@ public class DaemonMavenCli {
// parameters but this is sufficient for now. Ultimately we want components like Builders to provide a way to
// extend the command line to accept its own configuration parameters.
//
- final String threadConfiguration = commandLine.hasOption(CLIManager.THREADS)
- ? commandLine.getOptionValue(CLIManager.THREADS)
- : null;
+ final String threadConfiguration =
+ commandLine.hasOption(CLIManager.THREADS) ? commandLine.getOptionValue(CLIManager.THREADS) : null;
if (threadConfiguration != null) {
//
@@ -1310,7 +1337,8 @@ public class DaemonMavenCli {
if (props != null) {
boolean caseSensitive = Os.current() == Os.WINDOWS;
for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
- String key = "env." + (caseSensitive ? entry.getKey() : entry.getKey().toUpperCase(Locale.ENGLISH));
+ String key = "env."
+ + (caseSensitive ? entry.getKey() : entry.getKey().toUpperCase(Locale.ENGLISH));
props.setProperty(key, entry.getValue());
}
}
@@ -1343,8 +1371,7 @@ public class DaemonMavenCli {
System.setProperty(name, value);
}
- static class ExitException
- extends Exception {
+ static class ExitException extends Exception {
static final long serialVersionUID = 1L;
int exitCode;
@@ -1379,8 +1406,7 @@ public class DaemonMavenCli {
return new Slf4jMavenTransferListener();
}
- protected ModelProcessor createModelProcessor(PlexusContainer container)
- throws ComponentLookupException {
+ protected ModelProcessor createModelProcessor(PlexusContainer container) throws ComponentLookupException {
return container.lookup(ModelProcessor.class);
}
}
diff --git a/daemon/src/main/java/org/apache/maven/cli/MvndHelpFormatter.java b/daemon/src/main/java/org/apache/maven/cli/MvndHelpFormatter.java
index 62594d4e..68ce2ef2 100644
--- a/daemon/src/main/java/org/apache/maven/cli/MvndHelpFormatter.java
+++ b/daemon/src/main/java/org/apache/maven/cli/MvndHelpFormatter.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.cli;
@@ -54,8 +57,16 @@ public class MvndHelpFormatter {
out.println();
PrintWriter pw = new PrintWriter(out);
HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp(pw, terminalWidth, "mvnd [options] [<goal(s)>] [<phase(s)>]", "\nOptions:", cliManager.options,
- 1, 3, "\n", false);
+ formatter.printHelp(
+ pw,
+ terminalWidth,
+ "mvnd [options] [<goal(s)>] [<phase(s)>]",
+ "\nOptions:",
+ cliManager.options,
+ 1,
+ 3,
+ "\n",
+ false);
pw.flush();
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
@@ -65,78 +76,66 @@ public class MvndHelpFormatter {
final String indent = m.find() ? m.group() : " ";
final String lineSeparator = System.lineSeparator();
- final StringBuilder help = new StringBuilder(mvnHelp)
- .append(lineSeparator)
- .append("mvnd specific options:");
-
- Environment.documentedEntries()
- .forEach(entry -> {
- final Environment env = entry.getEntry();
- help.append(lineSeparator);
- int indentPos = help.length() + indent.length();
- int lineEnd = help.length() + terminalWidth;
- spaces(help, HelpFormatter.DEFAULT_LEFT_PAD);
- final String property = env.getProperty();
- if (property != null) {
- help
- .append("-D")
- .append(property);
- if (env.getType() != OptionType.VOID) {
- help
- .append("=<")
- .append(env.getType().name().toLowerCase(Locale.ROOT))
- .append('>');
-
- }
- }
+ final StringBuilder help =
+ new StringBuilder(mvnHelp).append(lineSeparator).append("mvnd specific options:");
+
+ Environment.documentedEntries().forEach(entry -> {
+ final Environment env = entry.getEntry();
+ help.append(lineSeparator);
+ int indentPos = help.length() + indent.length();
+ int lineEnd = help.length() + terminalWidth;
+ spaces(help, HelpFormatter.DEFAULT_LEFT_PAD);
+ final String property = env.getProperty();
+ if (property != null) {
+ help.append("-D").append(property);
+ if (env.getType() != OptionType.VOID) {
+ help.append("=<")
+ .append(env.getType().name().toLowerCase(Locale.ROOT))
+ .append('>');
+ }
+ }
- final Set<String> opts = env.getOptions();
- if (!opts.isEmpty()) {
- if (property != null) {
- help.append(';');
- }
- boolean first = true;
- for (String opt : opts) {
- if (first) {
- first = false;
- } else {
- help.append(',');
- }
- help.append(opt);
- }
- if (env.getType() != OptionType.VOID) {
- help
- .append(" <")
- .append(env.getType().name().toLowerCase(Locale.ROOT))
- .append('>');
- }
+ final Set<String> opts = env.getOptions();
+ if (!opts.isEmpty()) {
+ if (property != null) {
+ help.append(';');
+ }
+ boolean first = true;
+ for (String opt : opts) {
+ if (first) {
+ first = false;
+ } else {
+ help.append(',');
}
- help.append(' ');
-
- spaces(help, indentPos - help.length());
- wrap(help, toPlainText(entry.getJavaDoc()), terminalWidth, lineEnd, indent);
+ help.append(opt);
+ }
+ if (env.getType() != OptionType.VOID) {
+ help.append(" <")
+ .append(env.getType().name().toLowerCase(Locale.ROOT))
+ .append('>');
+ }
+ }
+ help.append(' ');
- indentedLine(help, terminalWidth, "Default", env.getDefault(), indent);
- indentedLine(help, terminalWidth, "Env. variable", env.getEnvironmentVariable(), indent);
+ spaces(help, indentPos - help.length());
+ wrap(help, toPlainText(entry.getJavaDoc()), terminalWidth, lineEnd, indent);
- });
+ indentedLine(help, terminalWidth, "Default", env.getDefault(), indent);
+ indentedLine(help, terminalWidth, "Env. variable", env.getEnvironmentVariable(), indent);
+ });
- help
- .append(lineSeparator)
- .append(lineSeparator)
- .append("mvnd value types:");
+ help.append(lineSeparator).append(lineSeparator).append("mvnd value types:");
- OptionType.documentedEntries()
- .forEach(entry -> {
- final OptionType type = entry.getEntry();
- help.append(lineSeparator);
- int indentPos = help.length() + indent.length();
- int lineEnd = help.length() + terminalWidth;
- spaces(help, HelpFormatter.DEFAULT_LEFT_PAD);
- help.append(type.name().toLowerCase(Locale.ROOT));
- spaces(help, indentPos - help.length());
- wrap(help, toPlainText(entry.getJavaDoc()), terminalWidth, lineEnd, indent);
- });
+ OptionType.documentedEntries().forEach(entry -> {
+ final OptionType type = entry.getEntry();
+ help.append(lineSeparator);
+ int indentPos = help.length() + indent.length();
+ int lineEnd = help.length() + terminalWidth;
+ spaces(help, HelpFormatter.DEFAULT_LEFT_PAD);
+ help.append(type.name().toLowerCase(Locale.ROOT));
+ spaces(help, indentPos - help.length());
+ wrap(help, toPlainText(entry.getJavaDoc()), terminalWidth, lineEnd, indent);
+ });
return help.toString();
}
@@ -151,13 +150,12 @@ public class MvndHelpFormatter {
return terminalWidth;
}
- private static void indentedLine(StringBuilder stringBuilder, int terminalWidth, String key, String value, String indent) {
+ private static void indentedLine(
+ StringBuilder stringBuilder, int terminalWidth, String key, String value, String indent) {
int lineEnd;
if (value != null) {
lineEnd = stringBuilder.length() + terminalWidth;
- stringBuilder
- .append(System.lineSeparator())
- .append(indent);
+ stringBuilder.append(System.lineSeparator()).append(indent);
wrap(stringBuilder, key + ": " + value, terminalWidth, lineEnd, indent);
}
}
@@ -187,10 +185,7 @@ public class MvndHelpFormatter {
} else {
nextLineEnd = stringBuilder.length() + lineLength;
- stringBuilder
- .append(System.lineSeparator())
- .append(indent)
- .append(token);
+ stringBuilder.append(System.lineSeparator()).append(indent).append(token);
}
lastWs = null;
}
@@ -210,5 +205,4 @@ public class MvndHelpFormatter {
}
return stringBuilder;
}
-
}
diff --git a/daemon/src/main/java/org/apache/maven/project/CachingProjectBuilder.java b/daemon/src/main/java/org/apache/maven/project/CachingProjectBuilder.java
index 9a919db4..bf3725d6 100644
--- a/daemon/src/main/java/org/apache/maven/project/CachingProjectBuilder.java
+++ b/daemon/src/main/java/org/apache/maven/project/CachingProjectBuilder.java
@@ -7,7 +7,7 @@
* "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
@@ -88,8 +88,7 @@ import org.eclipse.sisu.Typed;
@Singleton
@Typed(ProjectBuilder.class)
@Priority(10)
-public class CachingProjectBuilder
- implements ProjectBuilder {
+public class CachingProjectBuilder implements ProjectBuilder {
@Inject
private Logger logger;
@@ -117,25 +116,24 @@ public class CachingProjectBuilder
private final ModelCache modelCache = new ReactorModelCache();
- public CachingProjectBuilder() {
- }
+ public CachingProjectBuilder() {}
// ----------------------------------------------------------------------
// MavenProjectBuilder Implementation
// ----------------------------------------------------------------------
@Override
- public ProjectBuildingResult build(File pomFile, ProjectBuildingRequest request)
- throws ProjectBuildingException {
- return build(pomFile, new FileModelSource(pomFile),
+ public ProjectBuildingResult build(File pomFile, ProjectBuildingRequest request) throws ProjectBuildingException {
+ return build(
+ pomFile,
+ new FileModelSource(pomFile),
new InternalConfig(request, null, new SnapshotModelCache(getModelCache())));
}
@Override
public ProjectBuildingResult build(ModelSource modelSource, ProjectBuildingRequest request)
throws ProjectBuildingException {
- return build(null, modelSource,
- new InternalConfig(request, null, new SnapshotModelCache(getModelCache())));
+ return build(null, modelSource, new InternalConfig(request, null, new SnapshotModelCache(getModelCache())));
}
private ProjectBuildingResult build(File pomFile, ModelSource modelSource, InternalConfig config)
@@ -156,8 +154,8 @@ public class CachingProjectBuilder
project = new MavenProject();
project.setFile(pomFile);
- DefaultModelBuildingListener listener = new DefaultModelBuildingListener(project, projectBuildingHelper,
- projectBuildingRequest);
+ DefaultModelBuildingListener listener =
+ new DefaultModelBuildingListener(project, projectBuildingHelper, projectBuildingRequest);
request.setModelBuildingListener(listener);
request.setPomFile(pomFile);
@@ -170,8 +168,8 @@ public class CachingProjectBuilder
} catch (ModelBuildingException e) {
result = e.getResult();
if (result == null || result.getEffectiveModel() == null) {
- throw (ProjectBuildingException) new ProjectBuildingException(e.getModelId(), e.getMessage(), pomFile)
- .initCause(e);
+ throw (ProjectBuildingException)
+ new ProjectBuildingException(e.getModelId(), e.getMessage(), pomFile).initCause(e);
}
// validation error, continue project building and delay failing to help IDEs
error = e;
@@ -179,8 +177,13 @@ public class CachingProjectBuilder
modelProblems = result.getProblems();
- initProject(project, Collections.<String, MavenProject> emptyMap(), true,
- result, new HashMap<File, Boolean>(), projectBuildingRequest);
+ initProject(
+ project,
+ Collections.<String, MavenProject>emptyMap(),
+ true,
+ result,
+ new HashMap<File, Boolean>(),
+ projectBuildingRequest);
} else if (projectBuildingRequest.isResolveDependencies()) {
projectBuildingHelper.selectProjectRealm(project);
}
@@ -217,8 +220,11 @@ public class CachingProjectBuilder
Set<Artifact> artifacts = new LinkedHashSet<>();
if (resolutionResult.getDependencyGraph() != null) {
- RepositoryUtils.toArtifacts(artifacts, resolutionResult.getDependencyGraph().getChildren(),
- Collections.singletonList(project.getArtifact().getId()), null);
+ RepositoryUtils.toArtifacts(
+ artifacts,
+ resolutionResult.getDependencyGraph().getChildren(),
+ Collections.singletonList(project.getArtifact().getId()),
+ null);
// Maven 2.x quirk: an artifact always points at the local repo, regardless whether resolved or not
LocalRepositoryManager lrm = session.getLocalRepositoryManager();
@@ -251,9 +257,14 @@ public class CachingProjectBuilder
RequestTrace trace = RequestTrace.newChild(null, configuration).newChild(request);
- ModelResolver resolver = new ProjectModelResolver(config.session, trace, repoSystem, repositoryManager,
+ ModelResolver resolver = new ProjectModelResolver(
+ config.session,
+ trace,
+ repoSystem,
+ repositoryManager,
config.repositories,
- configuration.getRepositoryMerging(), config.modelPool);
+ configuration.getRepositoryMerging(),
+ config.modelPool);
request.setValidationLevel(configuration.getValidationLevel());
request.setProcessPlugins(configuration.isProcessPlugins());
@@ -297,8 +308,8 @@ public class CachingProjectBuilder
if (e.getResults().get(0).isMissing() && allowStubModel) {
return build(null, createStubModelSource(artifact), config);
}
- throw new ProjectBuildingException(artifact.getId(),
- "Error resolving project artifact: " + e.getMessage(), e);
+ throw new ProjectBuildingException(
+ artifact.getId(), "Error resolving project artifact: " + e.getMessage(), e);
}
File pomFile = pomArtifact.getFile();
@@ -340,16 +351,23 @@ public class CachingProjectBuilder
Map<String, MavenProject> projectIndex = new HashMap<>(256);
- boolean noErrors = build(results, interimResults, projectIndex, pomFiles, new LinkedHashSet<File>(), true, recursive,
- config);
+ boolean noErrors = build(
+ results, interimResults, projectIndex, pomFiles, new LinkedHashSet<File>(), true, recursive, config);
populateReactorModelPool(modelPool, interimResults);
ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
try {
- noErrors = build(results, new ArrayList<MavenProject>(), projectIndex, interimResults, request,
- new HashMap<File, Boolean>(), config.session) && noErrors;
+ noErrors = build(
+ results,
+ new ArrayList<MavenProject>(),
+ projectIndex,
+ interimResults,
+ request,
+ new HashMap<File, Boolean>(),
+ config.session)
+ && noErrors;
} finally {
Thread.currentThread().setContextClassLoader(oldContextClassLoader);
}
@@ -362,9 +380,15 @@ public class CachingProjectBuilder
}
@SuppressWarnings("checkstyle:parameternumber")
- private boolean build(List<ProjectBuildingResult> results, List<InterimResult> interimResults,
- Map<String, MavenProject> projectIndex, List<File> pomFiles, Set<File> aggregatorFiles,
- boolean isRoot, boolean recursive, InternalConfig config) {
+ private boolean build(
+ List<ProjectBuildingResult> results,
+ List<InterimResult> interimResults,
+ Map<String, MavenProject> projectIndex,
+ List<File> pomFiles,
+ Set<File> aggregatorFiles,
+ boolean isRoot,
+ boolean recursive,
+ InternalConfig config) {
boolean noErrors = true;
for (File pomFile : pomFiles) {
@@ -381,9 +405,15 @@ public class CachingProjectBuilder
}
@SuppressWarnings("checkstyle:parameternumber")
- private boolean build(List<ProjectBuildingResult> results, List<InterimResult> interimResults,
- Map<String, MavenProject> projectIndex, File pomFile, Set<File> aggregatorFiles,
- boolean isRoot, boolean recursive, InternalConfig config) {
+ private boolean build(
+ List<ProjectBuildingResult> results,
+ List<InterimResult> interimResults,
+ Map<String, MavenProject> projectIndex,
+ File pomFile,
+ Set<File> aggregatorFiles,
+ boolean isRoot,
+ boolean recursive,
+ InternalConfig config) {
boolean noErrors = true;
ModelBuildingRequest request = getModelBuildingRequest(config);
@@ -395,8 +425,8 @@ public class CachingProjectBuilder
request.setTwoPhaseBuilding(true);
request.setLocationTracking(true);
- DefaultModelBuildingListener listener = new DefaultModelBuildingListener(project, projectBuildingHelper,
- config.request);
+ DefaultModelBuildingListener listener =
+ new DefaultModelBuildingListener(project, projectBuildingHelper, config.request);
request.setModelBuildingListener(listener);
ModelBuildingResult result;
@@ -419,8 +449,8 @@ public class CachingProjectBuilder
// first pass: build without building parent.
initProject(project, projectIndex, false, result, new HashMap<File, Boolean>(0), config.request);
} catch (InvalidArtifactRTException iarte) {
- result.getProblems().add(new DefaultModelProblem(null, ModelProblem.Severity.ERROR, null, model, -1, -1,
- iarte));
+ result.getProblems()
+ .add(new DefaultModelProblem(null, ModelProblem.Severity.ERROR, null, model, -1, -1, iarte));
}
projectIndex.put(result.getModelIds().get(0), project);
@@ -447,9 +477,14 @@ public class CachingProjectBuilder
}
if (!moduleFile.isFile()) {
- ModelProblem problem = new DefaultModelProblem("Child module " + moduleFile + " of " + pomFile
- + " does not exist", ModelProblem.Severity.ERROR, ModelProblem.Version.BASE, model, -1,
- -1, null);
+ ModelProblem problem = new DefaultModelProblem(
+ "Child module " + moduleFile + " of " + pomFile + " does not exist",
+ ModelProblem.Severity.ERROR,
+ ModelProblem.Version.BASE,
+ model,
+ -1,
+ -1,
+ null);
result.getProblems().add(problem);
noErrors = false;
@@ -475,9 +510,14 @@ public class CachingProjectBuilder
}
buffer.append(moduleFile);
- ModelProblem problem = new DefaultModelProblem("Child module " + moduleFile + " of " + pomFile
- + " forms aggregation cycle " + buffer, ModelProblem.Severity.ERROR,
- ModelProblem.Version.BASE, model, -1, -1, null);
+ ModelProblem problem = new DefaultModelProblem(
+ "Child module " + moduleFile + " of " + pomFile + " forms aggregation cycle " + buffer,
+ ModelProblem.Severity.ERROR,
+ ModelProblem.Version.BASE,
+ model,
+ -1,
+ -1,
+ null);
result.getProblems().add(problem);
noErrors = false;
@@ -490,8 +530,15 @@ public class CachingProjectBuilder
interimResult.modules = new ArrayList<>();
- if (!build(results, interimResult.modules, projectIndex, moduleFiles, aggregatorFiles, false,
- recursive, config)) {
+ if (!build(
+ results,
+ interimResult.modules,
+ projectIndex,
+ moduleFiles,
+ aggregatorFiles,
+ false,
+ recursive,
+ config)) {
noErrors = false;
}
}
@@ -513,15 +560,18 @@ public class CachingProjectBuilder
List<InterimResult> modules = Collections.emptyList();
- InterimResult(File pomFile, ModelBuildingRequest request, ModelBuildingResult result,
- DefaultModelBuildingListener listener, boolean root) {
+ InterimResult(
+ File pomFile,
+ ModelBuildingRequest request,
+ ModelBuildingResult result,
+ DefaultModelBuildingListener listener,
+ boolean root) {
this.pomFile = pomFile;
this.request = request;
this.result = result;
this.listener = listener;
this.root = root;
}
-
}
private void populateReactorModelPool(ReactorModelPool reactorModelPool, List<InterimResult> interimResults) {
@@ -533,9 +583,13 @@ public class CachingProjectBuilder
}
}
- private boolean build(List<ProjectBuildingResult> results, List<MavenProject> projects,
- Map<String, MavenProject> projectIndex, List<InterimResult> interimResults,
- ProjectBuildingRequest request, Map<File, Boolean> profilesXmls,
+ private boolean build(
+ List<ProjectBuildingResult> results,
+ List<MavenProject> projects,
+ Map<String, MavenProject> projectIndex,
+ List<InterimResult> interimResults,
+ ProjectBuildingRequest request,
+ Map<File, Boolean> profilesXmls,
RepositorySystemSession session) {
boolean noErrors = true;
@@ -548,8 +602,15 @@ public class CachingProjectBuilder
try {
initProject(project, projectIndex, true, result, profilesXmls, request);
} catch (InvalidArtifactRTException iarte) {
- result.getProblems().add(new DefaultModelProblem(null, ModelProblem.Severity.ERROR, null,
- result.getEffectiveModel(), -1, -1, iarte));
+ result.getProblems()
+ .add(new DefaultModelProblem(
+ null,
+ ModelProblem.Severity.ERROR,
+ null,
+ result.getEffectiveModel(),
+ -1,
+ -1,
+ iarte));
}
List<MavenProject> modules = new ArrayList<>();
@@ -584,9 +645,13 @@ public class CachingProjectBuilder
}
@SuppressWarnings("checkstyle:methodlength")
- private void initProject(MavenProject project, Map<String, MavenProject> projects,
- boolean buildParentIfNotExisting, ModelBuildingResult result,
- Map<File, Boolean> profilesXmls, ProjectBuildingRequest projectBuildingRequest) {
+ private void initProject(
+ MavenProject project,
+ Map<String, MavenProject> projects,
+ boolean buildParentIfNotExisting,
+ ModelBuildingResult result,
+ Map<File, Boolean> profilesXmls,
+ ProjectBuildingRequest projectBuildingRequest) {
Model model = result.getEffectiveModel();
project.setModel(model);
@@ -595,9 +660,8 @@ public class CachingProjectBuilder
initParent(project, projects, buildParentIfNotExisting, result, projectBuildingRequest);
- Artifact projectArtifact = repositorySystem.createArtifact(project.getGroupId(), project.getArtifactId(),
- project.getVersion(), null,
- project.getPackaging());
+ Artifact projectArtifact = repositorySystem.createArtifact(
+ project.getGroupId(), project.getArtifactId(), project.getVersion(), null, project.getPackaging());
project.setArtifact(projectArtifact);
if (project.getFile() != null && buildParentIfNotExisting) // only set those on 2nd phase, ignore on 1st pass
@@ -620,9 +684,15 @@ public class CachingProjectBuilder
String modelId = findProfilesXml(result, profilesXmls);
if (modelId != null) {
- ModelProblem problem = new DefaultModelProblem("Detected profiles.xml alongside " + modelId
- + ", this file is no longer supported and was ignored" + ", please use the settings.xml instead",
- ModelProblem.Severity.WARNING, ModelProblem.Version.V30, model, -1, -1, null);
+ ModelProblem problem = new DefaultModelProblem(
+ "Detected profiles.xml alongside " + modelId + ", this file is no longer supported and was ignored"
+ + ", please use the settings.xml instead",
+ ModelProblem.Severity.WARNING,
+ ModelProblem.Version.V30,
+ model,
+ -1,
+ -1,
+ null);
result.getProblems().add(problem);
}
@@ -671,8 +741,8 @@ public class CachingProjectBuilder
version = ext.getVersion();
}
- Artifact artifact = repositorySystem.createArtifact(ext.getGroupId(), ext.getArtifactId(), version, null,
- "jar");
+ Artifact artifact =
+ repositorySystem.createArtifact(ext.getGroupId(), ext.getArtifactId(), version, null, "jar");
if (artifact != null) {
extensionArtifacts.add(artifact);
@@ -685,7 +755,8 @@ public class CachingProjectBuilder
Map<String, Artifact> map = null;
if (repositorySystem != null) {
final DependencyManagement dependencyManagement = project.getDependencyManagement();
- if ((dependencyManagement != null) && ((dependencyManagement.getDependencies()) != null)
+ if ((dependencyManagement != null)
+ && ((dependencyManagement.getDependencies()) != null)
&& (dependencyManagement.getDependencies().size() > 0)) {
map = new AbstractMap<String, Artifact>() {
HashMap<String, Artifact> delegate;
@@ -748,15 +819,14 @@ public class CachingProjectBuilder
DeploymentRepository r = project.getDistributionManagement().getRepository();
if (!StringUtils.isEmpty(r.getId()) && !StringUtils.isEmpty(r.getUrl())) {
ArtifactRepository repo = repositorySystem.buildArtifactRepository(r);
- repositorySystem.injectProxy(projectBuildingRequest.getRepositorySession(),
- Arrays.asList(repo));
- repositorySystem.injectAuthentication(projectBuildingRequest.getRepositorySession(),
- Arrays.asList(repo));
+ repositorySystem.injectProxy(projectBuildingRequest.getRepositorySession(), Arrays.asList(repo));
+ repositorySystem.injectAuthentication(
+ projectBuildingRequest.getRepositorySession(), Arrays.asList(repo));
project.setReleaseArtifactRepository(repo);
}
} catch (InvalidRepositoryException e) {
- throw new IllegalStateException("Failed to create release distribution repository for "
- + project.getId(), e);
+ throw new IllegalStateException(
+ "Failed to create release distribution repository for " + project.getId(), e);
}
}
@@ -767,32 +837,35 @@ public class CachingProjectBuilder
DeploymentRepository r = project.getDistributionManagement().getSnapshotRepository();
if (!StringUtils.isEmpty(r.getId()) && !StringUtils.isEmpty(r.getUrl())) {
ArtifactRepository repo = repositorySystem.buildArtifactRepository(r);
- repositorySystem.injectProxy(projectBuildingRequest.getRepositorySession(),
- Arrays.asList(repo));
- repositorySystem.injectAuthentication(projectBuildingRequest.getRepositorySession(),
- Arrays.asList(repo));
+ repositorySystem.injectProxy(projectBuildingRequest.getRepositorySession(), Arrays.asList(repo));
+ repositorySystem.injectAuthentication(
+ projectBuildingRequest.getRepositorySession(), Arrays.asList(repo));
project.setSnapshotArtifactRepository(repo);
}
} catch (InvalidRepositoryException e) {
- throw new IllegalStateException("Failed to create snapshot distribution repository for "
- + project.getId(), e);
+ throw new IllegalStateException(
+ "Failed to create snapshot distribution repository for " + project.getId(), e);
}
}
}
- private void initParent(MavenProject project, Map<String, MavenProject> projects, boolean buildParentIfNotExisting,
- ModelBuildingResult result, ProjectBuildingRequest projectBuildingRequest) {
- Model parentModel = result.getModelIds().size() > 1 && !result.getModelIds().get(1).isEmpty()
- ? result.getRawModel(result.getModelIds().get(1))
- : null;
+ private void initParent(
+ MavenProject project,
+ Map<String, MavenProject> projects,
+ boolean buildParentIfNotExisting,
+ ModelBuildingResult result,
+ ProjectBuildingRequest projectBuildingRequest) {
+ Model parentModel =
+ result.getModelIds().size() > 1 && !result.getModelIds().get(1).isEmpty()
+ ? result.getRawModel(result.getModelIds().get(1))
+ : null;
if (parentModel != null) {
final String parentGroupId = inheritedGroupId(result, 1);
final String parentVersion = inheritedVersion(result, 1);
- project.setParentArtifact(repositorySystem.createProjectArtifact(parentGroupId,
- parentModel.getArtifactId(),
- parentVersion));
+ project.setParentArtifact(
+ repositorySystem.createProjectArtifact(parentGroupId, parentModel.getArtifactId(), parentVersion));
// org.apache.maven.its.mng4834:parent:0.1
String parentModelId = result.getModelIds().get(1);
@@ -848,10 +921,7 @@ public class CachingProjectBuilder
if (!modelId.isEmpty()) {
final Model model = result.getRawModel(modelId);
- groupId = model.getGroupId() != null
- ? model.getGroupId()
- : inheritedGroupId(result, modelIndex + 1);
-
+ groupId = model.getGroupId() != null ? model.getGroupId() : inheritedGroupId(result, modelIndex + 1);
}
return groupId;
@@ -863,10 +933,7 @@ public class CachingProjectBuilder
if (!modelId.isEmpty()) {
final Model model = result.getRawModel(modelId);
- version = model.getVersion() != null
- ? model.getVersion()
- : inheritedVersion(result, modelIndex + 1);
-
+ version = model.getVersion() != null ? model.getVersion() : inheritedVersion(result, modelIndex + 1);
}
return version;
@@ -913,15 +980,13 @@ public class CachingProjectBuilder
this.request = request;
this.modelPool = modelPool;
this.modelCache = modelCache;
- session = LegacyLocalRepositoryManager.overlay(request.getLocalRepository(), request.getRepositorySession(),
- repoSystem);
+ session = LegacyLocalRepositoryManager.overlay(
+ request.getLocalRepository(), request.getRepositorySession(), repoSystem);
repositories = RepositoryUtils.toRepos(request.getRemoteRepositories());
}
-
}
private ModelCache getModelCache() {
return this.modelCache;
}
-
}
diff --git a/daemon/src/main/java/org/apache/maven/project/SnapshotModelCache.java b/daemon/src/main/java/org/apache/maven/project/SnapshotModelCache.java
index b4aee747..1809097d 100644
--- a/daemon/src/main/java/org/apache/maven/project/SnapshotModelCache.java
+++ b/daemon/src/main/java/org/apache/maven/project/SnapshotModelCache.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.project;
@@ -38,7 +41,6 @@ public class SnapshotModelCache implements ModelCache {
}
private ModelCache getDelegate(String version) {
- return version.contains("SNAPSHOT") || version.contains("${")
- ? reactorCache : globalCache;
+ return version.contains("SNAPSHOT") || version.contains("${") ? reactorCache : globalCache;
}
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/builder/DependencyGraph.java b/daemon/src/main/java/org/mvndaemon/mvnd/builder/DependencyGraph.java
index 19baf211..a8d7ad2f 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/builder/DependencyGraph.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/builder/DependencyGraph.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2017 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.builder;
@@ -54,10 +57,10 @@ public class DependencyGraph<K> {
static DependencyGraph<MavenProject> fromMaven(ProjectDependencyGraph graph) {
final List<MavenProject> projects = graph.getSortedProjects();
- Map<MavenProject, List<MavenProject>> upstreams = projects.stream()
- .collect(Collectors.toMap(p -> p, p -> graph.getUpstreamProjects(p, false)));
- Map<MavenProject, List<MavenProject>> downstreams = projects.stream()
- .collect(Collectors.toMap(p -> p, p -> graph.getDownstreamProjects(p, false)));
+ Map<MavenProject, List<MavenProject>> upstreams =
+ projects.stream().collect(Collectors.toMap(p -> p, p -> graph.getUpstreamProjects(p, false)));
+ Map<MavenProject, List<MavenProject>> downstreams =
+ projects.stream().collect(Collectors.toMap(p -> p, p -> graph.getDownstreamProjects(p, false)));
return new DependencyGraph<>(Collections.unmodifiableList(projects), upstreams, downstreams);
}
@@ -70,7 +73,10 @@ public class DependencyGraph<K> {
projects.forEach(this::transitiveUpstreams); // topological ordering of projects matters
}
- DependencyGraph(List<K> projects, Map<K, List<K>> upstreams, Map<K, List<K>> downstreams,
+ DependencyGraph(
+ List<K> projects,
+ Map<K, List<K>> upstreams,
+ Map<K, List<K>> downstreams,
Map<K, Set<K>> transitiveUpstreams) {
this.projects = projects;
this.upstreams = upstreams;
@@ -138,29 +144,20 @@ public class DependencyGraph<K> {
@Override
public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (getClass() != obj.getClass()) return false;
@SuppressWarnings("unchecked")
DependencyGraph<K> other = (DependencyGraph<K>) obj;
if (downstreams == null) {
- if (other.downstreams != null)
- return false;
- } else if (!downstreams.equals(other.downstreams))
- return false;
+ if (other.downstreams != null) return false;
+ } else if (!downstreams.equals(other.downstreams)) return false;
if (projects == null) {
- if (other.projects != null)
- return false;
- } else if (!projects.equals(other.projects))
- return false;
+ if (other.projects != null) return false;
+ } else if (!projects.equals(other.projects)) return false;
if (upstreams == null) {
- if (other.upstreams != null)
- return false;
- } else if (!upstreams.equals(other.upstreams))
- return false;
+ if (other.upstreams != null) return false;
+ } else if (!upstreams.equals(other.upstreams)) return false;
return true;
}
@@ -207,16 +204,21 @@ public class DependencyGraph<K> {
newNodeUpstreams = new ArrayList<>(oldNodeUpstreams);
} else if (oldNodeUpstreams.size() == 1) {
newNodeUpstreams = new ArrayList<>(oldNodeUpstreams);
- newDownstreams.computeIfAbsent(newNodeUpstreams.get(0), k -> new ArrayList<>()).add(node);
+ newDownstreams
+ .computeIfAbsent(newNodeUpstreams.get(0), k -> new ArrayList<>())
+ .add(node);
} else {
newNodeUpstreams = new ArrayList<>(oldNodeUpstreams.size());
for (K leftNode : oldNodeUpstreams) {
if (oldNodeUpstreams.stream()
.filter(rightNode -> leftNode != rightNode)
- .noneMatch(rightNode -> transitiveUpstreams.get(rightNode).contains(leftNode))) {
+ .noneMatch(rightNode ->
+ transitiveUpstreams.get(rightNode).contains(leftNode))) {
newNodeUpstreams.add(leftNode);
- newDownstreams.computeIfAbsent(leftNode, k -> new ArrayList<>()).add(node);
+ newDownstreams
+ .computeIfAbsent(leftNode, k -> new ArrayList<>())
+ .add(node);
}
}
}
@@ -237,9 +239,7 @@ public class DependencyGraph<K> {
if (result == null) {
final List<K> firstOrderUpstreams = this.upstreams.get(node);
result = new HashSet<>(firstOrderUpstreams);
- firstOrderUpstreams.stream()
- .map(this::transitiveUpstreams)
- .forEach(result::addAll);
+ firstOrderUpstreams.stream().map(this::transitiveUpstreams).forEach(result::addAll);
transitiveUpstreams.put(node, result);
}
return result;
@@ -269,10 +269,7 @@ public class DependencyGraph<K> {
graph.transitiveUpstreams.forEach((k, ups) -> {
mapByUpstreams.computeIfAbsent(ups, n -> new HashSet<>()).add(k);
});
- max = mapByUpstreams.values().stream()
- .mapToInt(Set::size)
- .max()
- .orElse(0);
+ max = mapByUpstreams.values().stream().mapToInt(Set::size).max().orElse(0);
if (max >= maxmax) {
return maxmax;
}
@@ -316,22 +313,17 @@ public class DependencyGraph<K> {
}
private List<K> getRoots() {
- return graph.getProjects()
- .filter(graph::isRoot)
- .collect(Collectors.toList());
+ return graph.getProjects().filter(graph::isRoot).collect(Collectors.toList());
}
List<K> ensembleWithChildrenOf(List<K> list, K node) {
final List<K> result = Stream.concat(
- list.stream().filter(k -> !Objects.equals(k, node)),
- graph.getDownstreamProjects(node)
- .filter(k -> graph.transitiveUpstreams.get(k)
- .stream()
+ list.stream().filter(k -> !Objects.equals(k, node)),
+ graph.getDownstreamProjects(node).filter(k -> graph.transitiveUpstreams.get(k).stream()
.noneMatch(k2 -> !Objects.equals(k2, node) && list.contains(k2))))
- .distinct().collect(Collectors.toList());
+ .distinct()
+ .collect(Collectors.toList());
return result;
}
-
}
-
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/builder/ProjectComparator.java b/daemon/src/main/java/org/mvndaemon/mvnd/builder/ProjectComparator.java
index 956932a7..fee21ce0 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/builder/ProjectComparator.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/builder/ProjectComparator.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2014 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.builder;
@@ -55,7 +58,8 @@ class ProjectComparator {
return create0(graph, Collections.emptyMap(), ProjectComparator::id);
}
- static <K> Comparator<K> create0(DependencyGraph<K> dependencyGraph,
+ static <K> Comparator<K> create0(
+ DependencyGraph<K> dependencyGraph,
Map<String, AtomicLong> historicalServiceTimes,
Function<K, String> toKey) {
final long defaultServiceTime = average(historicalServiceTimes.values());
@@ -79,18 +83,18 @@ class ProjectComparator {
}
private static long average(Collection<AtomicLong> values) {
- return (long) (values.stream().mapToLong(AtomicLong::longValue)
- .average().orElse(1.0d));
+ return (long)
+ (values.stream().mapToLong(AtomicLong::longValue).average().orElse(1.0d));
}
- private static <K> long getServiceTime(Map<String, AtomicLong> serviceTimes, K project,
- long defaultServiceTime, Function<K, String> toKey) {
+ private static <K> long getServiceTime(
+ Map<String, AtomicLong> serviceTimes, K project, long defaultServiceTime, Function<K, String> toKey) {
AtomicLong serviceTime = serviceTimes.get(toKey.apply(project));
return serviceTime != null ? serviceTime.longValue() : defaultServiceTime;
}
- private static <K> Map<K, Long> calculateWeights(DependencyGraph<K> dependencyGraph,
- Map<K, Long> serviceTimes, Collection<K> rootProjects) {
+ private static <K> Map<K, Long> calculateWeights(
+ DependencyGraph<K> dependencyGraph, Map<K, Long> serviceTimes, Collection<K> rootProjects) {
Map<K, Long> weights = new HashMap<>();
for (K rootProject : rootProjects) {
calculateWeights(dependencyGraph, serviceTimes, rootProject, weights);
@@ -102,10 +106,11 @@ class ProjectComparator {
* Returns the maximum sum of build time along a path from the project to an exit project. An
* "exit project" is a project without downstream dependencies.
*/
- private static <K> long calculateWeights(DependencyGraph<K> dependencyGraph,
- Map<K, Long> serviceTimes, K project, Map<K, Long> weights) {
+ private static <K> long calculateWeights(
+ DependencyGraph<K> dependencyGraph, Map<K, Long> serviceTimes, K project, Map<K, Long> weights) {
long weight = serviceTimes.get(project)
- + dependencyGraph.getDownstreamProjects(project)
+ + dependencyGraph
+ .getDownstreamProjects(project)
.mapToLong(successor -> {
long successorWeight;
if (weights.containsKey(successor)) {
@@ -115,15 +120,13 @@ class ProjectComparator {
}
return successorWeight;
})
- .max().orElse(0);
+ .max()
+ .orElse(0);
weights.put(project, weight);
return weight;
}
static String id(MavenProject project) {
- return project.getGroupId() +
- ':' + project.getArtifactId() +
- ':' + project.getVersion();
+ return project.getGroupId() + ':' + project.getArtifactId() + ':' + project.getVersion();
}
-
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/builder/ProjectExecutorService.java b/daemon/src/main/java/org/mvndaemon/mvnd/builder/ProjectExecutorService.java
index 63b9710a..58f56f0b 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/builder/ProjectExecutorService.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/builder/ProjectExecutorService.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2014 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.builder;
@@ -44,36 +47,35 @@ class ProjectExecutorService {
private final BlockingQueue<Future<MavenProject>> completion = new LinkedBlockingQueue<>();
private final Comparator<Runnable> taskComparator;
- public ProjectExecutorService(final int degreeOfConcurrency,
- final Comparator<MavenProject> projectComparator) {
+ public ProjectExecutorService(final int degreeOfConcurrency, final Comparator<MavenProject> projectComparator) {
- this.taskComparator = Comparator.comparing(
- r -> ((ProjectRunnable) r).getProject(), projectComparator);
+ this.taskComparator = Comparator.comparing(r -> ((ProjectRunnable) r).getProject(), projectComparator);
- final BlockingQueue<Runnable> executorWorkQueue = new PriorityBlockingQueue<>(degreeOfConcurrency, taskComparator);
+ final BlockingQueue<Runnable> executorWorkQueue =
+ new PriorityBlockingQueue<>(degreeOfConcurrency, taskComparator);
- executor = new ThreadPoolExecutor(degreeOfConcurrency, // corePoolSize
- degreeOfConcurrency, // maximumPoolSize
- 0L, TimeUnit.MILLISECONDS, // keepAliveTime, unit
- executorWorkQueue, // workQueue
- new BuildThreadFactory() // threadFactory
- ) {
+ executor =
+ new ThreadPoolExecutor(
+ degreeOfConcurrency, // corePoolSize
+ degreeOfConcurrency, // maximumPoolSize
+ 0L,
+ TimeUnit.MILLISECONDS, // keepAliveTime, unit
+ executorWorkQueue, // workQueue
+ new BuildThreadFactory() // threadFactory
+ ) {
- @Override
- protected void beforeExecute(Thread t, Runnable r) {
- ProjectExecutorService.this.beforeExecute(t, r);
- }
- };
+ @Override
+ protected void beforeExecute(Thread t, Runnable r) {
+ ProjectExecutorService.this.beforeExecute(t, r);
+ }
+ };
}
public void submitAll(final Collection<? extends ProjectRunnable> tasks) {
// when there are available worker threads, tasks are immediately executed, i.e. bypassed the
// ordered queued. need to sort tasks, such that submission order matches desired execution
// order
- tasks.stream()
- .sorted(taskComparator)
- .map(ProjectFutureTask::new)
- .forEach(executor::execute);
+ tasks.stream().sorted(taskComparator).map(ProjectFutureTask::new).forEach(executor::execute);
}
/**
@@ -93,8 +95,7 @@ class ProjectExecutorService {
}
// hook to allow pausing executor during unit tests
- protected void beforeExecute(Thread t, Runnable r) {
- }
+ protected void beforeExecute(Thread t, Runnable r) {}
// for testing purposes only
public void awaitShutdown() throws InterruptedException {
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/builder/ReactorBuildQueue.java b/daemon/src/main/java/org/mvndaemon/mvnd/builder/ReactorBuildQueue.java
index 69ecaeeb..d4c289b3 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/builder/ReactorBuildQueue.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/builder/ReactorBuildQueue.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2014 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.builder;
@@ -43,8 +46,7 @@ class ReactorBuildQueue {
private final Set<MavenProject> finishedProjects;
- public ReactorBuildQueue(Collection<MavenProject> projects,
- DependencyGraph<MavenProject> graph) {
+ public ReactorBuildQueue(Collection<MavenProject> projects, DependencyGraph<MavenProject> graph) {
this.graph = graph;
this.projects = new HashSet<>();
this.rootProjects = new HashSet<>();
@@ -116,5 +118,4 @@ class ReactorBuildQueue {
projects.removeAll(finishedProjects);
return projects;
}
-
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/builder/ReactorBuildStats.java b/daemon/src/main/java/org/mvndaemon/mvnd/builder/ReactorBuildStats.java
index 4c8e9d08..18d660be 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/builder/ReactorBuildStats.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/builder/ReactorBuildStats.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2017 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.builder;
@@ -47,11 +50,11 @@ class ReactorBuildStats {
* structure prevented higher degree of parallelism.
*/
private final Map<String, AtomicLong> bottleneckTimes;
+
private long startTime;
private long stopTime;
- private ReactorBuildStats(Map<String, AtomicLong> serviceTimes,
- Map<String, AtomicLong> bottleneckTimes) {
+ private ReactorBuildStats(Map<String, AtomicLong> serviceTimes, Map<String, AtomicLong> bottleneckTimes) {
this.serviceTimes = ImmutableMap.copyOf(serviceTimes);
this.bottleneckTimes = ImmutableMap.copyOf(bottleneckTimes);
}
@@ -81,13 +84,13 @@ class ReactorBuildStats {
public void recordServiceTime(MavenProject project, long durationNanos) {
AtomicLong serviceTime = serviceTimes.get(projectGAV(project));
if (serviceTime == null) {
- throw new IllegalStateException("Unknown project " + projectGAV(project) + ", found " + serviceTimes.keySet());
+ throw new IllegalStateException(
+ "Unknown project " + projectGAV(project) + ", found " + serviceTimes.keySet());
}
serviceTime.addAndGet(durationNanos);
}
- public void recordBottlenecks(Set<MavenProject> projects, int degreeOfConcurrency,
- long durationNanos) {
+ public void recordBottlenecks(Set<MavenProject> projects, int degreeOfConcurrency, long durationNanos) {
// only projects that result in single-threaded builds
if (projects.size() == 1) {
projects.forEach(p -> bottleneckTimes.get(projectGAV(p)).addAndGet(durationNanos));
@@ -99,7 +102,8 @@ class ReactorBuildStats {
//
public long totalServiceTime(TimeUnit unit) {
- long nanos = serviceTimes.values().stream().mapToLong(AtomicLong::longValue).sum();
+ long nanos =
+ serviceTimes.values().stream().mapToLong(AtomicLong::longValue).sum();
return unit.convert(nanos, TimeUnit.NANOSECONDS);
}
@@ -124,8 +128,8 @@ class ReactorBuildStats {
criticalPathServiceTime += serviceTimes.get(key).get();
appendProjectTimes(result, key);
}
- result.append(String.format("\nBuild critical path total service time %s",
- formatDuration(criticalPathServiceTime)));
+ result.append(
+ String.format("\nBuild critical path total service time %s", formatDuration(criticalPathServiceTime)));
// render bottleneck projects
@@ -138,8 +142,7 @@ class ReactorBuildStats {
bottleneckTotalTime += bottleneckTimes.get(bottleneck).get();
appendProjectTimes(result, bottleneck);
}
- result.append(
- String.format("\nBuild bottlenecks total time %s", formatDuration(bottleneckTotalTime)));
+ result.append(String.format("\nBuild bottlenecks total time %s", formatDuration(bottleneckTotalTime)));
}
result.append("\n** Bottlenecks are projects that limit build concurrency");
@@ -192,5 +195,4 @@ class ReactorBuildStats {
private <K> K getCriticalProject(Stream<K> projects, Comparator<K> comparator) {
return projects.min(comparator).orElse(null);
}
-
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/builder/SmartBuilder.java b/daemon/src/main/java/org/mvndaemon/mvnd/builder/SmartBuilder.java
index c5f61aa3..f6410f6f 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/builder/SmartBuilder.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/builder/SmartBuilder.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2014 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.builder;
@@ -86,25 +89,31 @@ public class SmartBuilder implements Builder {
}
@Override
- public synchronized void build(final MavenSession session, final ReactorContext reactorContext,
- ProjectBuildList projectBuilds, final List<TaskSegment> taskSegments,
- ReactorBuildStatus reactorBuildStatus) throws ExecutionException, InterruptedException {
+ public synchronized void build(
+ final MavenSession session,
+ final ReactorContext reactorContext,
+ ProjectBuildList projectBuilds,
+ final List<TaskSegment> taskSegments,
+ ReactorBuildStatus reactorBuildStatus)
+ throws ExecutionException, InterruptedException {
session.getRepositorySession().getData().set(ReactorBuildStatus.class, reactorBuildStatus);
- DependencyGraph<MavenProject> graph = (DependencyGraph<MavenProject>) session.getRequest().getData()
- .get(DependencyGraph.class.getName());
+ DependencyGraph<MavenProject> graph =
+ (DependencyGraph<MavenProject>) session.getRequest().getData().get(DependencyGraph.class.getName());
// log overall build info
final int degreeOfConcurrency = session.getRequest().getDegreeOfConcurrency();
- logger.info("Task segments : " + taskSegments.stream().map(Object::toString).collect(Collectors.joining(" ")));
+ logger.info(
+ "Task segments : " + taskSegments.stream().map(Object::toString).collect(Collectors.joining(" ")));
logger.info("Build maximum degree of concurrency is " + degreeOfConcurrency);
logger.info("Total number of projects is " + session.getProjects().size());
// the actual build execution
List<Map.Entry<TaskSegment, ReactorBuildStats>> allstats = new ArrayList<>();
for (TaskSegment taskSegment : taskSegments) {
- Set<MavenProject> projects = projectBuilds.getByTaskSegment(taskSegment).getProjects();
+ Set<MavenProject> projects =
+ projectBuilds.getByTaskSegment(taskSegment).getProjects();
if (canceled) {
return;
}
@@ -126,7 +135,8 @@ public class SmartBuilder implements Builder {
for (Map.Entry<TaskSegment, ReactorBuildStats> entry : allstats) {
TaskSegment taskSegment = entry.getKey();
ReactorBuildStats stats = entry.getValue();
- Set<MavenProject> projects = projectBuilds.getByTaskSegment(taskSegment).getProjects();
+ Set<MavenProject> projects =
+ projectBuilds.getByTaskSegment(taskSegment).getProjects();
logger.debug("Task segment {}, number of projects {}", taskSegment, projects.size());
@@ -136,7 +146,8 @@ public class SmartBuilder implements Builder {
logger.info(
"Segment walltime {} s, segment projects service time {} s, effective/maximum degree of concurrency {}/{}",
TimeUnit.NANOSECONDS.toSeconds(walltimeReactor),
- TimeUnit.NANOSECONDS.toSeconds(walltimeService), effectiveConcurrency,
+ TimeUnit.NANOSECONDS.toSeconds(walltimeService),
+ effectiveConcurrency,
degreeOfConcurrency);
if (projects.size() > 1 && isProfiling(session)) {
@@ -152,5 +163,4 @@ public class SmartBuilder implements Builder {
}
return Boolean.parseBoolean(value);
}
-
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/builder/SmartBuilderImpl.java b/daemon/src/main/java/org/mvndaemon/mvnd/builder/SmartBuilderImpl.java
index 5a32d097..027a66e3 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/builder/SmartBuilderImpl.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/builder/SmartBuilderImpl.java
@@ -1,16 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.mvndaemon.mvnd.builder;
@@ -61,9 +65,13 @@ class SmartBuilderImpl {
//
private final ReactorBuildStats stats;
- SmartBuilderImpl(LifecycleModuleBuilder lifecycleModuleBuilder, MavenSession session,
- ReactorContext reactorContext, TaskSegment taskSegment,
- Set<MavenProject> projects, DependencyGraph<MavenProject> graph) {
+ SmartBuilderImpl(
+ LifecycleModuleBuilder lifecycleModuleBuilder,
+ MavenSession session,
+ ReactorContext reactorContext,
+ TaskSegment taskSegment,
+ Set<MavenProject> projects,
+ DependencyGraph<MavenProject> graph) {
this.lifecycleModuleBuilder = lifecycleModuleBuilder;
this.rootSession = session;
this.reactorContext = reactorContext;
@@ -101,8 +109,7 @@ class SmartBuilderImpl {
try {
MavenProject completedProject = executor.take();
if (bottlenecks != null) {
- stats.recordBottlenecks(bottlenecks, degreeOfConcurrency,
- System.nanoTime() - timstampSubmit);
+ stats.recordBottlenecks(bottlenecks, degreeOfConcurrency, System.nanoTime() - timstampSubmit);
}
logCompleted(completedProject);
Set<MavenProject> readyProjects = reactorBuildQueue.onProjectFinish(completedProject);
@@ -135,8 +142,12 @@ class SmartBuilderImpl {
.map(SmartBuilderImpl::projectGA)
.collect(Collectors.joining(" ", "[", "]"));
}
- logger.debug("Builder state: blocked={} finished={} ready-or-running={} {}", blockedCount,
- finishedCount, readyCount, runningProjects);
+ logger.debug(
+ "Builder state: blocked={} finished={} ready-or-running={} {}",
+ blockedCount,
+ finishedCount,
+ readyCount,
+ runningProjects);
}
private void logCompleted(MavenProject project) {
@@ -170,17 +181,15 @@ class SmartBuilderImpl {
executor.submitAll(tasks);
}
- /* package */void buildProject(MavenProject project) {
+ /* package */ void buildProject(MavenProject project) {
logger.debug("STARTED build of project {}:{}", project.getGroupId(), project.getArtifactId());
try {
MavenSession copiedSession = rootSession.clone();
- lifecycleModuleBuilder.buildProject(copiedSession, rootSession, reactorContext, project,
- taskSegment);
+ lifecycleModuleBuilder.buildProject(copiedSession, rootSession, reactorContext, project, taskSegment);
} catch (RuntimeException ex) {
// preserve the xml stack trace, and the java cause chain
- rootSession.getResult()
- .addException(new RuntimeException(project.getName() + ": " + ex.getMessage(), ex));
+ rootSession.getResult().addException(new RuntimeException(project.getName() + ": " + ex.getMessage(), ex));
}
}
@@ -206,5 +215,4 @@ class SmartBuilderImpl {
return project;
}
}
-
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/cache/Cache.java b/daemon/src/main/java/org/mvndaemon/mvnd/cache/Cache.java
index 49f90e41..dc167ac7 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/cache/Cache.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/cache/Cache.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.cache;
@@ -69,5 +72,4 @@ public interface Cache<K, V extends CacheRecord> {
* @return the existing or newly computed {@link CacheRecord}
*/
V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction);
-
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/cache/CacheFactory.java b/daemon/src/main/java/org/mvndaemon/mvnd/cache/CacheFactory.java
index 01ffa527..38c3b266 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/cache/CacheFactory.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/cache/CacheFactory.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.cache;
@@ -26,5 +29,4 @@ public interface CacheFactory {
* @return a new {@link Cache}
*/
<K, V extends CacheRecord> Cache<K, V> newCache();
-
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/cache/CacheRecord.java b/daemon/src/main/java/org/mvndaemon/mvnd/cache/CacheRecord.java
index 2cadad50..99fa9a5d 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/cache/CacheRecord.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/cache/CacheRecord.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.cache;
@@ -33,5 +36,4 @@ public interface CacheRecord {
* Callback called by the cache when this {@link CacheRecord} is removed from the cache.
*/
void invalidate();
-
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/cache/impl/DefaultCacheFactory.java b/daemon/src/main/java/org/mvndaemon/mvnd/cache/impl/DefaultCacheFactory.java
index b8cc24eb..354af14d 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/cache/impl/DefaultCacheFactory.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/cache/impl/DefaultCacheFactory.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.cache.impl;
@@ -41,5 +44,4 @@ public class DefaultCacheFactory implements CacheFactory {
public <K, V extends CacheRecord> Cache<K, V> newCache() {
return delegate.newCache();
}
-
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/cache/impl/TimestampCacheFactory.java b/daemon/src/main/java/org/mvndaemon/mvnd/cache/impl/TimestampCacheFactory.java
index ed308472..c7bf4a0a 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/cache/impl/TimestampCacheFactory.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/cache/impl/TimestampCacheFactory.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.cache.impl;
@@ -39,8 +42,7 @@ import org.mvndaemon.mvnd.cache.CacheRecord;
*/
public class TimestampCacheFactory implements CacheFactory {
- public TimestampCacheFactory() {
- }
+ public TimestampCacheFactory() {}
@Override
public <K, V extends CacheRecord> Cache<K, V> newCache() {
@@ -73,14 +75,12 @@ public class TimestampCacheFactory implements CacheFactory {
@Override
public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
FileState that = (FileState) o;
- return path.equals(that.path) &&
- Objects.equals(lastModifiedTime, that.lastModifiedTime) &&
- Objects.equals(fileKey, that.fileKey);
+ return path.equals(that.path)
+ && Objects.equals(lastModifiedTime, that.lastModifiedTime)
+ && Objects.equals(fileKey, that.fileKey);
}
@Override
@@ -92,7 +92,6 @@ public class TimestampCacheFactory implements CacheFactory {
public String toString() {
return "FileState [path=" + path + ", lastModifiedTime=" + lastModifiedTime + ", fileKey=" + fileKey + "]";
}
-
}
static class Record<V extends CacheRecord> {
@@ -110,9 +109,7 @@ public class TimestampCacheFactory implements CacheFactory {
* @return {@link Set} of {@link FileState}s at current time
*/
private Set<FileState> currentFileStates() {
- return record.getDependencyPaths()
- .map(FileState::new)
- .collect(Collectors.toSet());
+ return record.getDependencyPaths().map(FileState::new).collect(Collectors.toSet());
}
}
@@ -157,7 +154,7 @@ public class TimestampCacheFactory implements CacheFactory {
@Override
public void removeIf(BiPredicate<K, V> predicate) {
- for (Iterator<Map.Entry<K, Record<V>>> iterator = map.entrySet().iterator(); iterator.hasNext();) {
+ for (Iterator<Map.Entry<K, Record<V>>> iterator = map.entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry<K, Record<V>> entry = iterator.next();
if (predicate.test(entry.getKey(), entry.getValue().record)) {
entry.getValue().record.invalidate();
@@ -169,19 +166,20 @@ public class TimestampCacheFactory implements CacheFactory {
@Override
public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
return map.compute(key, (k, v) -> {
- if (v != null) {
- try {
- if (Objects.equals(v.fileStates, v.currentFileStates())) {
- return v;
+ if (v != null) {
+ try {
+ if (Objects.equals(v.fileStates, v.currentFileStates())) {
+ return v;
+ }
+ } catch (RuntimeException e) {
+ // ignore and invalidate the record
+ }
+ v.record.invalidate();
+ v = null;
}
- } catch (RuntimeException e) {
- // ignore and invalidate the record
- }
- v.record.invalidate();
- v = null;
- }
- return new Record<>(mappingFunction.apply(k));
- }).record;
+ return new Record<>(mappingFunction.apply(k));
+ })
+ .record;
}
}
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/cache/impl/WatchServiceCacheFactory.java b/daemon/src/main/java/org/mvndaemon/mvnd/cache/impl/WatchServiceCacheFactory.java
index 13537db5..b40c75fc 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/cache/impl/WatchServiceCacheFactory.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/cache/impl/WatchServiceCacheFactory.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.cache.impl;
@@ -93,14 +96,15 @@ public class WatchServiceCacheFactory implements CacheFactory {
try {
WatchEvent.Modifier[] mods;
try {
- mods = new WatchEvent.Modifier[] {
- com.sun.nio.file.SensitivityWatchEventModifier.HIGH
- };
+ mods = new WatchEvent.Modifier[] {com.sun.nio.file.SensitivityWatchEventModifier.HIGH};
} catch (Throwable t) {
mods = null;
}
- final WatchKey watchKey = key.register(watchService,
- new WatchEvent.Kind[] { StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY },
+ final WatchKey watchKey = key.register(
+ watchService,
+ new WatchEvent.Kind[] {
+ StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY
+ },
mods);
return new Registration(watchKey);
} catch (NoSuchFileException e) {
@@ -138,7 +142,8 @@ public class WatchServiceCacheFactory implements CacheFactory {
} else if (kind == StandardWatchEventKinds.OVERFLOW) {
/* Invalidate all records under the given dir */
LOG.debug("Got overflow event for path {}", dir);
- Iterator<Map.Entry<Path, List<CacheRecord>>> it = recordsByPath.entrySet().iterator();
+ Iterator<Map.Entry<Path, List<CacheRecord>>> it =
+ recordsByPath.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Path, List<CacheRecord>> en = it.next();
final Path path = en.getKey();
@@ -230,7 +235,7 @@ public class WatchServiceCacheFactory implements CacheFactory {
@Override
public void removeIf(BiPredicate<K, V> predicate) {
- for (Iterator<Map.Entry<K, V>> iterator = map.entrySet().iterator(); iterator.hasNext();) {
+ for (Iterator<Map.Entry<K, V>> iterator = map.entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry<K, V> entry = iterator.next();
if (predicate.test(entry.getKey(), entry.getValue())) {
entry.getValue().invalidate();
@@ -271,6 +276,5 @@ public class WatchServiceCacheFactory implements CacheFactory {
delegate.invalidate();
map.remove(key);
}
-
}
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingExtensionRealmCache.java b/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingExtensionRealmCache.java
index 534e0143..630cdc96 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingExtensionRealmCache.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingExtensionRealmCache.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.cache.invalidating;
@@ -46,7 +49,8 @@ public class InvalidatingExtensionRealmCache extends DefaultExtensionRealmCache
@Override
public Stream<Path> getDependencyPaths() {
- return record.getArtifacts().stream().map(artifact -> artifact.getFile().toPath());
+ return record.getArtifacts().stream()
+ .map(artifact -> artifact.getFile().toPath());
}
@Override
@@ -74,8 +78,8 @@ public class InvalidatingExtensionRealmCache extends DefaultExtensionRealmCache
}
@Override
- public CacheRecord put(Key key, ClassRealm extensionRealm, ExtensionDescriptor extensionDescriptor,
- List<Artifact> artifacts) {
+ public CacheRecord put(
+ Key key, ClassRealm extensionRealm, ExtensionDescriptor extensionDescriptor, List<Artifact> artifacts) {
CacheRecord record = super.put(key, extensionRealm, extensionDescriptor, artifacts);
super.cache.remove(key);
cache.put(key, new Record(record));
@@ -88,7 +92,5 @@ public class InvalidatingExtensionRealmCache extends DefaultExtensionRealmCache
}
@Override
- public void register(MavenProject project, Key key, CacheRecord record) {
- }
-
+ public void register(MavenProject project, Key key, CacheRecord record) {}
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingPluginArtifactsCache.java b/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingPluginArtifactsCache.java
index c5c83606..a5be4346 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingPluginArtifactsCache.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingPluginArtifactsCache.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.cache.invalidating;
@@ -46,12 +49,12 @@ public class InvalidatingPluginArtifactsCache extends DefaultPluginArtifactsCach
if (record.getException() != null) {
return Stream.empty();
}
- return record.getArtifacts().stream().map(artifact -> artifact.getFile().toPath());
+ return record.getArtifacts().stream()
+ .map(artifact -> artifact.getFile().toPath());
}
@Override
- public void invalidate() {
- }
+ public void invalidate() {}
}
final Cache<Key, Record> cache;
@@ -95,5 +98,4 @@ public class InvalidatingPluginArtifactsCache extends DefaultPluginArtifactsCach
public void flush() {
cache.clear();
}
-
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingPluginDescriptorCache.java b/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingPluginDescriptorCache.java
index 8641de11..fb5f4d24 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingPluginDescriptorCache.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingPluginDescriptorCache.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.cache.invalidating;
@@ -59,8 +62,8 @@ public class InvalidatingPluginDescriptorCache extends DefaultPluginDescriptorCa
@Override
public Stream<Path> getDependencyPaths() {
- return Optional.ofNullable(descriptor.getArtifacts()).orElse(Collections.emptyList())
- .stream().map(artifact -> artifact.getFile().toPath());
+ return Optional.ofNullable(descriptor.getArtifacts()).orElse(Collections.emptyList()).stream()
+ .map(artifact -> artifact.getFile().toPath());
}
@Override
@@ -98,7 +101,9 @@ public class InvalidatingPluginDescriptorCache extends DefaultPluginDescriptorCa
Record r = cache.computeIfAbsent(key, k -> {
try {
return new Record(clone(supplier.load()));
- } catch (PluginDescriptorParsingException | PluginResolutionException | InvalidPluginDescriptorException e) {
+ } catch (PluginDescriptorParsingException
+ | PluginResolutionException
+ | InvalidPluginDescriptorException e) {
throw new RuntimeException(e);
}
});
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingPluginRealmCache.java b/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingPluginRealmCache.java
index f6f22f10..6817d854 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingPluginRealmCache.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingPluginRealmCache.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.cache.invalidating;
@@ -52,7 +55,8 @@ public class InvalidatingPluginRealmCache extends DefaultPluginRealmCache {
@Override
public Stream<Path> getDependencyPaths() {
- return record.getArtifacts().stream().map(artifact -> artifact.getFile().toPath());
+ return record.getArtifacts().stream()
+ .map(artifact -> artifact.getFile().toPath());
}
@Override
@@ -115,7 +119,5 @@ public class InvalidatingPluginRealmCache extends DefaultPluginRealmCache {
}
@Override
- public void register(MavenProject project, Key key, CacheRecord record) {
- }
-
+ public void register(MavenProject project, Key key, CacheRecord record) {}
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingProjectArtifactsCache.java b/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingProjectArtifactsCache.java
index ee0531d2..70d2aae8 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingProjectArtifactsCache.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingProjectArtifactsCache.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.cache.invalidating;
@@ -47,8 +50,7 @@ import org.mvndaemon.mvnd.cache.CacheFactory;
@Priority(10)
public class InvalidatingProjectArtifactsCache extends DefaultProjectArtifactsCache {
- protected static class CacheKey
- implements Key {
+ protected static class CacheKey implements Key {
private final String groupId;
@@ -72,8 +74,12 @@ public class InvalidatingProjectArtifactsCache extends DefaultProjectArtifactsCa
private final int hashCode;
- public CacheKey(MavenProject project, List<RemoteRepository> repositories,
- Collection<String> scopesToCollect, Collection<String> scopesToResolve, boolean aggregating,
+ public CacheKey(
+ MavenProject project,
+ List<RemoteRepository> repositories,
+ Collection<String> scopesToCollect,
+ Collection<String> scopesToResolve,
+ boolean aggregating,
RepositorySystemSession session) {
groupId = project.getGroupId();
@@ -99,10 +105,10 @@ public class InvalidatingProjectArtifactsCache extends DefaultProjectArtifactsCa
}
}
collect = scopesToCollect == null
- ? Collections.<String> emptySet()
+ ? Collections.<String>emptySet()
: Collections.unmodifiableSet(new HashSet<>(scopesToCollect));
resolve = scopesToResolve == null
- ? Collections.<String> emptySet()
+ ? Collections.<String>emptySet()
: Collections.unmodifiableSet(new HashSet<>(scopesToResolve));
this.aggregating = aggregating;
@@ -148,7 +154,8 @@ public class InvalidatingProjectArtifactsCache extends DefaultProjectArtifactsCa
CacheKey that = (CacheKey) o;
- return Objects.equals(groupId, that.groupId) && Objects.equals(artifactId, that.artifactId)
+ return Objects.equals(groupId, that.groupId)
+ && Objects.equals(artifactId, that.artifactId)
&& Objects.equals(version, that.version)
&& Objects.equals(dependencyArtifacts, that.dependencyArtifacts)
&& Objects.equals(workspace, that.workspace)
@@ -179,8 +186,7 @@ public class InvalidatingProjectArtifactsCache extends DefaultProjectArtifactsCa
}
@Override
- public void invalidate() {
- }
+ public void invalidate() {}
}
final Cache<Key, Record> cache;
@@ -191,10 +197,19 @@ public class InvalidatingProjectArtifactsCache extends DefaultProjectArtifactsCa
}
@Override
- public Key createKey(MavenProject project, Collection<String> scopesToCollect, Collection<String> scopesToResolve,
- boolean aggregating, RepositorySystemSession session) {
- return new CacheKey(project, project.getRemoteProjectRepositories(), scopesToCollect, scopesToResolve,
- aggregating, session);
+ public Key createKey(
+ MavenProject project,
+ Collection<String> scopesToCollect,
+ Collection<String> scopesToResolve,
+ boolean aggregating,
+ RepositorySystemSession session) {
+ return new CacheKey(
+ project,
+ project.getRemoteProjectRepositories(),
+ scopesToCollect,
+ scopesToResolve,
+ aggregating,
+ session);
}
@Override
@@ -231,6 +246,5 @@ public class InvalidatingProjectArtifactsCache extends DefaultProjectArtifactsCa
}
@Override
- public void register(MavenProject project, Key cacheKey, CacheRecord record) {
- }
+ public void register(MavenProject project, Key cacheKey, CacheRecord record) {}
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingRealmCacheEventSpy.java b/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingRealmCacheEventSpy.java
index fda2d6b1..40c90ec5 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingRealmCacheEventSpy.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/cache/invalidating/InvalidatingRealmCacheEventSpy.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2020 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.cache.invalidating;
@@ -65,8 +68,11 @@ public class InvalidatingRealmCacheEventSpy extends AbstractEventSpy {
try {
if (event instanceof MavenExecutionRequest) {
/* Store the multiModuleProjectDirectory path */
- multiModuleProjectDirectory = ((MavenExecutionRequest) event).getMultiModuleProjectDirectory().toPath();
- pattern = Environment.MVND_PLUGIN_REALM_EVICT_PATTERN.asOptional()
+ multiModuleProjectDirectory = ((MavenExecutionRequest) event)
+ .getMultiModuleProjectDirectory()
+ .toPath();
+ pattern = Environment.MVND_PLUGIN_REALM_EVICT_PATTERN
+ .asOptional()
.orElse(Environment.MVND_PLUGIN_REALM_EVICT_PATTERN.getDefault());
if (!pattern.isEmpty()) {
String[] patterns = pattern.split(",");
@@ -104,15 +110,17 @@ public class InvalidatingRealmCacheEventSpy extends AbstractEventSpy {
extensionCache.cache.removeIf(this::shouldEvict);
MavenExecutionResult mer = (MavenExecutionResult) event;
List<MavenProject> projects = mer.getTopologicallySortedProjects();
- projectArtifactsCache.cache
- .removeIf((k, r) -> shouldEvict(projects, (InvalidatingProjectArtifactsCache.CacheKey) k, r));
+ projectArtifactsCache.cache.removeIf(
+ (k, r) -> shouldEvict(projects, (InvalidatingProjectArtifactsCache.CacheKey) k, r));
}
} catch (Exception e) {
LOG.warn("Could not notify CliPluginRealmCache", e);
}
}
- private boolean shouldEvict(List<MavenProject> projects, InvalidatingProjectArtifactsCache.CacheKey k,
+ private boolean shouldEvict(
+ List<MavenProject> projects,
+ InvalidatingProjectArtifactsCache.CacheKey k,
InvalidatingProjectArtifactsCache.Record v) {
return projects.stream().anyMatch(p -> k.matches(p.getGroupId(), p.getArtifactId(), p.getVersion()));
}
@@ -125,12 +133,15 @@ public class InvalidatingRealmCacheEventSpy extends AbstractEventSpy {
if (path.startsWith(multiModuleProjectDirectory)) {
LOG.debug(
"Removing PluginRealmCache entry {} because it refers to an artifact in the build tree {}",
- k, path);
+ k,
+ path);
return true;
} else if (matcher != null && matcher.matches(path)) {
LOG.debug(
"Removing PluginRealmCache entry {} because its components {} matches the eviction pattern '{}'",
- k, path, pattern);
+ k,
+ path,
+ pattern);
return true;
}
}
@@ -149,12 +160,15 @@ public class InvalidatingRealmCacheEventSpy extends AbstractEventSpy {
if (path.startsWith(multiModuleProjectDirectory)) {
LOG.debug(
"Removing ExtensionRealmCache entry {} because it refers to an artifact in the build tree {}",
- k, path);
+ k,
+ path);
return true;
} else if (matcher != null && matcher.matches(path)) {
LOG.debug(
"Removing ExtensionRealmCache entry {} because its components {} matches the eviction pattern '{}'",
- k, path, pattern);
+ k,
+ path,
+ pattern);
return true;
}
}
@@ -171,5 +185,4 @@ public class InvalidatingRealmCacheEventSpy extends AbstractEventSpy {
}
return FileSystems.getDefault().getPathMatcher(pattern);
}
-
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/cli/EnvHelper.java b/daemon/src/main/java/org/mvndaemon/mvnd/cli/EnvHelper.java
index 90896341..766b9bb4 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/cli/EnvHelper.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/cli/EnvHelper.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2021 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.cli;
@@ -40,8 +43,7 @@ public class EnvHelper {
private static final Logger LOGGER = LoggerFactory.getLogger(EnvHelper.class);
- private EnvHelper() {
- }
+ private EnvHelper() {}
public static void environment(String workingDir, Map<String, String> clientEnv) {
environment(workingDir, clientEnv, LOGGER::warn);
@@ -82,8 +84,9 @@ public class EnvHelper {
diffs.forEach(key -> {
String vr = requested.get(key);
String va = nactual.get(key);
- log.accept(String.format(" %s -> %s instead of %s", key,
- va != null ? "'" + va + "'" : "<null>", vr != null ? "'" + vr + "'" : "<null>"));
+ log.accept(String.format(
+ " %s -> %s instead of %s",
+ key, va != null ? "'" + va + "'" : "<null>", vr != null ? "'" + vr + "'" : "<null>"));
});
log.accept("If the difference matters to you, stop the running daemons using mvnd --stop and");
log.accept("start a new daemon from the current environment by issuing any mvnd build command.");
@@ -157,8 +160,8 @@ public class EnvHelper {
// OpenJDK 8-17 on Windows
if (Os.current() == Os.WINDOWS) {
Class<?> processEnvironmentClass = Class.forName("java.lang.ProcessEnvironment");
- Field theCaseInsensitiveEnvironmentField = processEnvironmentClass
- .getDeclaredField("theCaseInsensitiveEnvironment");
+ Field theCaseInsensitiveEnvironmentField =
+ processEnvironmentClass.getDeclaredField("theCaseInsensitiveEnvironment");
theCaseInsensitiveEnvironmentField.setAccessible(true);
Map<String, String> cienv = (Map<String, String>) theCaseInsensitiveEnvironmentField.get(null);
cienv.clear();
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/daemon/ClientDispatcher.java b/daemon/src/main/java/org/mvndaemon/mvnd/daemon/ClientDispatcher.java
index 0fce8af4..eda1c5cd 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/daemon/ClientDispatcher.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/daemon/ClientDispatcher.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2019 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.daemon;
@@ -52,10 +55,14 @@ public class ClientDispatcher extends BuildEventListener {
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);
+ final int maxThreads =
+ degreeOfConcurrency == 1 ? 1 : dependencyGraph.computeMaxWidth(degreeOfConcurrency, 1000);
final List<MavenProject> projects = session.getProjects();
final int _90thArtifactIdLengthPercentile = artifactIdLength90thPercentile(projects);
- queue.add(new BuildStarted(getCurrentProject(session).getArtifactId(), projects.size(), maxThreads,
+ queue.add(new BuildStarted(
+ getCurrentProject(session).getArtifactId(),
+ projects.size(),
+ maxThreads,
_90thArtifactIdLengthPercentile));
}
@@ -65,7 +72,8 @@ public class ClientDispatcher extends BuildEventListener {
}
Map<Integer, Integer> frequencyDistribution = new TreeMap<>();
for (MavenProject p : projects) {
- frequencyDistribution.compute(p.getArtifactId().length(),
+ frequencyDistribution.compute(
+ p.getArtifactId().length(),
(k, v) -> (v == null) ? Integer.valueOf(1) : Integer.valueOf(v.intValue() + 1));
}
int _90PercCount = Math.round(0.9f * projects.size());
@@ -76,7 +84,8 @@ public class ClientDispatcher extends BuildEventListener {
return en.getKey().intValue();
}
}
- throw new IllegalStateException("Could not compute the 90th percentile of the projects length from " + projects);
+ throw new IllegalStateException(
+ "Could not compute the 90th percentile of the projects length from " + projects);
}
private final Map<String, Boolean> projects = new ConcurrentHashMap<>();
@@ -89,10 +98,12 @@ public class ClientDispatcher extends BuildEventListener {
public void projectLogMessage(String projectId, String event) {
if (projectId != null) {
Boolean b = projects.get(projectId);
- if (b != Boolean.TRUE) {
- }
+ if (b != Boolean.TRUE) {}
}
- queue.add(projectId == null ? Message.log(trimTrailingEols(event)) : Message.log(projectId, trimTrailingEols(event)));
+ queue.add(
+ projectId == null
+ ? Message.log(trimTrailingEols(event))
+ : Message.log(projectId, trimTrailingEols(event)));
}
@Override
@@ -134,40 +145,41 @@ public class ClientDispatcher extends BuildEventListener {
public void transfer(String projectId, TransferEvent e) {
final int event;
switch (e.getType()) {
- case INITIATED:
- event = Message.TRANSFER_INITIATED;
- break;
- case STARTED:
- event = Message.TRANSFER_STARTED;
- break;
- case PROGRESSED:
- event = Message.TRANSFER_PROGRESSED;
- break;
- case CORRUPTED:
- event = Message.TRANSFER_CORRUPTED;
- break;
- case SUCCEEDED:
- event = Message.TRANSFER_SUCCEEDED;
- break;
- case FAILED:
- event = Message.TRANSFER_FAILED;
- break;
- default:
- throw new IllegalStateException("Unexpected " + EventType.class.getSimpleName() + ": " + e.getType());
+ case INITIATED:
+ event = Message.TRANSFER_INITIATED;
+ break;
+ case STARTED:
+ event = Message.TRANSFER_STARTED;
+ break;
+ case PROGRESSED:
+ event = Message.TRANSFER_PROGRESSED;
+ break;
+ case CORRUPTED:
+ event = Message.TRANSFER_CORRUPTED;
+ break;
+ case SUCCEEDED:
+ event = Message.TRANSFER_SUCCEEDED;
+ break;
+ case FAILED:
+ event = Message.TRANSFER_FAILED;
+ break;
+ default:
+ throw new IllegalStateException("Unexpected " + EventType.class.getSimpleName() + ": " + e.getType());
}
final int requestType;
switch (e.getRequestType()) {
- case GET:
- requestType = Message.TransferEvent.GET;
- break;
- case GET_EXISTENCE:
- requestType = Message.TransferEvent.GET_EXISTENCE;
- break;
- case PUT:
- requestType = Message.TransferEvent.PUT;
- break;
- default:
- throw new IllegalStateException("Unexpected " + RequestType.class.getSimpleName() + ": " + e.getRequestType());
+ case GET:
+ requestType = Message.TransferEvent.GET;
+ break;
+ case GET_EXISTENCE:
+ requestType = Message.TransferEvent.GET_EXISTENCE;
+ break;
+ case PUT:
+ requestType = Message.TransferEvent.PUT;
+ break;
+ default:
+ throw new IllegalStateException(
+ "Unexpected " + RequestType.class.getSimpleName() + ": " + e.getRequestType());
}
String repositoryId = e.getResource().getRepositoryId();
String repositoryUrl = e.getResource().getRepositoryUrl();
@@ -175,8 +187,16 @@ public class ClientDispatcher extends BuildEventListener {
long contentLength = e.getResource().getContentLength();
long transferredBytes = e.getTransferredBytes();
String exception = e.getException() != null ? e.getException().toString() : null;
- queue.add(Message.transfer(projectId, event, requestType, repositoryId, repositoryUrl, resourceName,
- contentLength, transferredBytes, exception));
+ queue.add(Message.transfer(
+ projectId,
+ event,
+ requestType,
+ repositoryId,
+ repositoryUrl,
+ resourceName,
+ contentLength,
+ transferredBytes,
+ exception));
}
private MavenProject getCurrentProject(MavenSession mavenSession) {
@@ -187,7 +207,8 @@ public class ClientDispatcher extends BuildEventListener {
return mavenSession.getCurrentProject();
}
return mavenSession.getProjects().stream()
- .filter(p -> (p.getFile() != null && executionRootDirectory.equals(p.getFile().getParent())))
+ .filter(p -> (p.getFile() != null
+ && executionRootDirectory.equals(p.getFile().getParent())))
.findFirst()
.orElse(mavenSession.getCurrentProject());
}
@@ -195,5 +216,4 @@ public class ClientDispatcher extends BuildEventListener {
static String trimTrailingEols(String message) {
return message == null ? null : TRAILING_EOLS_PATTERN.matcher(message).replaceFirst("");
}
-
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/daemon/Connection.java b/daemon/src/main/java/org/mvndaemon/mvnd/daemon/Connection.java
index 44cea49c..08929367 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/daemon/Connection.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/daemon/Connection.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2020 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.daemon;
@@ -35,5 +38,4 @@ public interface Connection {
class Holder {
static Connection CURRENT;
}
-
}
diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/daemon/DaemonExpiration.java b/daemon/src/main/java/org/mvndaemon/mvnd/daemon/DaemonExpiration.java
index d47de8de..ed293f62 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/daemon/DaemonExpiration.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/daemon/DaemonExpiration.java
@@ -1,20 +1,29 @@
/*
- * Copyright 2016 the original author or authors.
+ * 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
*
- * 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
*
- * 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.
+ * 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.mvndaemon.mvnd.daemon;
+import static org.mvndaemon.mvnd.common.DaemonExpirationStatus.DO_NOT_EXPIRE;
+import static org.mvndaemon.mvnd.common.DaemonExpirationStatus.GRACEFUL_EXPIRE;
+import static org.mvndaemon.mvnd.common.DaemonExpirationStatus.IMMEDIATE_EXPIRE;
+import static org.mvndaemon.mvnd.common.DaemonExpirationStatus.QUIET_EXPIRE;
+import static org.mvndaemon.mvnd.daemon.DaemonExpiration.DaemonExpirationResult.NOT_TRIGGERED;
+
import java.lang.management.ManagementFactory;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -40,12 +49,6 @@ import org.mvndaemon.mvnd.common.Os;
import org.mvndaemon.mvnd.common.TimeUtils;
import org.mvndaemon.mvnd.nativ.CLibrary;
-import static org.mvndaemon.mvnd.common.DaemonExpirationStatus.DO_NOT_EXPIRE;
-import static org.mvndaemon.mvnd.common.DaemonExpirationStatus.GRACEFUL_EXPIRE;
-import static org.mvndaemon.mvnd.common.DaemonExpirationStatus.IMMEDIATE_EXPIRE;
-import static org.mvndaemon.mvnd.common.DaemonExpirationStatus.QUIET_EXPIRE;
-import static org.mvndaemon.mvnd.daemon.DaemonExpiration.DaemonExpirationResult.NOT_TRIGGERED;
-
/**
* File origin:
* https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/server/MasterExpirationStrategy.java
@@ -55,7 +58,6 @@ public class DaemonExpiration {
public interface DaemonExpirationStrategy {
DaemonExpirationResult checkExpiration(Server daemon);
-
}
public static DaemonExpirationStrategy master() {
@@ -112,11 +114,11 @@ public class DaemonExpiration {
... 8130 lines suppressed ...