├── .github ├── dependabot.yml └── workflows │ └── ci.yml ├── .gitignore ├── .mvn └── wrapper │ └── maven-wrapper.properties ├── LICENSE ├── README.md ├── it ├── pom.xml ├── toolbox-cli-its │ ├── pom.xml │ └── src │ │ └── it │ │ ├── classpath-1 │ │ └── it.groovy │ │ ├── dm-tree-1 │ │ └── it.groovy │ │ ├── dump-1 │ │ └── it.groovy │ │ ├── exists-1 │ │ └── it.groovy │ │ ├── help-1 │ │ └── it.groovy │ │ ├── identify-1 │ │ └── it.groovy │ │ ├── identify-2 │ │ ├── aopalliance-1.0.jar │ │ └── it.groovy │ │ └── libyear-1 │ │ └── it.groovy └── toolbox-plugin-its │ ├── pom.xml │ └── src │ └── it │ ├── dependency-versions │ ├── expected-pom.xml │ ├── invoker.properties │ ├── my-repo │ │ └── org │ │ │ └── maveniverse │ │ │ └── maven │ │ │ └── toolbox │ │ │ └── it │ │ │ └── versions │ │ │ ├── first │ │ │ └── maven-metadata.xml │ │ │ ├── fourth │ │ │ └── maven-metadata.xml │ │ │ ├── second │ │ │ └── maven-metadata.xml │ │ │ └── third │ │ │ └── maven-metadata.xml │ ├── pom.xml │ └── verify.groovy │ ├── gav-classpath-1 │ ├── invoker.properties │ ├── pom.xml │ └── verify.groovy │ ├── gav-dm-tree-1 │ ├── invoker.properties │ ├── pom.xml │ └── verify.groovy │ ├── gav-dump-1 │ ├── invoker.properties │ ├── pom.xml │ └── verify.groovy │ ├── gav-exists-1 │ ├── invoker.properties │ ├── pom.xml │ └── verify.groovy │ ├── gav-identify-1 │ ├── invoker.properties │ ├── pom.xml.off │ └── verify.groovy │ ├── gav-identify-2 │ ├── aopalliance-1.0.jar │ ├── invoker.properties │ ├── pom.xml.off │ └── verify.groovy │ ├── gav-libyear-1 │ ├── invoker.properties │ ├── pom.xml │ └── verify.groovy │ ├── help │ ├── invoker.properties │ ├── pom.xml │ └── verify.groovy │ ├── libyear-1 │ ├── invoker.properties │ ├── pom.xml │ └── verify.groovy │ ├── lock-plugin-versions │ ├── invoker.properties │ ├── pom.xml │ └── verify.groovy │ ├── plugin-versions │ ├── expected-pom.xml │ ├── invoker.properties │ ├── my-repo │ │ └── org │ │ │ └── maveniverse │ │ │ └── maven │ │ │ └── toolbox │ │ │ └── it │ │ │ └── versions │ │ │ ├── first │ │ │ └── maven-metadata.xml │ │ │ ├── fourth │ │ │ └── maven-metadata.xml │ │ │ ├── second │ │ │ └── maven-metadata.xml │ │ │ └── third │ │ │ └── maven-metadata.xml │ ├── pom.xml │ └── verify.groovy │ ├── set-version │ ├── expected-pom.xml │ ├── invoker.properties │ ├── pom.xml │ └── verify.groovy │ ├── settings.xml │ └── versions │ ├── .mvn │ ├── expected-extensions.xml │ └── extensions.xml │ ├── expected-pom.xml │ ├── invoker.properties │ ├── my-repo │ └── org │ │ └── maveniverse │ │ └── maven │ │ └── toolbox │ │ └── it │ │ └── versions │ │ ├── fifth │ │ ├── 1.0 │ │ │ ├── fifth-1.0.jar │ │ │ └── fifth-1.0.pom │ │ ├── 1.1 │ │ │ ├── fifth-1.1.jar │ │ │ └── fifth-1.1.pom │ │ └── maven-metadata-local.xml │ │ ├── first │ │ └── maven-metadata-local.xml │ │ ├── fourth │ │ └── maven-metadata-local.xml │ │ ├── second │ │ └── maven-metadata-local.xml │ │ ├── sixth │ │ ├── 1.0 │ │ │ ├── sixth-1.0.jar │ │ │ └── sixth-1.0.pom │ │ ├── 1.1 │ │ │ ├── sixth-1.1.jar │ │ │ └── sixth-1.1.pom │ │ └── maven-metadata-local.xml │ │ └── third │ │ └── maven-metadata-local.xml │ ├── pom.xml │ └── verify.groovy ├── mvnsh ├── pom.xml └── src │ └── main │ └── java │ └── eu │ └── maveniverse │ └── maven │ └── toolbox │ └── plugin │ └── mvnsh │ └── ToolboxShellCommandRegistryFactory.java ├── mvnw ├── mvnw.cmd ├── pom.xml ├── shared ├── pom.xml └── src │ ├── main │ └── java │ │ └── eu │ │ └── maveniverse │ │ └── maven │ │ └── toolbox │ │ └── shared │ │ ├── ArtifactMapper.java │ │ ├── ArtifactMatcher.java │ │ ├── ArtifactNameMapper.java │ │ ├── ArtifactRecorder.java │ │ ├── ArtifactVersionMatcher.java │ │ ├── ArtifactVersionSelector.java │ │ ├── DependencyMapper.java │ │ ├── DependencyMatcher.java │ │ ├── FileUtils.java │ │ ├── ProjectArtifacts.java │ │ ├── ProjectLocator.java │ │ ├── ReactorLocator.java │ │ ├── ResolutionRoot.java │ │ ├── ResolutionScope.java │ │ ├── Result.java │ │ ├── Sink.java │ │ ├── Source.java │ │ ├── ToolboxCommando.java │ │ ├── ToolboxCommandoVersion.java │ │ ├── ToolboxResolver.java │ │ ├── ToolboxSearchApi.java │ │ ├── internal │ │ ├── ArtifactRecorderImpl.java │ │ ├── ArtifactSinks.java │ │ ├── ArtifactSources.java │ │ ├── Artifacts.java │ │ ├── Dependencies.java │ │ ├── DependencyGraphDecorators.java │ │ ├── DependencyGraphDumper.java │ │ ├── DependencySinks.java │ │ ├── DeployingSink.java │ │ ├── DirectorySink.java │ │ ├── DirectorySource.java │ │ ├── ExtensionsSuppliers.java │ │ ├── ExtensionsTransformerSink.java │ │ ├── IndexFileReader.java │ │ ├── IndexFileWriter.java │ │ ├── InstallingSink.java │ │ ├── Java11HttpClientFactory.java │ │ ├── LevelDependencySelector.java │ │ ├── LibYearSink.java │ │ ├── LocalRepositorySource.java │ │ ├── ModuleDescriptorExtractingSink.java │ │ ├── MultiArtifactSink.java │ │ ├── PomSuppliers.java │ │ ├── PomTransformerSink.java │ │ ├── ProjectLocatorImpl.java │ │ ├── PurgingSink.java │ │ ├── SpecParser.java │ │ ├── ToolboxCommandoImpl.java │ │ ├── ToolboxResolverImpl.java │ │ ├── ToolboxSearchApiImpl.java │ │ ├── UnpackSink.java │ │ └── jdom │ │ │ ├── JDomCfg.java │ │ │ ├── JDomContentHelper.java │ │ │ ├── JDomDocumentIO.java │ │ │ ├── JDomExtensionsCfg.java │ │ │ ├── JDomExtensionsEditor.java │ │ │ ├── JDomExtensionsSource.java │ │ │ ├── JDomExtensionsTransformer.java │ │ │ ├── JDomPomCfg.java │ │ │ ├── JDomPomCleanupHelper.java │ │ │ ├── JDomPomEditor.java │ │ │ ├── JDomPomTransformer.java │ │ │ ├── JDomTransformationContext.java │ │ │ ├── JDomUtils.java │ │ │ └── package-info.java │ │ ├── io │ │ ├── IOConsumer.java │ │ └── IOSupplier.java │ │ └── output │ │ ├── AnsiOutput.java │ │ ├── LoggerOutput.java │ │ ├── Marker.java │ │ ├── NopOutput.java │ │ ├── Output.java │ │ ├── OutputSupport.java │ │ └── PrintStreamOutput.java │ └── test │ └── java │ └── eu │ └── maveniverse │ └── maven │ └── toolbox │ └── shared │ ├── ArtifactMapperTest.java │ ├── ArtifactMatcherTest.java │ ├── ArtifactNameMapperTest.java │ ├── ArtifactVersionMatcherTest.java │ ├── ArtifactVersionSelectorTest.java │ ├── DependencyMatcherTest.java │ └── internal │ ├── ArtifactSinksTest.java │ ├── DirectorySinkTest.java │ ├── IndexFileTest.java │ ├── SpecParserTest.java │ ├── ToolboxCommandoImplTest.java │ └── jdom │ └── JDomPomEditorTest.java └── toolbox ├── pom.xml └── src └── main ├── java └── eu │ └── maveniverse │ └── maven │ └── toolbox │ └── plugin │ ├── CLI.java │ ├── CwdAware.java │ ├── GavMojoSupport.java │ ├── GavSearchMojoSupport.java │ ├── MPMojoSupport.java │ ├── MPPluginMojoSupport.java │ ├── MavenReactorLocator.java │ ├── MojoSupport.java │ ├── OutputFactory.java │ ├── gav │ ├── GavArtifactPathMojo.java │ ├── GavClasspathMojo.java │ ├── GavCopyGavMojo.java │ ├── GavCopyMojo.java │ ├── GavCopyRecordedMojo.java │ ├── GavCopyTransitiveMojo.java │ ├── GavDeployMojo.java │ ├── GavDeployRecordedMojo.java │ ├── GavDirtyTreeMojo.java │ ├── GavDmListMojo.java │ ├── GavDmTreeMojo.java │ ├── GavDumpMojo.java │ ├── GavEffectiveModelMojo.java │ ├── GavExistsMojo.java │ ├── GavFlattenBomMojo.java │ ├── GavIdentifyMojo.java │ ├── GavInstallMojo.java │ ├── GavLibYearMojo.java │ ├── GavListAvailablePluginsMojo.java │ ├── GavListMojo.java │ ├── GavListRepositoriesMojo.java │ ├── GavLocalRepositoryPathMojo.java │ ├── GavMetadataPathMojo.java │ ├── GavRecordMojo.java │ ├── GavReplMojo.java │ ├── GavResolveMojo.java │ ├── GavResolveTransitiveMojo.java │ ├── GavSearchMojo.java │ ├── GavTreeMojo.java │ ├── GavVerifyMojo.java │ ├── GavVersionsMojo.java │ └── package-info.java │ ├── hello │ ├── AddCoreExtension.java │ ├── AddManagedDependency.java │ ├── AddManagedPlugin.java │ ├── HelloMojoSupport.java │ ├── HelloProjectMojoSupport.java │ ├── NewProject.java │ ├── NewSubProject.java │ ├── RemoveCoreExtension.java │ └── package-info.java │ └── mp │ ├── CheckExclusionsMojo.java │ ├── ClasspathMojo.java │ ├── CopyDependenciesMojo.java │ ├── CopyTransitiveMojo.java │ ├── CoreExtensionVersionsMojo.java │ ├── DependencyVersionsMojo.java │ ├── DirtyTreeMojo.java │ ├── DmListMojo.java │ ├── DmTreeMojo.java │ ├── DumpMojo.java │ ├── EffectiveModelAggregatorMojo.java │ ├── EffectiveModelMojo.java │ ├── ExtensionVersionsMojo.java │ ├── LibYearMojo.java │ ├── ListRepositoriesMojo.java │ ├── LockPluginVersionsMojo.java │ ├── ParentChildTreeMojo.java │ ├── PluginClasspathMojo.java │ ├── PluginLibYearMojo.java │ ├── PluginListRepositoriesMojo.java │ ├── PluginResolveMojo.java │ ├── PluginResolveTransitiveMojo.java │ ├── PluginTreeFindMojo.java │ ├── PluginTreeMojo.java │ ├── PluginVersionsMojo.java │ ├── ProjectDependencyTreeMojo.java │ ├── ResolveMojo.java │ ├── ResolveTransitiveMojo.java │ ├── SetVersionMojo.java │ ├── SubprojectTreeMojo.java │ ├── TreeFindMojo.java │ ├── TreeMojo.java │ ├── VersionsMojo.java │ └── package-info.java └── resources └── simplelogger.properties /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | 4 | - package-ecosystem: "maven" 5 | directory: "/" 6 | schedule: 7 | interval: "daily" 8 | 9 | - package-ecosystem: "github-actions" 10 | directory: "/" 11 | schedule: 12 | interval: "daily" 13 | 14 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | jobs: 10 | build: 11 | name: Verify 12 | uses: maveniverse/parent/.github/workflows/ci.yml@release-38 13 | with: 14 | jdk-matrix: '[ "11", "17", "21", "24" ]' 15 | maven-matrix: '[ "3.9.9", "4.0.0-rc-3" ]' 16 | maven-test: './mvnw clean verify -e -B -V -P run-its -f it' 17 | 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .project 3 | .settings/ 4 | target/ 5 | *.ser 6 | *.ec 7 | *.ipr 8 | *.iml 9 | *.iws 10 | .idea/ 11 | .DS_Store 12 | build.rc 13 | pom.xml.tag 14 | pom.xml.releaseBackup 15 | pom.xml.versionsBackup 16 | pom.xml.next 17 | release.properties 18 | dependency-reduced-pom.xml 19 | buildNumber.properties 20 | .mvn/timing.properties 21 | 22 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Toolbox 2 | 3 | Toolbox is a multi-faceted (CLI and Maven Plugin) utility that contains useful commands and also showcase usage 4 | of [Maveniverse MIMA](https://github.com/maveniverse/mima). 5 | 6 | ## About the project 7 | 8 | The Toolbox project started with manifold aims: 9 | * replace `MIMA CLI`, provide drop-in replacement, but also continue improving it. 10 | * provide alternative for `maven-dependency-plugin`, offering similar (sub)set of Mojos 11 | * showcase MIMA, demonstrate how it helps to write reusable Resolver code that runs embedded in Maven (as Mojos or Extensions), but also outside of Maven as CLI 12 | * to experiment: was birthplace of Resolver 2.x `ScopeManager` (that is now part of Resolver 2.x, while Resolver 1.x circumvention is present in Toolbox that supports Maven 3.6+), fixing MNG-8041 13 | 14 | ## Usage 15 | 16 | Usage: use the help command/mojo to get help about Toolbox: 17 | ``` 18 | $ mvn eu.maveniverse.maven.plugins:toolbox:help -Ddetail 19 | ``` 20 | or 21 | ``` 22 | $ jbang toolbox@maveniverse --help 23 | ``` 24 | or you can download the CLI JAR from Maven Central and run it directly. 25 | Finally, just go over sources to get the idea what is happening. 26 | 27 | To not have to type groupId of the plugin in Maven, just "toolbox", add 28 | following snippet to your `settings.xml`: 29 | 30 | ```xml 31 | 32 | eu.maveniverse.maven.plugins 33 | 34 | ``` 35 | 36 | To use mvnsh extension, add this to your `extensions.xml`: 37 | 38 | ```xml 39 | 40 | 41 | 42 | eu.maveniverse.maven.toolbox 43 | mvnsh 44 | 0.7.1 45 | 46 | 47 | ``` 48 | 49 | ## Requirements 50 | 51 | Runtime requirement: 52 | * Java 11+ (CLI and Maven Plugin) 53 | * Maven 3.6.3+ (Maven Plugin) 54 | 55 | Build requirements: 56 | * Java 21 57 | * Maven 3.9.9+ 58 | 59 | ## Project structure 60 | 61 | Structure of the project: 62 | * Subproject "shared" is a **reusable library** module, that depends on MIMA `Context` and Resolver APIs, and implements all the logic. 63 | * Subproject "toolbox" is a Maven Plugin and a CLI at the same time, that exposes Toolbox operations as Mojos and commands. Each Mojo comes in two 64 | "flavors": without prefix (i.e. "tree"), that requires project, and uses `MavenProject` to get the data for requests, and "gav-" 65 | prefixed ones (i.e. "gav-tree"), that do not require project, and is able to target any existing Artifact out there. 66 | * Subproject "mvnsh" is a Maven 4 mvnsh extension, providing Toolbox as mvnsh commands. 67 | -------------------------------------------------------------------------------- /it/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 4.0.0 13 | 14 | 15 | eu.maveniverse.maven.toolbox 16 | toolbox 17 | 0.10.2-SNAPSHOT 18 | 19 | 20 | eu.maveniverse.maven.toolbox.it 21 | it 22 | pom 23 | 24 | ${project.groupId}:${project.artifactId} 25 | 26 | 27 | toolbox-plugin-its 28 | toolbox-cli-its 29 | 30 | 31 | 32 | [8,) 33 | [3.6.3,) 34 | 35 | true 36 | true 37 | 38 | 39 | 40 | 41 | run-its 42 | 43 | 44 | 45 | 46 | com.diffplug.spotless 47 | spotless-maven-plugin 48 | 49 | 50 | check 51 | 52 | check 53 | 54 | none 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /it/toolbox-cli-its/src/it/classpath-1/it.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | 9 | StringBuilder out = new StringBuilder() 10 | StringBuilder err = new StringBuilder() 11 | String[] args = ["${java}", '-jar', "${cli}", "-e", "classpath", "eu.maveniverse.maven.toolbox:shared:${project.version}"] 12 | 13 | ProcessBuilder proc = new ProcessBuilder(args) 14 | Process process = proc.start() 15 | process.consumeProcessOutput(out, err) 16 | process.waitFor() 17 | 18 | assert out.contains("shared-${project.version}.jar") -------------------------------------------------------------------------------- /it/toolbox-cli-its/src/it/dm-tree-1/it.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | 9 | StringBuilder out = new StringBuilder() 10 | StringBuilder err = new StringBuilder() 11 | String[] args = ["${java}", '-jar', "${cli}", "-e", "dm-tree", "org.springframework.boot:spring-boot-dependencies:3.3.3"] 12 | 13 | ProcessBuilder proc = new ProcessBuilder(args) 14 | Process process = proc.start() 15 | process.consumeProcessOutput(out, err) 16 | process.waitFor() 17 | 18 | assert out.contains('DM conflicts discovered:') 19 | assert out.contains(' * org.apache.maven.plugin-tools:maven-plugin-annotations:jar version 3.11.0 prevails, but met versions [3.11.0, 3.10.2, 3.7.0]') 20 | -------------------------------------------------------------------------------- /it/toolbox-cli-its/src/it/dump-1/it.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | 9 | StringBuilder out = new StringBuilder() 10 | StringBuilder err = new StringBuilder() 11 | String[] args = ["${java}", '-jar', "${cli}", "-e", "dump", "-Dverbosity=CHATTER"] 12 | 13 | ProcessBuilder proc = new ProcessBuilder(args) 14 | Process process = proc.start() 15 | process.consumeProcessOutput(out, err) 16 | process.waitFor() 17 | 18 | assert out.contains("Toolbox ${project.version}") 19 | -------------------------------------------------------------------------------- /it/toolbox-cli-its/src/it/exists-1/it.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | 9 | StringBuilder out = new StringBuilder() 10 | StringBuilder err = new StringBuilder() 11 | // On Java 24 ANSI kicks in, so must use -B 12 | String[] args = ["${java}", '-jar', "${cli}", "exists", "-e", "-B", "org.apache.maven:maven-core:3.6.3", "--pom", "--javadoc", "--sources", "--signature", "--all-required"] 13 | 14 | ProcessBuilder proc = new ProcessBuilder(args) 15 | Process process = proc.start() 16 | process.consumeProcessOutput(out, err) 17 | process.waitFor() 18 | 19 | assert out.contains('org.apache.maven:maven-core:jar:3.6.3 EXISTS') 20 | assert out.contains('Checked TOTAL of 5 (existing: 5 not existing: 0)') 21 | -------------------------------------------------------------------------------- /it/toolbox-cli-its/src/it/help-1/it.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | 9 | StringBuilder out = new StringBuilder() 10 | StringBuilder err = new StringBuilder() 11 | String[] args = ["${java}", '-jar', "${cli}", "-e", "-h"] 12 | 13 | ProcessBuilder proc = new ProcessBuilder(args) 14 | Process process = proc.start() 15 | process.consumeProcessOutput(out, err) 16 | process.waitFor() 17 | 18 | assert out.contains('Usage: toolbox') 19 | -------------------------------------------------------------------------------- /it/toolbox-cli-its/src/it/identify-1/it.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | 9 | StringBuilder out = new StringBuilder() 10 | StringBuilder err = new StringBuilder() 11 | String[] args = ["${java}", '-jar', "${cli}", "-e", "identify", "eca800aa73e750ec9a880eb224f0bb68f5b7873b"] 12 | 13 | ProcessBuilder proc = new ProcessBuilder(args) 14 | Process process = proc.start() 15 | process.consumeProcessOutput(out, err) 16 | process.waitFor() 17 | 18 | assert out.contains('org.apache.maven:maven-core:jar:3.6.3') 19 | -------------------------------------------------------------------------------- /it/toolbox-cli-its/src/it/identify-2/aopalliance-1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maveniverse/toolbox/3528c8d7a0272217acf2eb59c5b839a3c8080749/it/toolbox-cli-its/src/it/identify-2/aopalliance-1.0.jar -------------------------------------------------------------------------------- /it/toolbox-cli-its/src/it/identify-2/it.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | 9 | StringBuilder out = new StringBuilder() 10 | StringBuilder err = new StringBuilder() 11 | String[] args = ["${java}", '-jar', "${cli}", "-e", "identify", "${itDir}/identify-2/aopalliance-1.0.jar"] 12 | 13 | ProcessBuilder proc = new ProcessBuilder(args) 14 | Process process = proc.start() 15 | process.consumeProcessOutput(out, err) 16 | process.waitFor() 17 | 18 | assert out.contains('SHA1=0235ba8b489512805ac13a8f9ea77a1ca5ebe3e8') 19 | assert out.contains('aopalliance:aopalliance:jar:1.0') 20 | -------------------------------------------------------------------------------- /it/toolbox-cli-its/src/it/libyear-1/it.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | 9 | StringBuilder out = new StringBuilder() 10 | StringBuilder err = new StringBuilder() 11 | String[] args = ["${java}", '-jar', "${cli}", "-e", "libyear", "org.junit.jupiter:junit-jupiter-api:5.10.0"] 12 | 13 | ProcessBuilder proc = new ProcessBuilder(args) 14 | Process process = proc.start() 15 | process.consumeProcessOutput(out, err) 16 | process.waitFor() 17 | 18 | assert out.contains('Outdated versions with known age') 19 | assert !out.contains('Total of 0.00 years from 0 outdated dependencies') -------------------------------------------------------------------------------- /it/toolbox-plugin-its/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 4.0.0 13 | 14 | 15 | eu.maveniverse.maven.toolbox.it 16 | it 17 | 0.10.2-SNAPSHOT 18 | 19 | 20 | toolbox-plugin-its 21 | pom 22 | 23 | ${project.groupId}:${project.artifactId} 24 | 25 | 26 | 27 | eu.maveniverse.maven.plugins 28 | toolbox 29 | 30 | 31 | 32 | 33 | 34 | run-its 35 | 36 | 37 | 38 | org.apache.maven.plugins 39 | maven-invoker-plugin 40 | 41 | ${project.build.directory}/it 42 | true 43 | 44 | */pom.xml 45 | 46 | setup 47 | verify 48 | ${project.build.directory}/local-repo 49 | src/it/settings.xml 50 | true 51 | 52 | ${project.version} 53 | 54 | 55 | 56 | 57 | integration-test 58 | 59 | install 60 | run 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/dependency-versions/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023-2024 Maveniverse Org. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v2.0 5 | # which accompanies this distribution, and is available at 6 | # https://www.eclipse.org/legal/epl-v20.html 7 | # 8 | 9 | invoker.goals = eu.maveniverse.maven.plugins:toolbox:${project.version}:dependency-versions -Dapply -e -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/dependency-versions/my-repo/org/maveniverse/maven/toolbox/it/versions/first/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | org.maveniverse.maven.toolbox.it.versions 13 | first 14 | 15 | 1.1 16 | 1.1 17 | 18 | 1.0 19 | 1.1 20 | 21 | 20241206134229 22 | 23 | 24 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/dependency-versions/my-repo/org/maveniverse/maven/toolbox/it/versions/fourth/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | org.maveniverse.maven.toolbox.it.versions 13 | fourth 14 | 15 | 1.1 16 | 1.1 17 | 18 | 1.0 19 | 1.1 20 | 21 | 20241206134229 22 | 23 | 24 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/dependency-versions/my-repo/org/maveniverse/maven/toolbox/it/versions/second/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | org.maveniverse.maven.toolbox.it.versions 13 | second 14 | 15 | 1.1 16 | 1.1 17 | 18 | 1.0 19 | 1.1 20 | 21 | 20241206134229 22 | 23 | 24 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/dependency-versions/my-repo/org/maveniverse/maven/toolbox/it/versions/third/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | org.maveniverse.maven.toolbox.it.versions 13 | third 14 | 15 | 1.1 16 | 1.1 17 | 18 | 1.0 19 | 1.1 20 | 21 | 20241206134229 22 | 23 | 24 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/dependency-versions/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | String buildLog = new File(basedir, 'build.log').text 9 | assert !buildLog.contains('ERROR') 10 | 11 | String pom = new File(basedir, 'pom.xml').text 12 | String expectedPom = new File(basedir, 'expected-pom.xml').text 13 | assert pom != null && expectedPom != null && pom.equals(expectedPom) 14 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-classpath-1/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023-2024 Maveniverse Org. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v2.0 5 | # which accompanies this distribution, and is available at 6 | # https://www.eclipse.org/legal/epl-v20.html 7 | # 8 | 9 | invoker.goals = eu.maveniverse.maven.plugins:toolbox:${project.version}:gav-classpath -Dgav=eu.maveniverse.maven.toolbox:shared:${project.version} -e -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-classpath-1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 4.0.0 13 | org.maveniverse.maven.toolbox.it 14 | unused 15 | 1.0.0 16 | 17 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-classpath-1/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | assert new File(basedir, 'build.log').text.contains("shared-${projectVersion}.jar") -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-dm-tree-1/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023-2024 Maveniverse Org. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v2.0 5 | # which accompanies this distribution, and is available at 6 | # https://www.eclipse.org/legal/epl-v20.html 7 | # 8 | 9 | invoker.goals = eu.maveniverse.maven.plugins:toolbox:${project.version}:gav-dm-tree -Dgav=org.springframework.boot:spring-boot-dependencies:3.3.3 -e -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-dm-tree-1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 4.0.0 13 | org.maveniverse.maven.toolbox.it 14 | unused 15 | 1.0.0 16 | 17 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-dm-tree-1/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | String buildLog = new File(basedir, 'build.log').text 9 | 10 | // These 3 version comes from ASF parent (also 3 different versions) and ASF project BOMs inherit it 11 | assert buildLog.contains('DM conflicts discovered:') 12 | assert buildLog.contains(' * org.apache.maven.plugin-tools:maven-plugin-annotations:jar version 3.11.0 prevails, but met versions [3.11.0, 3.10.2, 3.7.0]') 13 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-dump-1/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023-2024 Maveniverse Org. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v2.0 5 | # which accompanies this distribution, and is available at 6 | # https://www.eclipse.org/legal/epl-v20.html 7 | # 8 | 9 | invoker.goals = eu.maveniverse.maven.plugins:toolbox:${project.version}:gav-dump -Dverbosity=CHATTER -e 10 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-dump-1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 4.0.0 13 | org.maveniverse.maven.toolbox.it 14 | unused 15 | 1.0.0 16 | 17 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-dump-1/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | String buildLog = new File(basedir, 'build.log').text 9 | assert buildLog.contains('Toolbox ' + projectVersion) 10 | assert buildLog.contains('Maven version ' + mavenVersion) -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-exists-1/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023-2024 Maveniverse Org. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v2.0 5 | # which accompanies this distribution, and is available at 6 | # https://www.eclipse.org/legal/epl-v20.html 7 | # 8 | 9 | invoker.goals = eu.maveniverse.maven.plugins:toolbox:${project.version}:gav-exists -Dgav=org.apache.maven:maven-core:3.6.3 -Dpom -Dsources -Djavadoc -Dsignature -DallRequired -e -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-exists-1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 4.0.0 13 | org.maveniverse.maven.toolbox.it 14 | unused 15 | 1.0.0 16 | 17 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-exists-1/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | String buildLog = new File(basedir, 'build.log').text 9 | assert buildLog.contains('org.apache.maven:maven-core:jar:3.6.3 EXISTS') 10 | assert buildLog.contains('Checked TOTAL of 5 (existing: 5 not existing: 0)') 11 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-identify-1/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023-2024 Maveniverse Org. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v2.0 5 | # which accompanies this distribution, and is available at 6 | # https://www.eclipse.org/legal/epl-v20.html 7 | # 8 | 9 | invoker.goals = eu.maveniverse.maven.plugins:toolbox:${project.version}:gav-identify -Dtarget=eca800aa73e750ec9a880eb224f0bb68f5b7873b -e -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-identify-1/pom.xml.off: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 4.0.0 13 | org.maveniverse.maven.toolbox.it 14 | unused 15 | 1.0.0 16 | 17 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-identify-1/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | String buildLog = new File(basedir, 'build.log').text 9 | assert buildLog.contains('org.apache.maven:maven-core:jar:3.6.3') 10 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-identify-2/aopalliance-1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maveniverse/toolbox/3528c8d7a0272217acf2eb59c5b839a3c8080749/it/toolbox-plugin-its/src/it/gav-identify-2/aopalliance-1.0.jar -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-identify-2/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023-2024 Maveniverse Org. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v2.0 5 | # which accompanies this distribution, and is available at 6 | # https://www.eclipse.org/legal/epl-v20.html 7 | # 8 | 9 | invoker.goals = eu.maveniverse.maven.plugins:toolbox:${project.version}:gav-identify -Dtarget=./aopalliance-1.0.jar -Ddecorated -e -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-identify-2/pom.xml.off: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 4.0.0 13 | org.maveniverse.maven.toolbox.it 14 | unused 15 | 1.0.0 16 | 17 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-identify-2/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | String buildLog = new File(basedir, 'build.log').text 9 | assert buildLog.contains('0235ba8b489512805ac13a8f9ea77a1ca5ebe3e8 (./aopalliance-1.0.jar) = aopalliance:aopalliance:jar:1.0') 10 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-libyear-1/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023-2024 Maveniverse Org. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v2.0 5 | # which accompanies this distribution, and is available at 6 | # https://www.eclipse.org/legal/epl-v20.html 7 | # 8 | 9 | invoker.goals = eu.maveniverse.maven.plugins:toolbox:${project.version}:gav-libyear -Dgav=org.junit.jupiter:junit-jupiter-api:5.10.0 -e -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-libyear-1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 4.0.0 13 | org.maveniverse.maven.toolbox.it 14 | unused 15 | 1.0.0 16 | 17 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/gav-libyear-1/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | String buildLog = new File(basedir, 'build.log').text 9 | assert buildLog.contains('Outdated versions with known age') 10 | assert !buildLog.contains('Total of 0.00 years from 0 outdated dependencies') -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/help/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023-2024 Maveniverse Org. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v2.0 5 | # which accompanies this distribution, and is available at 6 | # https://www.eclipse.org/legal/epl-v20.html 7 | # 8 | 9 | invoker.goals = eu.maveniverse.maven.plugins:toolbox:${project.version}:help -Ddetail -e -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/help/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 4.0.0 13 | org.maveniverse.maven.toolbox.it 14 | unused 15 | 1.0.0 16 | 17 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/help/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | assert new File(basedir, 'build.log').text.contains('toolbox:dump') -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/libyear-1/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023-2024 Maveniverse Org. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v2.0 5 | # which accompanies this distribution, and is available at 6 | # https://www.eclipse.org/legal/epl-v20.html 7 | # 8 | 9 | invoker.goals = eu.maveniverse.maven.plugins:toolbox:${project.version}:libyear -e -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/libyear-1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 4.0.0 13 | org.maveniverse.maven.toolbox.it 14 | libyear 15 | 1.0.0 16 | 17 | 18 | 19 | org.junit.jupiter 20 | junit-jupiter-api 21 | 5.10.0 22 | test 23 | 24 | 25 | 26 | junit 27 | junit 28 | [4.13.2,) 29 | test 30 | 31 | 32 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/libyear-1/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | String buildLog = new File(basedir, 'build.log').text 9 | assert buildLog.contains('Outdated versions with known age') 10 | assert !buildLog.contains('Total of 0.00 years from 0 outdated dependencies') -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/lock-plugin-versions/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023-2024 Maveniverse Org. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v2.0 5 | # which accompanies this distribution, and is available at 6 | # https://www.eclipse.org/legal/epl-v20.html 7 | # 8 | 9 | invoker.goals = eu.maveniverse.maven.plugins:toolbox:${project.version}:lock-plugin-versions -Dapply -e -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/lock-plugin-versions/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | String buildLog = new File(basedir, 'build.log').text 9 | assert !buildLog.contains('ERROR') 10 | 11 | String pom = new File(basedir, 'pom.xml').text 12 | 13 | // partial assert: original does not have it, but locked one should list it 14 | assert pom.contains('maven-deploy-plugin') 15 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/plugin-versions/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023-2024 Maveniverse Org. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v2.0 5 | # which accompanies this distribution, and is available at 6 | # https://www.eclipse.org/legal/epl-v20.html 7 | # 8 | 9 | invoker.goals = eu.maveniverse.maven.plugins:toolbox:${project.version}:plugin-versions -Dapply -e -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/plugin-versions/my-repo/org/maveniverse/maven/toolbox/it/versions/first/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | org.maveniverse.maven.toolbox.it.versions 13 | first 14 | 15 | 1.1 16 | 1.1 17 | 18 | 1.0 19 | 1.1 20 | 21 | 20241206134229 22 | 23 | 24 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/plugin-versions/my-repo/org/maveniverse/maven/toolbox/it/versions/fourth/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | org.maveniverse.maven.toolbox.it.versions 13 | fourth 14 | 15 | 1.1 16 | 1.1 17 | 18 | 1.0 19 | 1.1 20 | 21 | 20241206134229 22 | 23 | 24 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/plugin-versions/my-repo/org/maveniverse/maven/toolbox/it/versions/second/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | org.maveniverse.maven.toolbox.it.versions 13 | second 14 | 15 | 1.1 16 | 1.1 17 | 18 | 1.0 19 | 1.1 20 | 21 | 20241206134229 22 | 23 | 24 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/plugin-versions/my-repo/org/maveniverse/maven/toolbox/it/versions/third/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | org.maveniverse.maven.toolbox.it.versions 13 | third 14 | 15 | 1.1 16 | 1.1 17 | 18 | 1.0 19 | 1.1 20 | 21 | 20241206134229 22 | 23 | 24 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/plugin-versions/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | String buildLog = new File(basedir, 'build.log').text 9 | assert !buildLog.contains('ERROR') 10 | 11 | String pom = new File(basedir, 'pom.xml').text 12 | String expectedPom = new File(basedir, 'expected-pom.xml').text 13 | assert pom != null && expectedPom != null && pom.equals(expectedPom) 14 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/set-version/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023-2024 Maveniverse Org. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v2.0 5 | # which accompanies this distribution, and is available at 6 | # https://www.eclipse.org/legal/epl-v20.html 7 | # 8 | 9 | invoker.goals = eu.maveniverse.maven.plugins:toolbox:${project.version}:set-version -Dversion=2.0.0 -Dproperties=first.version -e -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/set-version/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | String buildLog = new File(basedir, 'build.log').text 9 | assert !buildLog.contains('ERROR') 10 | 11 | String pom = new File(basedir, 'pom.xml').text 12 | String expectedPom = new File(basedir, 'expected-pom.xml').text 13 | assert pom != null && expectedPom != null && pom.equals(expectedPom) 14 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/.mvn/expected-extensions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.maveniverse.maven.toolbox.it.versions 5 | sixth 6 | 1.1 7 | 8 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/.mvn/extensions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.maveniverse.maven.toolbox.it.versions 5 | sixth 6 | 1.0 7 | 8 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023-2024 Maveniverse Org. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v2.0 5 | # which accompanies this distribution, and is available at 6 | # https://www.eclipse.org/legal/epl-v20.html 7 | # 8 | 9 | invoker.maven.version = 3.9+ 10 | 11 | invoker.goals = eu.maveniverse.maven.plugins:toolbox:${project.version}:versions -DartifactVersionSelectorSpec=major() -Dapply -e -Dmaven.repo.local.tail=my-repo -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/fifth/1.0/fifth-1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maveniverse/toolbox/3528c8d7a0272217acf2eb59c5b839a3c8080749/it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/fifth/1.0/fifth-1.0.jar -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/fifth/1.0/fifth-1.0.pom: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | org.maveniverse.maven.toolbox.it.versions 4 | fifth 5 | 1.0 6 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/fifth/1.1/fifth-1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maveniverse/toolbox/3528c8d7a0272217acf2eb59c5b839a3c8080749/it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/fifth/1.1/fifth-1.1.jar -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/fifth/1.1/fifth-1.1.pom: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | org.maveniverse.maven.toolbox.it.versions 4 | fifth 5 | 1.1 6 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/fifth/maven-metadata-local.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | org.maveniverse.maven.toolbox.it.versions 13 | fifth 14 | 15 | 1.1 16 | 1.1 17 | 18 | 1.0 19 | 1.1 20 | 21 | 20241206134229 22 | 23 | 24 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/first/maven-metadata-local.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | org.maveniverse.maven.toolbox.it.versions 13 | first 14 | 15 | 1.1 16 | 1.1 17 | 18 | 1.0 19 | 1.1 20 | 21 | 20241206134229 22 | 23 | 24 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/fourth/maven-metadata-local.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | org.maveniverse.maven.toolbox.it.versions 13 | fourth 14 | 15 | 1.1 16 | 1.1 17 | 18 | 1.0 19 | 1.1 20 | 21 | 20241206134229 22 | 23 | 24 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/second/maven-metadata-local.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | org.maveniverse.maven.toolbox.it.versions 13 | second 14 | 15 | 1.1 16 | 1.1 17 | 18 | 1.0 19 | 1.1 20 | 21 | 20241206134229 22 | 23 | 24 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/sixth/1.0/sixth-1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maveniverse/toolbox/3528c8d7a0272217acf2eb59c5b839a3c8080749/it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/sixth/1.0/sixth-1.0.jar -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/sixth/1.0/sixth-1.0.pom: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | org.maveniverse.maven.toolbox.it.versions 4 | fifth 5 | 1.0 6 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/sixth/1.1/sixth-1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maveniverse/toolbox/3528c8d7a0272217acf2eb59c5b839a3c8080749/it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/sixth/1.1/sixth-1.1.jar -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/sixth/1.1/sixth-1.1.pom: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | org.maveniverse.maven.toolbox.it.versions 4 | fifth 5 | 1.1 6 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/sixth/maven-metadata-local.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | org.maveniverse.maven.toolbox.it.versions 13 | sixth 14 | 15 | 1.1 16 | 1.1 17 | 18 | 1.0 19 | 1.1 20 | 21 | 20241206134229 22 | 23 | 24 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/my-repo/org/maveniverse/maven/toolbox/it/versions/third/maven-metadata-local.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | org.maveniverse.maven.toolbox.it.versions 13 | third 14 | 15 | 1.1 16 | 1.1 17 | 18 | 1.0 19 | 1.1 20 | 21 | 20241206134229 22 | 23 | 24 | -------------------------------------------------------------------------------- /it/toolbox-plugin-its/src/it/versions/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | String buildLog = new File(basedir, 'build.log').text 9 | assert !buildLog.contains('ERROR') 10 | 11 | String pom = new File(basedir, 'pom.xml').text 12 | String expectedPom = new File(basedir, 'expected-pom.xml').text 13 | assert pom != null && expectedPom != null && pom.equals(expectedPom) 14 | 15 | String extensionsXml = new File(basedir, '.mvn/extensions.xml').text 16 | String expectedExtensionsXml = new File(basedir, '.mvn/expected-extensions.xml').text 17 | assert extensionsXml != null && expectedExtensionsXml != null && extensionsXml.equals(expectedExtensionsXml) 18 | -------------------------------------------------------------------------------- /mvnsh/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 4.0.0 13 | 14 | 15 | eu.maveniverse.maven.toolbox 16 | toolbox 17 | 0.10.2-SNAPSHOT 18 | 19 | 20 | mvnsh 21 | 22 | ${project.groupId}:${project.artifactId} 23 | 24 | 25 | 26 | 17 27 | 28 | 29 | 30 | 31 | org.apache.maven 32 | maven-cli 33 | 4.0.0-rc-3 34 | provided 35 | 36 | 37 | 38 | eu.maveniverse.maven.plugins 39 | toolbox 40 | 41 | 42 | org.jline 43 | jline 44 | 45 | 46 | org.slf4j 47 | slf4j-api 48 | 49 | 50 | org.slf4j 51 | jcl-over-slf4j 52 | 53 | 54 | eu.maveniverse.maven.mima.runtime 55 | embedded-maven 56 | 57 | 58 | 59 | 60 | eu.maveniverse.maven.mima.runtime 61 | standalone-static-uber 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /mvnsh/src/main/java/eu/maveniverse/maven/toolbox/plugin/mvnsh/ToolboxShellCommandRegistryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mvnsh; 9 | 10 | import eu.maveniverse.maven.mima.context.Runtimes; 11 | import eu.maveniverse.maven.mima.runtime.standalonestatic.StandaloneStaticRuntime; 12 | import eu.maveniverse.maven.toolbox.plugin.CLI; 13 | import eu.maveniverse.maven.toolbox.plugin.CwdAware; 14 | import javax.inject.Named; 15 | import javax.inject.Singleton; 16 | import org.apache.maven.cling.invoker.LookupContext; 17 | import org.apache.maven.cling.invoker.mvnsh.ShellCommandRegistryFactory; 18 | import org.jline.console.CommandRegistry; 19 | import picocli.CommandLine; 20 | import picocli.shell.jline3.PicocliCommands; 21 | 22 | /** 23 | * Main C. 24 | */ 25 | @Named("toolbox") 26 | @Singleton 27 | public class ToolboxShellCommandRegistryFactory implements ShellCommandRegistryFactory { 28 | @Override 29 | public CommandRegistry createShellCommandRegistry(LookupContext lookupContext) { 30 | Runtimes.INSTANCE.registerRuntime(new StandaloneStaticRuntime()); 31 | 32 | PicocliCommands.PicocliCommandsFactory factory = new PicocliCommands.PicocliCommandsFactory() { 33 | @Override 34 | public K create(Class clazz) throws Exception { 35 | K result = super.create(clazz); 36 | if (result instanceof CwdAware cwdAware) { 37 | cwdAware.setCwd(lookupContext.cwd.get()); 38 | } 39 | return result; 40 | } 41 | }; 42 | factory.setTerminal(lookupContext.terminal); 43 | 44 | PicocliCommands picocliCommands = new PicocliCommands(new CommandLine(new CLI(), factory)); 45 | picocliCommands.name("Maveniverse Toolbox"); 46 | return picocliCommands; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/ArtifactRecorder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared; 9 | 10 | import java.util.Collection; 11 | import java.util.List; 12 | import java.util.Map; 13 | import java.util.stream.Stream; 14 | import org.eclipse.aether.artifact.Artifact; 15 | import org.eclipse.aether.repository.RemoteRepository; 16 | 17 | /** 18 | * Artifact recorder. 19 | */ 20 | public interface ArtifactRecorder extends Source { 21 | /** 22 | * The "sentinel" remote repository that recorder assigns when there is no remote repository available. This 23 | * means that artifact was either installed locally. To check for "sentinel" remote repository use instance 24 | * equality. 25 | */ 26 | RemoteRepository SENTINEL = new RemoteRepository.Builder("sentinel", "default", "none").build(); 27 | 28 | /** 29 | * Tells is recorder active or not. 30 | */ 31 | boolean isActive(); 32 | 33 | /** 34 | * Activate/deactivate recorder. 35 | */ 36 | boolean setActive(boolean active); 37 | 38 | /** 39 | * Returns the count of recorded artifacts. 40 | */ 41 | int recordedCount(); 42 | 43 | /** 44 | * Clears the recorder buffer. 45 | */ 46 | void clear(); 47 | 48 | /** 49 | * Returns the map of recorded artifacts. Map key may be {@link #SENTINEL}, and it is left at caller discretion 50 | * how to handle those. 51 | */ 52 | Map> getRecordedArtifacts(); 53 | 54 | @Override 55 | default Stream get() { 56 | return getRecordedArtifacts().values().stream().flatMap(Collection::stream); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/ProjectLocator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared; 9 | 10 | import java.util.List; 11 | import java.util.Optional; 12 | import org.eclipse.aether.artifact.Artifact; 13 | import org.eclipse.aether.graph.Dependency; 14 | 15 | /** 16 | * Construction to represent "projects" abstraction and ability to locate them. 17 | */ 18 | public interface ProjectLocator { 19 | /** 20 | * Represents single project. 21 | */ 22 | interface Project { 23 | Artifact artifact(); 24 | 25 | Optional getParent(); 26 | 27 | List dependencies(); 28 | 29 | ProjectLocator origin(); 30 | } 31 | /** 32 | * Locates project by given artifact. If not present, it means artifact is "external" relative to these projects. 33 | */ 34 | Optional locateProject(Artifact artifact); 35 | } 36 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/ReactorLocator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared; 9 | 10 | import eu.maveniverse.maven.toolbox.shared.internal.Artifacts; 11 | import java.util.List; 12 | import org.apache.maven.model.Model; 13 | 14 | /** 15 | * Construction to represent "reactor" abstraction. 16 | */ 17 | public interface ReactorLocator extends ProjectLocator, Artifacts.Source { 18 | interface ReactorProject extends Project { 19 | Model effectiveModel(); 20 | } 21 | 22 | /** 23 | * Returns "top level" project, never {@code null}. 24 | */ 25 | ReactorProject getTopLevelProject(); 26 | 27 | /** 28 | * Returns "current" project, never {@code null}. 29 | */ 30 | ReactorProject getCurrentProject(); 31 | 32 | /** 33 | * Returns list of all projects, never {@code null}. 34 | */ 35 | List getAllProjects(); 36 | 37 | /** 38 | * Locates children projects of given project within reactor, that is projects that refer to passed in project 39 | * as parent. 40 | */ 41 | List locateChildren(Project project); 42 | 43 | /** 44 | * Locates children projects of given project within reactor, that is projects that are referred from passed in 45 | * project as modules. 46 | */ 47 | List locateCollected(Project project); 48 | } 49 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/Result.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared; 9 | 10 | import static java.util.Objects.requireNonNull; 11 | 12 | import java.util.Optional; 13 | 14 | /** 15 | * The Toolbox Commando result. 16 | */ 17 | public final class Result { 18 | public static Result failure(String message) { 19 | requireNonNull(message, "message"); 20 | return new Result<>(false, message, null); 21 | } 22 | 23 | public static Result success(T data) { 24 | requireNonNull(data, "data"); 25 | return new Result<>(true, "Success", data); 26 | } 27 | 28 | private final boolean success; 29 | private final String message; 30 | private final T data; 31 | 32 | private Result(boolean success, String message, T data) { 33 | this.success = success; 34 | this.message = message; 35 | this.data = data; 36 | } 37 | 38 | public boolean isSuccess() { 39 | return success; 40 | } 41 | 42 | public String getMessage() { 43 | return message; 44 | } 45 | 46 | public Optional getData() { 47 | return Optional.ofNullable(data); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/Sink.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared; 9 | 10 | import static java.util.Objects.requireNonNull; 11 | 12 | import java.io.IOException; 13 | import java.io.UncheckedIOException; 14 | import java.util.Collection; 15 | import java.util.stream.Stream; 16 | 17 | /** 18 | * Construct to accept collection of things. 19 | */ 20 | @FunctionalInterface 21 | public interface Sink extends AutoCloseable { 22 | void accept(T thing) throws IOException; 23 | 24 | default void accept(Stream stream) throws IOException { 25 | try { 26 | stream.forEach(t -> { 27 | try { 28 | accept(t); 29 | } catch (IOException e) { 30 | throw new UncheckedIOException(e); 31 | } 32 | }); 33 | } catch (UncheckedIOException e) { 34 | throw e.getCause(); 35 | } 36 | } 37 | 38 | default void accept(Collection things) throws IOException { 39 | requireNonNull(things, "things"); 40 | try { 41 | for (T thing : things) { 42 | accept(thing); 43 | } 44 | } catch (IOException e) { 45 | cleanup(e); 46 | throw e; 47 | } 48 | } 49 | 50 | default void cleanup(Exception e) {} 51 | 52 | @Override 53 | default void close() throws Exception {} 54 | } 55 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/Source.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared; 9 | 10 | import java.io.IOException; 11 | import java.util.stream.Stream; 12 | 13 | /** 14 | * Construction to supply collection of things. 15 | */ 16 | @FunctionalInterface 17 | public interface Source extends AutoCloseable { 18 | Stream get() throws IOException; 19 | 20 | @Override 21 | default void close() throws Exception {} 22 | } 23 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/ToolboxCommandoVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared; 9 | 10 | import static eu.maveniverse.maven.toolbox.shared.internal.ToolboxCommandoImpl.discoverArtifactVersion; 11 | 12 | public final class ToolboxCommandoVersion { 13 | private ToolboxCommandoVersion() {} 14 | 15 | public static String getVersion() { 16 | return discoverArtifactVersion("eu.maveniverse.maven.toolbox", "shared", "unknown"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/internal/ArtifactRecorderImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.internal; 9 | 10 | import eu.maveniverse.maven.toolbox.shared.ArtifactRecorder; 11 | import java.util.ArrayList; 12 | import java.util.Collection; 13 | import java.util.Collections; 14 | import java.util.List; 15 | import java.util.Map; 16 | import java.util.concurrent.ConcurrentHashMap; 17 | import java.util.concurrent.atomic.AtomicBoolean; 18 | import org.eclipse.aether.AbstractRepositoryListener; 19 | import org.eclipse.aether.RepositoryEvent; 20 | import org.eclipse.aether.artifact.Artifact; 21 | import org.eclipse.aether.repository.RemoteRepository; 22 | 23 | public class ArtifactRecorderImpl extends AbstractRepositoryListener implements Artifacts.Source, ArtifactRecorder { 24 | private final ConcurrentHashMap> recordedArtifacts; 25 | private final AtomicBoolean active; 26 | 27 | public ArtifactRecorderImpl() { 28 | this.recordedArtifacts = new ConcurrentHashMap<>(); 29 | this.active = new AtomicBoolean(false); 30 | } 31 | 32 | @Override 33 | public void artifactResolved(RepositoryEvent event) { 34 | if (active.get()) { 35 | RemoteRepository repository = event.getRepository() instanceof RemoteRepository 36 | ? (RemoteRepository) event.getRepository() 37 | : SENTINEL; 38 | recordedArtifacts 39 | .computeIfAbsent(repository, k -> Collections.synchronizedList(new ArrayList<>())) 40 | .add(event.getArtifact()); 41 | } 42 | } 43 | 44 | @Override 45 | public boolean isActive() { 46 | return active.get(); 47 | } 48 | 49 | @Override 50 | public boolean setActive(boolean val) { 51 | return active.compareAndSet(!val, val); 52 | } 53 | 54 | @Override 55 | public int recordedCount() { 56 | return recordedArtifacts.values().stream().mapToInt(Collection::size).sum(); 57 | } 58 | 59 | @Override 60 | public void clear() { 61 | recordedArtifacts.clear(); 62 | } 63 | 64 | @Override 65 | public Map> getRecordedArtifacts() { 66 | return recordedArtifacts; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/internal/Artifacts.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.internal; 9 | 10 | import org.eclipse.aether.artifact.Artifact; 11 | 12 | /** 13 | * Artifacts. 14 | */ 15 | public final class Artifacts { 16 | private Artifacts() {} 17 | 18 | public interface Sink extends eu.maveniverse.maven.toolbox.shared.Sink {} 19 | 20 | public interface Source extends eu.maveniverse.maven.toolbox.shared.Source {} 21 | } 22 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/internal/Dependencies.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.internal; 9 | 10 | import org.eclipse.aether.graph.Dependency; 11 | 12 | /** 13 | * Dependencies. 14 | */ 15 | public final class Dependencies { 16 | private Dependencies() {} 17 | 18 | public interface Sink extends eu.maveniverse.maven.toolbox.shared.Sink {} 19 | 20 | public interface Source extends eu.maveniverse.maven.toolbox.shared.Source {} 21 | } 22 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/internal/DependencyGraphDecorators.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.internal; 9 | 10 | import java.util.function.Supplier; 11 | 12 | public final class DependencyGraphDecorators { 13 | private DependencyGraphDecorators() {} 14 | 15 | public static Supplier defaultSupplier() { 16 | return DependencyGraphDumper.LineFormatter::new; 17 | } 18 | 19 | public static class TreeDecorator extends DependencyGraphDumper.LineFormatter {} 20 | 21 | public static class DmTreeDecorator extends DependencyGraphDumper.LineFormatter {} 22 | 23 | public static class ParentChildTreeDecorator extends DependencyGraphDumper.LineFormatter {} 24 | 25 | public static class SubprojectTreeDecorator extends DependencyGraphDumper.LineFormatter {} 26 | 27 | public static class ProjectDependenciesTreeDecorator extends DependencyGraphDumper.LineFormatter {} 28 | } 29 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/internal/DirectorySource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.internal; 9 | 10 | import static java.util.Objects.requireNonNull; 11 | 12 | import java.io.IOException; 13 | import java.nio.file.Files; 14 | import java.nio.file.Path; 15 | import java.util.stream.Stream; 16 | import org.eclipse.aether.artifact.Artifact; 17 | 18 | /** 19 | * Construction to supply collection of artifacts, for example like a filesystem directory. 20 | */ 21 | public final class DirectorySource implements Artifacts.Source { 22 | /** 23 | * Creates plain directory source, that supplies all artifacts it has. 24 | */ 25 | public static DirectorySource directory(Path path) { 26 | return new DirectorySource(path); 27 | } 28 | 29 | private final Path directory; 30 | private final IndexFileReader indexFileReader; 31 | 32 | /** 33 | * Creates a directory source. 34 | * 35 | * @param directory The directory, if not existing, will be created. 36 | */ 37 | private DirectorySource(Path directory) { 38 | this.directory = requireNonNull(directory, "directory").toAbsolutePath(); 39 | if (!Files.isDirectory(directory)) { 40 | throw new IllegalArgumentException("directory must exists"); 41 | } 42 | this.indexFileReader = new IndexFileReader(directory.resolve(".index")); 43 | } 44 | 45 | public Path getDirectory() { 46 | return directory; 47 | } 48 | 49 | @Override 50 | public Stream get() throws IOException { 51 | return indexFileReader.read(directory::resolve); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/internal/ExtensionsSuppliers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.internal; 9 | 10 | /** 11 | * Some simple suppliers of extensions. 12 | */ 13 | public final class ExtensionsSuppliers { 14 | public static String empty110() { 15 | return "\n" 17 | + "\n"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/internal/IndexFileReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.internal; 9 | 10 | import static java.util.Objects.requireNonNull; 11 | 12 | import java.io.IOException; 13 | import java.nio.file.Files; 14 | import java.nio.file.Path; 15 | import java.util.function.Function; 16 | import java.util.stream.Stream; 17 | import org.eclipse.aether.artifact.Artifact; 18 | import org.eclipse.aether.artifact.DefaultArtifact; 19 | 20 | /** 21 | * Reads "index file", that is a file having GAV per line. 22 | */ 23 | public final class IndexFileReader implements AutoCloseable { 24 | private final Path indexFile; 25 | 26 | public IndexFileReader(Path indexFile) { 27 | this.indexFile = requireNonNull(indexFile, "indexFile").toAbsolutePath(); 28 | } 29 | 30 | public Stream read(Function pathResolver) throws IOException { 31 | return Files.readAllLines(indexFile).stream() 32 | .filter(l -> !l.trim().isEmpty() && !l.startsWith("#")) 33 | .map(l -> { 34 | String[] parts = l.split(" >> ", -1); 35 | return new DefaultArtifact(parts[0]) 36 | .setFile(pathResolver.apply(parts[1]).toFile()); 37 | }); 38 | } 39 | 40 | @Override 41 | public void close() {} 42 | } 43 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/internal/LevelDependencySelector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.internal; 9 | 10 | import org.eclipse.aether.collection.DependencyCollectionContext; 11 | import org.eclipse.aether.collection.DependencySelector; 12 | import org.eclipse.aether.graph.Dependency; 13 | import org.eclipse.aether.util.graph.selector.StaticDependencySelector; 14 | 15 | public class LevelDependencySelector implements DependencySelector { 16 | private final int maxLevel; 17 | private final int currentLevel; 18 | 19 | public LevelDependencySelector(int maxLevel) { 20 | if (maxLevel < 1) { 21 | throw new IllegalArgumentException("maxLevel must be greater than 0"); 22 | } 23 | this.maxLevel = maxLevel; 24 | this.currentLevel = 0; 25 | } 26 | 27 | private LevelDependencySelector(int maxLevel, int currentLevel) { 28 | this.maxLevel = maxLevel; 29 | this.currentLevel = currentLevel; 30 | } 31 | 32 | @Override 33 | public boolean selectDependency(Dependency dependency) { 34 | return true; 35 | } 36 | 37 | @Override 38 | public DependencySelector deriveChildSelector(DependencyCollectionContext context) { 39 | int newLevel = currentLevel + 1; 40 | if (newLevel > maxLevel) { 41 | return new StaticDependencySelector(false); 42 | } else { 43 | return new LevelDependencySelector(maxLevel, newLevel); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/internal/PomSuppliers.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.internal; 9 | 10 | import static java.util.Objects.requireNonNull; 11 | 12 | /** 13 | * Some simple suppliers of POM. 14 | */ 15 | public final class PomSuppliers { 16 | public static String empty400(String groupId, String artifactId, String version) { 17 | requireNonNull(groupId, "groupId"); 18 | requireNonNull(artifactId, "artifactId"); 19 | requireNonNull(version, "version"); 20 | return "\n" // 21 | + "\n" // 23 | + " 4.0.0\n" // 24 | + "\n" // 25 | + " " + groupId + "\n" // 26 | + " " + artifactId + "\n" // 27 | + " " + version + "\n" // 28 | + "\n"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/internal/jdom/JDomCfg.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.internal.jdom; 9 | 10 | /* 11 | * Copyright 2018 CoreMedia AG, Hamburg 12 | * 13 | * Licensed under the Apache License, Version 2.0 (the "License"); 14 | * you may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at 16 | * 17 | * http://www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | */ 25 | 26 | import java.util.List; 27 | 28 | public interface JDomCfg { 29 | List getElementOrder(String type); 30 | 31 | void setElementOrder(String type, List elementOrder); 32 | } 33 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/internal/jdom/JDomExtensionsCfg.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.internal.jdom; 9 | 10 | /* 11 | * Copyright 2018 CoreMedia AG, Hamburg 12 | * 13 | * Licensed under the Apache License, Version 2.0 (the "License"); 14 | * you may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at 16 | * 17 | * http://www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | */ 25 | 26 | import java.util.HashMap; 27 | import java.util.List; 28 | import java.util.Map; 29 | 30 | public class JDomExtensionsCfg implements JDomCfg { 31 | 32 | private final Map> elementOrder = new HashMap<>(); 33 | 34 | @Override 35 | public List getElementOrder(String type) { 36 | return elementOrder.get(type); 37 | } 38 | 39 | @Override 40 | public void setElementOrder(String type, List elementOrder) { 41 | this.elementOrder.put(type, elementOrder); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/internal/jdom/JDomExtensionsSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.internal.jdom; 9 | 10 | import static java.util.Objects.requireNonNull; 11 | 12 | import eu.maveniverse.maven.toolbox.shared.internal.Artifacts; 13 | import java.io.IOException; 14 | import java.nio.file.Path; 15 | import java.util.stream.Stream; 16 | import org.eclipse.aether.artifact.Artifact; 17 | 18 | /** 19 | * Construction to accept collection of artifacts, and applies it to some extensions.xml based on provided transformations. 20 | */ 21 | public final class JDomExtensionsSource implements Artifacts.Source { 22 | 23 | private final Path extensions; 24 | 25 | public JDomExtensionsSource(Path extensions) { 26 | this.extensions = requireNonNull(extensions); 27 | } 28 | 29 | @Override 30 | public Stream get() throws IOException { 31 | try (JDomDocumentIO domDocumentIO = new JDomDocumentIO(extensions)) { 32 | return JDomExtensionsEditor.listExtensions( 33 | domDocumentIO.getDocument().getRootElement()) 34 | .stream(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/internal/jdom/JDomTransformationContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.internal.jdom; 9 | 10 | import java.nio.file.Path; 11 | import java.util.function.Consumer; 12 | import org.jdom2.Document; 13 | 14 | /** 15 | * The transformation context. 16 | */ 17 | public interface JDomTransformationContext { 18 | /** 19 | * The document, 20 | */ 21 | Document getDocument(); 22 | 23 | interface JDomPomTransformationContext extends JDomTransformationContext { 24 | /** 25 | * Hook for post processor registration. 26 | */ 27 | void registerPostTransformation(Consumer transformation); 28 | 29 | Path pom(); 30 | } 31 | 32 | interface JdomExtensionsTransformationContext extends JDomTransformationContext { 33 | /** 34 | * Hook for post processor registration. 35 | */ 36 | void registerPostTransformation(Consumer transformation); 37 | 38 | Path extensions(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/internal/jdom/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | 9 | /** 10 | * This package contains sources from Maven Release project 11 | * and improved codebase from Maven JDom Parser. 12 | * 13 | * @author Robert Scholte (for Maven Release project) 14 | * @author Marc Rohlfs, CoreMedia AG 15 | */ 16 | package eu.maveniverse.maven.toolbox.shared.internal.jdom; 17 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/io/IOConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.io; 9 | 10 | import java.io.IOException; 11 | 12 | @FunctionalInterface 13 | public interface IOConsumer { 14 | void accept(T t) throws IOException; 15 | } 16 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/io/IOSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.io; 9 | 10 | import java.io.IOException; 11 | 12 | @FunctionalInterface 13 | public interface IOSupplier { 14 | T get() throws IOException; 15 | } 16 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/output/LoggerOutput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.output; 9 | 10 | import java.util.Arrays; 11 | import org.slf4j.Logger; 12 | 13 | /** 14 | * {@link Output} backed with Slf4J {@link Logger}. 15 | */ 16 | public final class LoggerOutput extends OutputSupport { 17 | private final Logger output; 18 | 19 | public LoggerOutput(Logger output, boolean errors, Verbosity verbosity) { 20 | super(verbosity, errors); 21 | this.output = output; 22 | } 23 | 24 | @Override 25 | public void warn(String message, Object... params) { 26 | if (!isShowErrors() && params.length > 0 && params[params.length - 1] instanceof Throwable) { 27 | output.warn( 28 | message + " " + ((Throwable) params[params.length - 1]).getMessage(), 29 | Arrays.copyOf(params, params.length - 1)); 30 | } else { 31 | output.warn(message, params); 32 | } 33 | } 34 | 35 | @Override 36 | public void error(String message, Object... params) { 37 | if (!isShowErrors() && params.length > 0 && params[params.length - 1] instanceof Throwable) { 38 | output.error( 39 | message + " " + ((Throwable) params[params.length - 1]).getMessage(), 40 | Arrays.copyOf(params, params.length - 1)); 41 | } else { 42 | output.error(message, params); 43 | } 44 | } 45 | 46 | @Override 47 | protected void doHandle(Verbosity verbosity, String message, Object... params) { 48 | output.info(message, params); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/output/Marker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.output; 9 | 10 | import static java.util.Objects.requireNonNull; 11 | 12 | /** 13 | * Simple "Marker (Pen)", useful to assemble single message line with different markings. This implementation is 14 | * "no op" (does not do anything), subclasses of it may do more. 15 | */ 16 | public class Marker { 17 | private final Output output; 18 | private final Output.Verbosity verbosity; 19 | private final StringBuilder message; 20 | 21 | public Marker(Output output, Output.Verbosity verbosity) { 22 | this.output = output; 23 | this.verbosity = verbosity; 24 | this.message = new StringBuilder(); 25 | } 26 | 27 | public enum Intent { 28 | EMPHASIZE, 29 | OUTSTANDING, 30 | NORMAL, 31 | DETAIL, 32 | UNIMPORTANT, 33 | SCARY, 34 | BLOODY 35 | } 36 | 37 | public Marker word(Intent intent, String word) { 38 | requireNonNull(intent, "intent"); 39 | requireNonNull(word, "word"); 40 | message.append(word); 41 | return this; 42 | } 43 | 44 | public Marker emphasize(String word) { 45 | return word(Intent.EMPHASIZE, word); 46 | } 47 | 48 | public Marker outstanding(String word) { 49 | return word(Intent.OUTSTANDING, word); 50 | } 51 | 52 | public Marker normal(String word) { 53 | return word(Intent.NORMAL, word); 54 | } 55 | 56 | public Marker detail(String word) { 57 | return word(Intent.DETAIL, word); 58 | } 59 | 60 | public Marker unimportant(String word) { 61 | return word(Intent.UNIMPORTANT, word); 62 | } 63 | 64 | public Marker scary(String word) { 65 | return word(Intent.SCARY, word); 66 | } 67 | 68 | public Marker bloody(String word) { 69 | return word(Intent.BLOODY, word); 70 | } 71 | 72 | public void say(Object... params) { 73 | if (output.isHeard(verbosity)) { 74 | output.handle(verbosity, toString(), params); 75 | } 76 | } 77 | 78 | @Override 79 | public String toString() { 80 | String result = message.toString(); 81 | message.setLength(0); 82 | return result; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/output/NopOutput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.output; 9 | 10 | /** 11 | * No op {@link Output}. 12 | */ 13 | public final class NopOutput extends OutputSupport { 14 | public static final NopOutput INSTANCE = new NopOutput(); 15 | 16 | private NopOutput() { 17 | super(Verbosity.SILENT, false); 18 | } 19 | 20 | @Override 21 | protected void doHandle(Verbosity verbosity, String message, Object... params) {} 22 | } 23 | -------------------------------------------------------------------------------- /shared/src/main/java/eu/maveniverse/maven/toolbox/shared/output/PrintStreamOutput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.output; 9 | 10 | import java.io.PrintStream; 11 | import org.slf4j.helpers.FormattingTuple; 12 | import org.slf4j.helpers.MessageFormatter; 13 | 14 | /** 15 | * {@link Output} backed with {@link PrintStream}. 16 | */ 17 | public class PrintStreamOutput extends OutputSupport { 18 | protected final PrintStream output; 19 | 20 | public PrintStreamOutput(PrintStream output, Verbosity verbosity, boolean errors) { 21 | super(verbosity, errors); 22 | this.output = output; 23 | } 24 | 25 | @Override 26 | protected void doHandle(Verbosity verbosity, String message, Object... params) { 27 | FormattingTuple tuple = MessageFormatter.arrayFormat(message, params); 28 | output.println(tuple.getMessage()); 29 | if (tuple.getThrowable() != null) { 30 | if (errors) { 31 | tuple.getThrowable().printStackTrace(output); 32 | } else { 33 | output.println(tuple.getThrowable().getMessage()); 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /shared/src/test/java/eu/maveniverse/maven/toolbox/shared/ArtifactMapperTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared; 9 | 10 | import static org.junit.jupiter.api.Assertions.assertEquals; 11 | 12 | import java.util.HashMap; 13 | import java.util.function.Function; 14 | import org.eclipse.aether.artifact.Artifact; 15 | import org.eclipse.aether.artifact.DefaultArtifact; 16 | import org.junit.jupiter.api.Test; 17 | 18 | public class ArtifactMapperTest { 19 | @Test 20 | void noChangeEquals() { 21 | DefaultArtifact a = new DefaultArtifact("a:b:c"); 22 | Artifact other = ArtifactMapper.baseVersion().apply(a); 23 | assertEquals(a, other); 24 | } 25 | 26 | @Test 27 | void allOfThemComposed() { 28 | Artifact mapped = ArtifactMapper.compose( 29 | ArtifactMapper.baseVersion(), 30 | ArtifactMapper.omitClassifier(), 31 | ArtifactMapper.rename(s -> "g1", s -> "a1", Function.identity())) 32 | .apply(new DefaultArtifact("g:a:jar:classifier:1.0-20240322.090900-12")); 33 | assertEquals(new DefaultArtifact("g1:a1:1.0-SNAPSHOT"), mapped); 34 | } 35 | 36 | @Test 37 | void parse() { 38 | HashMap properties = new HashMap<>(); 39 | properties.put("groupId", "org.some.group"); 40 | Artifact artifact = new DefaultArtifact("g:a:jar:classifier:1.0-20240322.090900-12"); 41 | 42 | Artifact mapped; 43 | 44 | mapped = ArtifactMapper.build(properties, "omitClassifier()").apply(artifact); 45 | assertEquals(new DefaultArtifact("g:a:jar:1.0-20240322.090900-12"), mapped); 46 | 47 | mapped = ArtifactMapper.build(properties, "baseVersion()").apply(artifact); 48 | assertEquals(new DefaultArtifact("g:a:jar:classifier:1.0-SNAPSHOT"), mapped); 49 | 50 | mapped = ArtifactMapper.build(properties, "compose(omitClassifier(), baseVersion())") 51 | .apply(artifact); 52 | assertEquals(new DefaultArtifact("g:a:jar:1.0-SNAPSHOT"), mapped); 53 | 54 | mapped = ArtifactMapper.build(properties, "rename(${groupId},*,1.0.0)").apply(artifact); 55 | assertEquals(new DefaultArtifact("org.some.group:a:jar:classifier:1.0.0"), mapped); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /shared/src/test/java/eu/maveniverse/maven/toolbox/shared/internal/ToolboxCommandoImplTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.shared.internal; 9 | 10 | import eu.maveniverse.maven.mima.context.Context; 11 | import eu.maveniverse.maven.mima.context.ContextOverrides; 12 | import eu.maveniverse.maven.mima.context.Runtime; 13 | import eu.maveniverse.maven.mima.context.Runtimes; 14 | import eu.maveniverse.maven.toolbox.shared.output.NopOutput; 15 | import java.io.IOException; 16 | import java.nio.file.Path; 17 | import org.junit.jupiter.api.Disabled; 18 | import org.junit.jupiter.api.Test; 19 | 20 | @Disabled("This test does not test anything") 21 | public class ToolboxCommandoImplTest { 22 | 23 | @Test 24 | void search() throws IOException { 25 | Runtime runtime = Runtimes.INSTANCE.getRuntime(); 26 | try (Context context = runtime.create(ContextOverrides.create() 27 | .withBasedirOverride(Path.of("target").toAbsolutePath()) 28 | .build())) { 29 | ToolboxCommandoImpl tc = new ToolboxCommandoImpl(NopOutput.INSTANCE, context); 30 | 31 | tc.search(ContextOverrides.CENTRAL, "junit:junit:4.13.2"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /shared/src/test/java/eu/maveniverse/maven/toolbox/shared/internal/jdom/JDomPomEditorTest.java: -------------------------------------------------------------------------------- 1 | package eu.maveniverse.maven.toolbox.shared.internal.jdom; 2 | 3 | import eu.maveniverse.maven.toolbox.shared.internal.PomSuppliers; 4 | import java.io.IOException; 5 | import java.util.concurrent.atomic.AtomicReference; 6 | import org.eclipse.aether.artifact.DefaultArtifact; 7 | import org.junit.jupiter.api.Test; 8 | 9 | public class JDomPomEditorTest { 10 | @Test 11 | void smokeUpdateManagedPlugin() throws IOException { 12 | AtomicReference result = new AtomicReference<>(); 13 | try (JDomDocumentIO documentIO = 14 | new JDomDocumentIO(() -> PomSuppliers.empty400("org.example", "test", "1.0.0-SNAPSHOT"), result::set)) { 15 | JDomPomEditor.updateManagedPlugin( 16 | documentIO.getDocument().getRootElement(), new DefaultArtifact("g:a:v"), true); 17 | } 18 | System.out.println(result.get()); 19 | } 20 | 21 | @Test 22 | void smokeUpdatePlugin() throws IOException { 23 | AtomicReference result = new AtomicReference<>(); 24 | try (JDomDocumentIO documentIO = 25 | new JDomDocumentIO(() -> PomSuppliers.empty400("org.example", "test", "1.0.0-SNAPSHOT"), result::set)) { 26 | JDomPomEditor.updatePlugin(documentIO.getDocument().getRootElement(), new DefaultArtifact("g:a:v"), true); 27 | } 28 | System.out.println(result.get()); 29 | } 30 | 31 | @Test 32 | void smokeUpdateManagedDependency() throws IOException { 33 | AtomicReference result = new AtomicReference<>(); 34 | try (JDomDocumentIO documentIO = 35 | new JDomDocumentIO(() -> PomSuppliers.empty400("org.example", "test", "1.0.0-SNAPSHOT"), result::set)) { 36 | JDomPomEditor.updateManagedDependency( 37 | documentIO.getDocument().getRootElement(), new DefaultArtifact("g:a:v"), true); 38 | } 39 | System.out.println(result.get()); 40 | } 41 | 42 | @Test 43 | void smokeUpdateDependency() throws IOException { 44 | AtomicReference result = new AtomicReference<>(); 45 | try (JDomDocumentIO documentIO = 46 | new JDomDocumentIO(() -> PomSuppliers.empty400("org.example", "test", "1.0.0-SNAPSHOT"), result::set)) { 47 | JDomPomEditor.updateDependency( 48 | documentIO.getDocument().getRootElement(), new DefaultArtifact("g:a:v"), true); 49 | } 50 | System.out.println(result.get()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/CwdAware.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin; 9 | 10 | import static java.util.Objects.requireNonNull; 11 | 12 | import java.nio.file.Path; 13 | 14 | public interface CwdAware { 15 | /** 16 | * Sets CWD; must be non-null path that points to existing directory. 17 | */ 18 | void setCwd(Path cwd); 19 | 20 | /** 21 | * Returns CWD; a non-null path that points to existing directory. 22 | */ 23 | Path getCwd(); 24 | 25 | /** 26 | * Resolves against CWD. 27 | */ 28 | default Path resolve(Path path) { 29 | requireNonNull(path, "path"); 30 | return getCwd().resolve(path).normalize().toAbsolutePath(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/GavMojoSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin; 9 | 10 | import eu.maveniverse.maven.toolbox.shared.ProjectArtifacts; 11 | import java.io.File; 12 | import java.io.IOException; 13 | import java.nio.file.Files; 14 | import java.nio.file.InvalidPathException; 15 | import java.nio.file.Path; 16 | import java.util.Arrays; 17 | import java.util.Collection; 18 | import java.util.Collections; 19 | 20 | /** 21 | * Support class for "project unaware" Mojos (not needing project). 22 | */ 23 | public abstract class GavMojoSupport extends MojoSupport { 24 | /** 25 | * Splits comma separated string into elements. 26 | */ 27 | protected Collection csv(String csv) { 28 | if (csv == null || csv.trim().isEmpty()) { 29 | return Collections.emptyList(); 30 | } 31 | return Arrays.asList(csv.split(",")); 32 | } 33 | /** 34 | * Slurps, either comma separated string, or if value is existing file, will read 35 | * up the file with values on separate lines. 36 | */ 37 | protected Collection slurp(String csv) throws IOException { 38 | if (csv == null || csv.trim().isEmpty()) { 39 | return Collections.emptyList(); 40 | } 41 | try { 42 | Path target = Path.of(csv).toAbsolutePath(); 43 | if (Files.isRegularFile(target) && Files.size(target) < 5_000_000) { 44 | return Files.readAllLines(target); 45 | } 46 | } catch (InvalidPathException e) { 47 | // ignore 48 | } 49 | return csv(csv); 50 | } 51 | 52 | protected ProjectArtifacts projectArtifacts(String gav, File jar, File pom, File sources, File javadoc) { 53 | ProjectArtifacts.Builder builder = new ProjectArtifacts.Builder(gav); 54 | builder.addMain(jar.toPath()); 55 | if (pom != null) { 56 | builder.addPom(pom.toPath()); 57 | } 58 | if (sources != null) { 59 | builder.addSources(sources.toPath()); 60 | } 61 | if (javadoc != null) { 62 | builder.addJavadoc(javadoc.toPath()); 63 | } 64 | return builder.build(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/GavSearchMojoSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin; 9 | 10 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 11 | import org.apache.maven.plugins.annotations.Parameter; 12 | import org.eclipse.aether.repository.RemoteRepository; 13 | import picocli.CommandLine; 14 | 15 | /** 16 | * Support class for "project unaware" search Mojos. 17 | */ 18 | public abstract class GavSearchMojoSupport extends GavMojoSupport { 19 | /** 20 | * A repository ID. Maybe a "well known" one, or if all repository data given, a new one. 21 | */ 22 | @CommandLine.Option( 23 | names = {"--repositoryId"}, 24 | defaultValue = "central", 25 | description = "A repository ID. Maybe a 'well known' one, or if all repository data given, a new one") 26 | @Parameter(property = "repositoryId", defaultValue = "central") 27 | protected String repositoryId; 28 | 29 | /** 30 | * The base URI of the remote repository. 31 | */ 32 | @CommandLine.Option( 33 | names = {"--repositoryBaseUri"}, 34 | description = "The base URI of the remote repository") 35 | @Parameter(property = "repositoryBaseUri") 36 | protected String repositoryBaseUri; 37 | 38 | /** 39 | * The vendor of the remote repository. 40 | */ 41 | @CommandLine.Option( 42 | names = {"--repositoryVendor"}, 43 | description = "The vendor of the remote repository") 44 | @Parameter(property = "repositoryVendor", alias = "toolbox.search.backend.type") 45 | protected String repositoryVendor; 46 | 47 | protected RemoteRepository getRemoteRepository(ToolboxCommando toolboxCommando) { 48 | RemoteRepository remoteRepository = 49 | toolboxCommando.getKnownSearchRemoteRepositories().get(repositoryId); 50 | if (remoteRepository != null) { 51 | return remoteRepository; 52 | } 53 | if (repositoryBaseUri == null && repositoryVendor == null) { 54 | throw new IllegalArgumentException("for new remote repository one must specify all information"); 55 | } 56 | return toolboxCommando.parseRemoteRepository(repositoryId + "::" + repositoryVendor + "::" + repositoryBaseUri); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/OutputFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin; 9 | 10 | import static java.util.Objects.requireNonNull; 11 | 12 | import eu.maveniverse.maven.toolbox.shared.output.AnsiOutput; 13 | import eu.maveniverse.maven.toolbox.shared.output.LoggerOutput; 14 | import eu.maveniverse.maven.toolbox.shared.output.Output; 15 | import eu.maveniverse.maven.toolbox.shared.output.PrintStreamOutput; 16 | import org.jline.jansi.Ansi; 17 | import org.slf4j.Logger; 18 | import org.slf4j.LoggerFactory; 19 | 20 | /** 21 | * Factory for {@link Output}. 22 | */ 23 | public final class OutputFactory { 24 | private OutputFactory() {} 25 | 26 | private static void dumpOutputStatus(Output output) { 27 | if (output.isHeard(Output.Verbosity.CHATTER)) { 28 | output.chatter("Using output {}", output.getClass().getSimpleName()); 29 | output.chatter("Output verbosity '{}'", output.getVerbosity()); 30 | output.chatter("ANSI detected={} and enabled={}", Ansi.isDetected(), Ansi.isEnabled()); 31 | } 32 | } 33 | 34 | /** 35 | * When running as Mojo, Maven set up {@link Logger} for us. 36 | */ 37 | public static Output createMojoOutput(boolean batchMode, boolean errors, Output.Verbosity verbosity) { 38 | requireNonNull(verbosity, "verbosity"); 39 | Output output = new LoggerOutput(LoggerFactory.getLogger(OutputFactory.class), errors, verbosity); 40 | if (!batchMode && System.console() != null) { 41 | if (!Ansi.isEnabled()) { 42 | Ansi.setEnabled(true); 43 | } 44 | output = new AnsiOutput(output); 45 | } 46 | dumpOutputStatus(output); 47 | return output; 48 | } 49 | 50 | /** 51 | * When running as CLI, we need to set up ourselves fully. 52 | */ 53 | public static Output createCliOutput(boolean batchMode, boolean errors, Output.Verbosity verbosity) { 54 | requireNonNull(verbosity, "verbosity"); 55 | Output output = new PrintStreamOutput(System.out, verbosity, errors); 56 | if (!batchMode && System.console() != null) { 57 | if (!Ansi.isEnabled()) { 58 | Ansi.setEnabled(true); 59 | } 60 | output = new AnsiOutput(output); 61 | } 62 | dumpOutputStatus(output); 63 | return output; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavArtifactPathMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import java.nio.file.Path; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import org.eclipse.aether.artifact.DefaultArtifact; 17 | import org.eclipse.aether.repository.RemoteRepository; 18 | import picocli.CommandLine; 19 | 20 | /** 21 | * Prints expected relative path for a given Maven Artifact in a local repository. 22 | */ 23 | @CommandLine.Command( 24 | name = "artifact-path", 25 | description = "Prints expected relative path for a given Maven Artifact in a local repository") 26 | @Mojo(name = "gav-artifact-path", requiresProject = false, threadSafe = true) 27 | public class GavArtifactPathMojo extends GavMojoSupport { 28 | /** 29 | * The GAV of artifact. 30 | */ 31 | @CommandLine.Parameters(index = "0", description = "The Artifact coordinates", arity = "1") 32 | @Parameter(property = "gav", required = true) 33 | private String gav; 34 | 35 | /** 36 | * The optional remote repository spec string. It is expected to be in form of {@code id::url}, but we are really 37 | * interested in repository ID only. 38 | */ 39 | @CommandLine.Option( 40 | names = {"--repository"}, 41 | description = 42 | "The optional remote repository spec string. It is expected to be in form of {@code id::url}, but we are really interested in repository ID only.") 43 | @Parameter(property = "repository") 44 | private String repository; 45 | 46 | @Override 47 | protected Result doExecute() throws Exception { 48 | ToolboxCommando toolboxCommando = getToolboxCommando(); 49 | RemoteRepository rr = null; 50 | if (repository != null) { 51 | rr = toolboxCommando.parseRemoteRepository(repository); 52 | } 53 | return toolboxCommando.artifactPath(new DefaultArtifact(gav), rr); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavClasspathMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.ResolutionScope; 12 | import eu.maveniverse.maven.toolbox.shared.Result; 13 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import picocli.CommandLine; 17 | 18 | /** 19 | * Resolves Maven Artifact and prints out the classpath. 20 | */ 21 | @CommandLine.Command(name = "classpath", description = "Resolves Maven Artifact and prints out the classpath") 22 | @Mojo(name = "gav-classpath", requiresProject = false, threadSafe = true) 23 | public class GavClasspathMojo extends GavMojoSupport { 24 | /** 25 | * The artifact coordinates in the format {@code :[:[:]]:} 26 | * to display tree for. 27 | */ 28 | @CommandLine.Parameters(index = "0", description = "The GAV to print classpath for") 29 | @Parameter(property = "gav", required = true) 30 | private String gav; 31 | 32 | /** 33 | * The resolution scope to display, accepted values are "runtime", "compile", "test", etc. 34 | */ 35 | @CommandLine.Option( 36 | names = {"--scope"}, 37 | defaultValue = "runtime", 38 | description = "Resolution scope to resolve (default 'runtime')") 39 | @Parameter(property = "scope", defaultValue = "runtime", required = true) 40 | private String scope; 41 | 42 | /** 43 | * Apply BOMs, if needed. Comma separated GAVs. 44 | */ 45 | @CommandLine.Option( 46 | names = {"--boms"}, 47 | defaultValue = "", 48 | description = "Comma separated list of BOMs to apply") 49 | @Parameter(property = "boms") 50 | private String boms; 51 | 52 | @Override 53 | protected Result doExecute() throws Exception { 54 | ToolboxCommando toolboxCommando = getToolboxCommando(); 55 | return toolboxCommando.classpath(ResolutionScope.parse(scope), toolboxCommando.loadGav(gav, slurp(boms))); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavCopyGavMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import eu.maveniverse.maven.toolbox.shared.internal.ArtifactSources; 14 | import java.util.List; 15 | import java.util.stream.Collectors; 16 | import org.apache.maven.plugins.annotations.Mojo; 17 | import org.apache.maven.plugins.annotations.Parameter; 18 | import org.eclipse.aether.artifact.Artifact; 19 | import picocli.CommandLine; 20 | 21 | /** 22 | * Resolves a given GAV and copies resulting artifact to target. 23 | */ 24 | @CommandLine.Command(name = "copy-gav", description = "Resolves Maven Artifact and copies it to target") 25 | @Mojo(name = "gav-copy-gav", requiresProject = false, threadSafe = true) 26 | public final class GavCopyGavMojo extends GavMojoSupport { 27 | /** 28 | * The sink spec. 29 | */ 30 | @CommandLine.Parameters(index = "0", description = "The sink spec", arity = "1") 31 | @Parameter(property = "sinkSpec", required = true) 32 | private String sinkSpec; 33 | 34 | /** 35 | * The comma separated GAVs to resolve. 36 | */ 37 | @CommandLine.Parameters(index = "1", description = "The comma separated GAVs to resolve", arity = "1") 38 | @Parameter(property = "gav", required = true) 39 | private String gav; 40 | 41 | @Override 42 | protected Result> doExecute() throws Exception { 43 | ToolboxCommando toolboxCommando = getToolboxCommando(); 44 | return toolboxCommando.copy( 45 | ArtifactSources.concatArtifactSource(slurp(gav).stream() 46 | .map(ArtifactSources::gavArtifactSource) 47 | .collect(Collectors.toList())), 48 | toolboxCommando.artifactSink(sinkSpec, dryRun)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavCopyMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import java.util.List; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import org.eclipse.aether.artifact.Artifact; 17 | import picocli.CommandLine; 18 | 19 | /** 20 | * Copies artifacts from a specified artifact source to specified artifact sink. 21 | */ 22 | @CommandLine.Command(name = "copy", description = "Copies from source to target") 23 | @Mojo(name = "gav-copy", requiresProject = false, threadSafe = true) 24 | public final class GavCopyMojo extends GavMojoSupport { 25 | /** 26 | * The source spec. 27 | */ 28 | @CommandLine.Parameters(index = "0", description = "The source spec", arity = "1") 29 | @Parameter(property = "sourceSpec", required = true) 30 | private String sourceSpec; 31 | 32 | /** 33 | * The sink spec. 34 | */ 35 | @CommandLine.Parameters(index = "1", description = "The sink spec", arity = "1") 36 | @Parameter(property = "sinkSpec", required = true) 37 | private String sinkSpec; 38 | 39 | @Override 40 | protected Result> doExecute() throws Exception { 41 | ToolboxCommando toolboxCommando = getToolboxCommando(); 42 | return toolboxCommando.copy( 43 | toolboxCommando.artifactSource(sourceSpec), toolboxCommando.artifactSink(sinkSpec, dryRun)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavCopyRecordedMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import java.util.List; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import org.eclipse.aether.artifact.Artifact; 17 | import picocli.CommandLine; 18 | 19 | /** 20 | * Copy all recorded Maven Artifacts to given sink. 21 | */ 22 | @CommandLine.Command(name = "copy-recorded", description = "Copies all recorded Maven Artifacts to specified sink") 23 | @Mojo(name = "gav-copy-recorded", requiresProject = false, threadSafe = true) 24 | public final class GavCopyRecordedMojo extends GavMojoSupport { 25 | /** 26 | * The sink spec. 27 | */ 28 | @CommandLine.Parameters(index = "0", description = "The sink spec", arity = "1") 29 | @Parameter(property = "sinkSpec", required = true) 30 | private String sinkSpec; 31 | 32 | @Override 33 | protected Result> doExecute() throws Exception { 34 | ToolboxCommando toolboxCommando = getToolboxCommando(); 35 | return toolboxCommando.copyRecorded(true, toolboxCommando.artifactSink(sinkSpec, dryRun)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavDeployRecordedMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import java.util.List; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import org.eclipse.aether.artifact.Artifact; 17 | import picocli.CommandLine; 18 | 19 | /** 20 | * Deploys all recorded Maven Artifacts to remote repository. 21 | */ 22 | @CommandLine.Command( 23 | name = "deploy-recorded", 24 | description = "Deploys all recorded Maven Artifacts to remote repository") 25 | @Mojo(name = "gav-deploy-recorded", requiresProject = false, threadSafe = true) 26 | public final class GavDeployRecordedMojo extends GavMojoSupport { 27 | /** 28 | * The RemoteRepository spec (id::url). 29 | */ 30 | @CommandLine.Parameters(index = "0", description = "The RemoteRepository spec (id::url)", arity = "1") 31 | @Parameter(property = "remoteRepositorySpec", required = true) 32 | private String remoteRepositorySpec; 33 | 34 | @Override 35 | protected Result> doExecute() throws Exception { 36 | ToolboxCommando toolboxCommando = getToolboxCommando(); 37 | return toolboxCommando.copyRecorded( 38 | true, toolboxCommando.artifactSink("deploy(" + remoteRepositorySpec + ")", dryRun)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavDmListMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import java.util.List; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import org.eclipse.aether.graph.Dependency; 17 | import picocli.CommandLine; 18 | 19 | /** 20 | * Displays dependency management list of Maven Artifact. 21 | */ 22 | @CommandLine.Command(name = "dm-list", description = "Displays dependency management list of Maven Artifact") 23 | @Mojo(name = "gav-dm-list", requiresProject = false, threadSafe = true) 24 | public class GavDmListMojo extends GavMojoSupport { 25 | /** 26 | * The GAV to show tree for. 27 | */ 28 | @CommandLine.Parameters(index = "0", description = "The GAV to show dependency management list for", arity = "1") 29 | @Parameter(property = "gav", required = true) 30 | private String gav; 31 | 32 | /** 33 | * Comma separated list of BOMs to apply. 34 | */ 35 | @CommandLine.Option( 36 | names = {"--boms"}, 37 | defaultValue = "", 38 | description = "Comma separated list of BOMs to apply") 39 | @Parameter(property = "boms") 40 | private String boms; 41 | 42 | /** 43 | * Set it {@code true} for verbose list. 44 | */ 45 | @CommandLine.Option( 46 | names = {"--verboseList"}, 47 | defaultValue = "false", 48 | description = "Make it true for verbose list") 49 | @Parameter(property = "verboseList", defaultValue = "false", required = true) 50 | private boolean verboseList; 51 | 52 | @Override 53 | protected Result> doExecute() throws Exception { 54 | ToolboxCommando toolboxCommando = getToolboxCommando(); 55 | return toolboxCommando.dmList(toolboxCommando.loadGav(gav, slurp(boms)), verboseList); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavDmTreeMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import org.apache.maven.plugins.annotations.Mojo; 14 | import org.apache.maven.plugins.annotations.Parameter; 15 | import org.eclipse.aether.collection.CollectResult; 16 | import picocli.CommandLine; 17 | 18 | /** 19 | * Displays dependency management tree of Maven Artifact. 20 | */ 21 | @CommandLine.Command(name = "dm-tree", description = "Displays dependency management tree of Maven Artifact") 22 | @Mojo(name = "gav-dm-tree", requiresProject = false, threadSafe = true) 23 | public class GavDmTreeMojo extends GavMojoSupport { 24 | /** 25 | * The GAV to show tree for. 26 | */ 27 | @CommandLine.Parameters(index = "0", description = "The GAV to show dependency management tree for", arity = "1") 28 | @Parameter(property = "gav", required = true) 29 | private String gav; 30 | 31 | /** 32 | * Comma separated list of BOMs to apply. 33 | */ 34 | @CommandLine.Option( 35 | names = {"--boms"}, 36 | defaultValue = "", 37 | description = "Comma separated list of BOMs to apply") 38 | @Parameter(property = "boms") 39 | private String boms; 40 | 41 | /** 42 | * Set it {@code true} for verbose tree. 43 | */ 44 | @CommandLine.Option( 45 | names = {"--verboseTree"}, 46 | defaultValue = "false", 47 | description = "Make it true for verbose tree") 48 | @Parameter(property = "verboseTree", defaultValue = "false", required = true) 49 | private boolean verboseTree; 50 | 51 | @Override 52 | protected Result doExecute() throws Exception { 53 | ToolboxCommando toolboxCommando = getToolboxCommando(); 54 | return toolboxCommando.dmTree(toolboxCommando.loadGav(gav, slurp(boms)), verboseTree); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavDumpMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import java.io.File; 13 | import java.io.IOException; 14 | import java.io.OutputStream; 15 | import java.nio.file.Files; 16 | import java.util.Collections; 17 | import java.util.Map; 18 | import java.util.Properties; 19 | import org.apache.maven.plugins.annotations.Mojo; 20 | import org.apache.maven.plugins.annotations.Parameter; 21 | import picocli.CommandLine; 22 | 23 | /** 24 | * Dumps MIMA environment. 25 | */ 26 | @CommandLine.Command(name = "dump", description = "Dump MIMA environment") 27 | @Mojo(name = "gav-dump", requiresProject = false, threadSafe = true) 28 | public class GavDumpMojo extends GavMojoSupport { 29 | /** 30 | * Output it as Java Properties format. 31 | */ 32 | @CommandLine.Option( 33 | names = {"--asProperties"}, 34 | defaultValue = "false", 35 | description = "Output it as Java Properties format") 36 | @Parameter(property = "asProperties", defaultValue = "false", required = true) 37 | private boolean asProperties; 38 | 39 | /** 40 | * Output it into given file (only if asProperties=true). 41 | */ 42 | @CommandLine.Option( 43 | names = {"--toFile"}, 44 | description = "Output it into given file (only if asProperties=true)") 45 | @Parameter(property = "toFile") 46 | private File toFile; 47 | 48 | @Override 49 | protected Result doExecute() throws IOException { 50 | if (asProperties) { 51 | Result> result = getToolboxCommando().dumpAsMap(); 52 | Properties properties = new Properties(); 53 | properties.putAll(result.getData().orElse(Collections.emptyMap())); 54 | if (toFile != null) { 55 | toFile.getParentFile().mkdirs(); 56 | try (OutputStream fos = Files.newOutputStream(toFile.toPath())) { 57 | properties.store(fos, "Toolbox dump"); 58 | } 59 | } else { 60 | properties.store(System.out, "Toolbox dump"); 61 | } 62 | return Result.success("success"); 63 | } else { 64 | // dumps to console for human consumption 65 | return getToolboxCommando().dump(); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavEffectiveModelMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import org.apache.maven.model.Model; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import picocli.CommandLine; 17 | 18 | /** 19 | * Shows effective model for given GAV. 20 | */ 21 | @CommandLine.Command(name = "effective-model", description = "Shows model of Maven Artifact") 22 | @Mojo(name = "gav-effective-model", requiresProject = false, threadSafe = true) 23 | public class GavEffectiveModelMojo extends GavMojoSupport { 24 | /** 25 | * The GAV to check for. 26 | */ 27 | @CommandLine.Parameters(index = "0", description = "The GAV to check for") 28 | @Parameter(property = "gav", required = true) 29 | private String gav; 30 | 31 | @Override 32 | protected Result doExecute() throws Exception { 33 | ToolboxCommando toolboxCommando = getToolboxCommando(); 34 | return toolboxCommando.effectiveModel(toolboxCommando.loadGav(gav)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavFlattenBomMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import org.apache.maven.model.Model; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import org.eclipse.aether.artifact.DefaultArtifact; 17 | import picocli.CommandLine; 18 | 19 | /** 20 | * Flattens a BOM. 21 | */ 22 | @CommandLine.Command(name = "flatten-bom", description = "Flattens a BOM") 23 | @Mojo(name = "gav-flatten-bom", requiresProject = false, threadSafe = true) 24 | public class GavFlattenBomMojo extends GavMojoSupport { 25 | /** 26 | * The GAV to emit flattened BOM with. 27 | */ 28 | @CommandLine.Parameters( 29 | index = "0", 30 | defaultValue = "org.acme:acme:1.0", 31 | description = "The GAV to emit flattened BOM with") 32 | @Parameter(property = "gav", defaultValue = "org.acme:acme:1.0") 33 | private String gav; 34 | 35 | /** 36 | * The GAV of BOM to flatten. 37 | */ 38 | @CommandLine.Parameters(index = "0", description = "The GAV of BOM to flatten") 39 | @Parameter(property = "bom", required = true) 40 | private String bom; 41 | 42 | @Override 43 | protected Result doExecute() throws Exception { 44 | ToolboxCommando toolboxCommando = getToolboxCommando(); 45 | return toolboxCommando.flattenBOM(new DefaultArtifact(gav), toolboxCommando.loadGav(bom)); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavIdentifyMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavSearchMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import java.io.IOException; 14 | import java.util.Map; 15 | import org.apache.maven.plugins.annotations.Mojo; 16 | import org.apache.maven.plugins.annotations.Parameter; 17 | import org.eclipse.aether.artifact.Artifact; 18 | import picocli.CommandLine; 19 | 20 | /** 21 | * Identify artifact, either by provided SHA-1 or calculated SHA-1 of a file pointed at. 22 | */ 23 | @CommandLine.Command( 24 | name = "identify", 25 | description = "Identify artifact, either by provided SHA-1 or calculated SHA-1 of a file pointed at") 26 | @Mojo(name = "gav-identify", requiresProject = false, threadSafe = true) 27 | public class GavIdentifyMojo extends GavSearchMojoSupport { 28 | /** 29 | * Target, SHA-1 checksum or a file (comma separated if more). 30 | */ 31 | @CommandLine.Parameters(index = "0", description = "Target, a SHA-1 checksum or a file (comma separated if more)") 32 | @Parameter(property = "target", required = true) 33 | private String target; 34 | 35 | @CommandLine.Option( 36 | names = {"-d", "--decorated"}, 37 | description = "Decorate the output") 38 | @Parameter(property = "decorated") 39 | private boolean decorated; 40 | 41 | @Override 42 | protected Result> doExecute() throws IOException { 43 | ToolboxCommando toolboxCommando = getToolboxCommando(); 44 | return toolboxCommando.identify(getRemoteRepository(toolboxCommando), csv(target), decorated); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavInstallMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import java.io.File; 14 | import java.util.List; 15 | import org.apache.maven.plugins.annotations.Mojo; 16 | import org.apache.maven.plugins.annotations.Parameter; 17 | import org.eclipse.aether.artifact.Artifact; 18 | import picocli.CommandLine; 19 | 20 | /** 21 | * Installs an artifact into local repository. 22 | */ 23 | @CommandLine.Command(name = "install", description = "Installs an artifact into local repository") 24 | @Mojo(name = "gav-install", requiresProject = false, threadSafe = true) 25 | public final class GavInstallMojo extends GavMojoSupport { 26 | 27 | /** 28 | * The GAV to deploy to. 29 | */ 30 | @CommandLine.Parameters(index = "0", description = "The GAV to install to", arity = "1") 31 | @Parameter(property = "gav", required = true) 32 | private String gav; 33 | 34 | /** 35 | * The artifact JAR file. 36 | */ 37 | @CommandLine.Parameters(index = "1", description = "The artifact JAR file", arity = "1") 38 | @Parameter(property = "jar", required = true) 39 | private File jar; 40 | 41 | /** 42 | * The POM file. 43 | */ 44 | @CommandLine.Option( 45 | names = {"--pom"}, 46 | description = "The POM file") 47 | @Parameter(property = "pom") 48 | private File pom; 49 | 50 | /** 51 | * The sources JAR file. 52 | */ 53 | @CommandLine.Option( 54 | names = {"--sources"}, 55 | description = "The sources JAR file") 56 | @Parameter(property = "sources") 57 | private File sources; 58 | 59 | /** 60 | * The javadoc JAR file. 61 | */ 62 | @CommandLine.Option( 63 | names = {"--javadoc"}, 64 | description = "The javadoc JAR file") 65 | @Parameter(property = "javadoc") 66 | private File javadoc; 67 | 68 | @Override 69 | protected Result> doExecute() throws Exception { 70 | ToolboxCommando toolboxCommando = getToolboxCommando(); 71 | return toolboxCommando.copy( 72 | projectArtifacts(gav, jar, pom, sources, javadoc), toolboxCommando.artifactSink("install()", dryRun)); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavListMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavSearchMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import java.util.List; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import picocli.CommandLine; 17 | 18 | /** 19 | * Lists remote repository by given "gavoid" (G or G:A or G:A:V where V may be a version constraint). 20 | */ 21 | @CommandLine.Command( 22 | name = "list", 23 | description = "Lists remote repository by given 'gavoid' (G or G:A or G:A:V where V may be version constraint)") 24 | @Mojo(name = "gav-list", requiresProject = false, threadSafe = true) 25 | public class GavListMojo extends GavSearchMojoSupport { 26 | /** 27 | * The GAV-oid to list (G or G:A or G:A:V), where V may be a version constraint. 28 | */ 29 | @CommandLine.Parameters(index = "0", description = "The GAV-oid to list (G or G:A or G:A:V)") 30 | @Parameter(property = "gavoid", required = true) 31 | private String gavoid; 32 | 33 | @Override 34 | protected Result> doExecute() throws Exception { 35 | ToolboxCommando toolboxCommando = getToolboxCommando(); 36 | return toolboxCommando.list(getRemoteRepository(toolboxCommando), gavoid, null); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavListRepositoriesMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.ResolutionScope; 12 | import eu.maveniverse.maven.toolbox.shared.Result; 13 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 14 | import java.util.List; 15 | import org.apache.maven.plugins.annotations.Mojo; 16 | import org.apache.maven.plugins.annotations.Parameter; 17 | import org.eclipse.aether.repository.RemoteRepository; 18 | import picocli.CommandLine; 19 | 20 | /** 21 | * Lists repositories used to resolve given GAV. 22 | */ 23 | @CommandLine.Command(name = "list-repositories", description = "Lists repositories used to resolve given GAV") 24 | @Mojo(name = "gav-list-repositories", requiresProject = false, threadSafe = true) 25 | public final class GavListRepositoriesMojo extends GavMojoSupport { 26 | /** 27 | * The GAV to list repositories for. 28 | */ 29 | @CommandLine.Parameters(index = "0", description = "The GAV to list repositories for") 30 | @Parameter(property = "gav", required = true) 31 | private String gav; 32 | 33 | /** 34 | * Resolution scope to resolve (default 'runtime'). 35 | */ 36 | @CommandLine.Option( 37 | names = {"--scope"}, 38 | defaultValue = "runtime", 39 | description = "Resolution scope to resolve (default 'runtime')") 40 | @Parameter(property = "scope", defaultValue = "runtime", required = true) 41 | private String scope; 42 | 43 | /** 44 | * Comma separated list of BOMs to apply. 45 | */ 46 | @CommandLine.Option( 47 | names = {"--boms"}, 48 | defaultValue = "", 49 | description = "Comma separated list of BOMs to apply") 50 | @Parameter(property = "boms", defaultValue = "") 51 | private String boms; 52 | 53 | @Override 54 | protected Result> doExecute() throws Exception { 55 | ToolboxCommando toolboxCommando = getToolboxCommando(); 56 | return toolboxCommando.listRepositories( 57 | ResolutionScope.parse(scope), "GAV", toolboxCommando.loadGav(gav, slurp(boms))); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavLocalRepositoryPathMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import java.nio.file.Path; 13 | import org.apache.maven.plugins.annotations.Mojo; 14 | import picocli.CommandLine; 15 | 16 | /** 17 | * Prints Maven Local Repository basedir. 18 | */ 19 | @CommandLine.Command(name = "local-repository-path", description = "Prints Maven Local Repository basedir") 20 | @Mojo(name = "gav-local-repository-path", requiresProject = false, threadSafe = true) 21 | public class GavLocalRepositoryPathMojo extends GavMojoSupport { 22 | @Override 23 | protected Result doExecute() throws Exception { 24 | return getToolboxCommando().localRepository(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavRecordMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import org.apache.maven.plugins.annotations.Mojo; 14 | import org.apache.maven.plugins.annotations.Parameter; 15 | import org.eclipse.aether.resolution.DependencyResolutionException; 16 | import picocli.CommandLine; 17 | 18 | /** 19 | * Controls recording of resolved Maven Artifacts. 20 | */ 21 | @CommandLine.Command(name = "record", description = "Controls recording of resolved Maven Artifacts") 22 | @Mojo(name = "gav-record", requiresProject = false, threadSafe = true) 23 | public final class GavRecordMojo extends GavMojoSupport { 24 | 25 | /** 26 | * Stops recording if set, otherwise starts it. 27 | */ 28 | @CommandLine.Option( 29 | names = {"--start"}, 30 | description = "Starts recording") 31 | @Parameter(property = "start", defaultValue = "false", required = true) 32 | private boolean start; 33 | 34 | /** 35 | * Stops recording if set, otherwise starts it. 36 | */ 37 | @CommandLine.Option( 38 | names = {"--stop"}, 39 | description = "Stops recording") 40 | @Parameter(property = "stop", defaultValue = "false", required = true) 41 | private boolean stop; 42 | 43 | @Override 44 | protected Result doExecute() throws DependencyResolutionException { 45 | ToolboxCommando toolboxCommando = getToolboxCommando(); 46 | if (stop) { 47 | return toolboxCommando.recordStop(); 48 | } else if (start) { 49 | return toolboxCommando.recordStart(); 50 | } else { 51 | return toolboxCommando.recordStats(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavSearchMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavSearchMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import java.io.IOException; 14 | import java.util.List; 15 | import org.apache.maven.plugins.annotations.Mojo; 16 | import org.apache.maven.plugins.annotations.Parameter; 17 | import org.eclipse.aether.artifact.Artifact; 18 | import picocli.CommandLine; 19 | 20 | /** 21 | * Searches Maven Artifacts using SMO service. 22 | */ 23 | @CommandLine.Command(name = "search", description = "Searches Maven Artifacts using SMO service") 24 | @Mojo(name = "gav-search", requiresProject = false, threadSafe = true) 25 | public class GavSearchMojo extends GavSearchMojoSupport { 26 | /** 27 | * The expression to search for. 28 | */ 29 | @CommandLine.Parameters(index = "0", description = "The expression to search for") 30 | @Parameter(property = "expression", required = true) 31 | private String expression; 32 | 33 | @Override 34 | protected Result> doExecute() throws IOException { 35 | ToolboxCommando toolboxCommando = getToolboxCommando(); 36 | return toolboxCommando.search(getRemoteRepository(toolboxCommando), expression); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/GavVerifyMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.gav; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.GavSearchMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import java.io.IOException; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import picocli.CommandLine; 17 | 18 | /** 19 | * Verifies Maven Artifact against known SHA-1 using origin repository. 20 | */ 21 | @CommandLine.Command( 22 | name = "verify", 23 | description = "Verifies Maven Artifact against known SHA-1 using origin repository") 24 | @Mojo(name = "gav-verify", requiresProject = false, threadSafe = true) 25 | public class GavVerifyMojo extends GavSearchMojoSupport { 26 | /** 27 | * The GAV to verify. 28 | */ 29 | @CommandLine.Parameters(index = "0", description = "The GAV to show tree for", arity = "1") 30 | @Parameter(property = "gav", required = true) 31 | private String gav; 32 | 33 | /** 34 | * The locally known SHA-1 of GAV. 35 | */ 36 | @CommandLine.Parameters(index = "1", description = "The locally known SHA-1 of GAV") 37 | @Parameter(property = "sha1", required = true) 38 | private String sha1; 39 | 40 | @Override 41 | protected Result doExecute() throws IOException { 42 | ToolboxCommando toolboxCommando = getToolboxCommando(); 43 | return toolboxCommando.verify(getRemoteRepository(toolboxCommando), gav, sha1, null); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/gav/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | 9 | /** 10 | * The GAV package contains classes that are Mojos but also Picocli Commands. When executed within Maven 11 | * as Mojos, these do NOT require a project, instead usually as for "gav" input. Hence, the name package name. 12 | */ 13 | package eu.maveniverse.maven.toolbox.plugin.gav; 14 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/hello/AddCoreExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.hello; 9 | 10 | import eu.maveniverse.maven.toolbox.shared.Result; 11 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 12 | import java.nio.file.Path; 13 | import java.util.List; 14 | import java.util.Locale; 15 | import org.apache.maven.plugins.annotations.Mojo; 16 | import org.apache.maven.plugins.annotations.Parameter; 17 | import org.eclipse.aether.artifact.Artifact; 18 | import picocli.CommandLine; 19 | 20 | /** 21 | * Adds core extension. 22 | */ 23 | @CommandLine.Command(name = "add-core-extension", description = "Adds core extension") 24 | @Mojo(name = "add-core-extension", requiresProject = false, threadSafe = true) 25 | public class AddCoreExtension extends HelloProjectMojoSupport { 26 | /** 27 | * The extension GAV. 28 | */ 29 | @CommandLine.Parameters(index = "0", description = "The extension GAV", arity = "1") 30 | @Parameter(property = "gav", required = true) 31 | private String gav; 32 | 33 | /** 34 | * The scope where to look. 35 | */ 36 | @CommandLine.Option( 37 | names = {"scope"}, 38 | defaultValue = "project", 39 | description = "The scope where to look.") 40 | @Parameter(property = "scope", defaultValue = "project") 41 | private String scope; 42 | 43 | @Override 44 | protected Result doExecute() throws Exception { 45 | ToolboxCommando toolboxCommando = getToolboxCommando(); 46 | Artifact extension = toCoreExtensionArtifact(gav); 47 | ToolboxCommando.ExtensionsScope extensionsScope = 48 | ToolboxCommando.ExtensionsScope.valueOf(scope.toUpperCase(Locale.ROOT)); 49 | Path extensionsXml; 50 | if (extensionsScope == ToolboxCommando.ExtensionsScope.PROJECT) { 51 | extensionsXml = getRootPom().getParent().resolve(".mvn").resolve("extensions.xml"); 52 | } else { 53 | extensionsXml = toolboxCommando.extensionsPath(extensionsScope); 54 | } 55 | 56 | try (ToolboxCommando.EditSession editSession = getToolboxCommando().createEditSession(extensionsXml)) { 57 | toolboxCommando.editExtensions(editSession, ToolboxCommando.Op.UPSERT, List.of(extension)::stream); 58 | } 59 | return Result.success(Boolean.TRUE); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/hello/AddManagedDependency.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.hello; 9 | 10 | import eu.maveniverse.maven.toolbox.shared.Result; 11 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 12 | import eu.maveniverse.maven.toolbox.shared.internal.jdom.JDomDocumentIO; 13 | import eu.maveniverse.maven.toolbox.shared.internal.jdom.JDomPomEditor; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import org.eclipse.aether.artifact.Artifact; 17 | import picocli.CommandLine; 18 | 19 | /** 20 | * Adds managed dependency. 21 | */ 22 | @CommandLine.Command(name = "add-managed-dependency", description = "Adds managed dependency") 23 | @Mojo(name = "add-managed-dependency", requiresProject = false, threadSafe = true) 24 | public class AddManagedDependency extends HelloProjectMojoSupport { 25 | /** 26 | * The dependency GAV. 27 | */ 28 | @CommandLine.Parameters(index = "0", description = "The dependency GAV", arity = "1") 29 | @Parameter(property = "gav", required = true) 30 | private String gav; 31 | 32 | @Override 33 | protected Result doExecute() throws Exception { 34 | Artifact dependency = toDependencyArtifact(gav); 35 | try (ToolboxCommando.EditSession editSession = getToolboxCommando().createEditSession(getRootPom())) { 36 | editSession.edit(p -> { 37 | try (JDomDocumentIO documentIO = new JDomDocumentIO(p)) { 38 | JDomPomEditor.updateManagedDependency( 39 | documentIO.getDocument().getRootElement(), dependency, true); 40 | } 41 | }); 42 | } 43 | return Result.success(Boolean.TRUE); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/hello/AddManagedPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.hello; 9 | 10 | import eu.maveniverse.maven.toolbox.shared.Result; 11 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 12 | import eu.maveniverse.maven.toolbox.shared.internal.jdom.JDomDocumentIO; 13 | import eu.maveniverse.maven.toolbox.shared.internal.jdom.JDomPomEditor; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import org.eclipse.aether.artifact.Artifact; 17 | import picocli.CommandLine; 18 | 19 | /** 20 | * Adds managed plugin. 21 | */ 22 | @CommandLine.Command(name = "add-managed-plugin", description = "Adds managed plugin") 23 | @Mojo(name = "add-managed-plugin", requiresProject = false, threadSafe = true) 24 | public class AddManagedPlugin extends HelloProjectMojoSupport { 25 | /** 26 | * The plugin GAV. 27 | */ 28 | @CommandLine.Parameters(index = "0", description = "The plugin GAV", arity = "1") 29 | @Parameter(property = "gav", required = true) 30 | private String gav; 31 | 32 | @Override 33 | protected Result doExecute() throws Exception { 34 | Artifact plugin = toPluginArtifact(gav); 35 | try (ToolboxCommando.EditSession editSession = getToolboxCommando().createEditSession(getRootPom())) { 36 | editSession.edit(p -> { 37 | try (JDomDocumentIO documentIO = new JDomDocumentIO(p)) { 38 | JDomPomEditor.updateManagedPlugin(documentIO.getDocument().getRootElement(), plugin, true); 39 | } 40 | }); 41 | } 42 | return Result.success(Boolean.TRUE); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/hello/RemoveCoreExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.hello; 9 | 10 | import eu.maveniverse.maven.toolbox.shared.Result; 11 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 12 | import java.nio.file.Path; 13 | import java.util.List; 14 | import java.util.Locale; 15 | import org.apache.maven.plugins.annotations.Mojo; 16 | import org.apache.maven.plugins.annotations.Parameter; 17 | import org.eclipse.aether.artifact.Artifact; 18 | import picocli.CommandLine; 19 | 20 | /** 21 | * Removes core extension. 22 | */ 23 | @CommandLine.Command(name = "remove-core-extension", description = "Removes core extension") 24 | @Mojo(name = "remove-core-extension", requiresProject = false, threadSafe = true) 25 | public class RemoveCoreExtension extends HelloProjectMojoSupport { 26 | /** 27 | * The extension GAV. 28 | */ 29 | @CommandLine.Parameters(index = "0", description = "The extension GAV", arity = "1") 30 | @Parameter(property = "gav", required = true) 31 | private String gav; 32 | 33 | /** 34 | * The scope where to look. 35 | */ 36 | @CommandLine.Option( 37 | names = {"scope"}, 38 | defaultValue = "project", 39 | description = "The scope where to look.") 40 | @Parameter(property = "scope", defaultValue = "project") 41 | private String scope; 42 | 43 | @Override 44 | protected Result doExecute() throws Exception { 45 | ToolboxCommando toolboxCommando = getToolboxCommando(); 46 | Artifact extension = toCoreExtensionArtifact(gav); 47 | ToolboxCommando.ExtensionsScope extensionsScope = 48 | ToolboxCommando.ExtensionsScope.valueOf(scope.toUpperCase(Locale.ROOT)); 49 | Path extensionsXml; 50 | if (extensionsScope == ToolboxCommando.ExtensionsScope.PROJECT) { 51 | extensionsXml = getRootPom().getParent().resolve(".mvn").resolve("extensions.xml"); 52 | } else { 53 | extensionsXml = toolboxCommando.extensionsPath(extensionsScope); 54 | } 55 | 56 | try (ToolboxCommando.EditSession editSession = getToolboxCommando().createEditSession(extensionsXml)) { 57 | toolboxCommando.editExtensions(editSession, ToolboxCommando.Op.DELETE, List.of(extension)::stream); 58 | } 59 | return Result.success(Boolean.TRUE); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/hello/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | 9 | /** 10 | * This package contains Picocli commands only, part of "Hello Maven" stuff. 11 | */ 12 | package eu.maveniverse.maven.toolbox.plugin.hello; 13 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/ClasspathMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.ResolutionScope; 12 | import eu.maveniverse.maven.toolbox.shared.Result; 13 | import org.apache.maven.plugins.annotations.Mojo; 14 | import org.apache.maven.plugins.annotations.Parameter; 15 | 16 | /** 17 | * Prints the classpath of current project. 18 | */ 19 | @Mojo(name = "classpath", threadSafe = true) 20 | public class ClasspathMojo extends MPMojoSupport { 21 | /** 22 | * The resolution scope to display, accepted values are "runtime", "compile", "test", etc. 23 | */ 24 | @Parameter(property = "scope", defaultValue = "runtime", required = true) 25 | private String scope; 26 | 27 | @Override 28 | protected Result doExecute() throws Exception { 29 | return getToolboxCommando().classpath(ResolutionScope.parse(scope), projectAsResolutionRoot()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/CopyDependenciesMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import java.util.List; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import org.eclipse.aether.artifact.Artifact; 17 | 18 | /** 19 | * Resolves selected dependencies and copies resulting artifacts to target. 20 | */ 21 | @Mojo(name = "copy-dependencies", threadSafe = true) 22 | public final class CopyDependenciesMojo extends MPMojoSupport { 23 | 24 | /** 25 | * The artifact sink spec (default: "null()"). 26 | */ 27 | @Parameter(property = "sinkSpec", defaultValue = "null()", required = true) 28 | private String sinkSpec; 29 | 30 | /** 31 | * The dependency matcher spec. 32 | */ 33 | @Parameter(property = "depSpec", defaultValue = "any()") 34 | private String depSpec; 35 | 36 | @Override 37 | protected Result> doExecute() throws Exception { 38 | ToolboxCommando toolboxCommando = getToolboxCommando(); 39 | return toolboxCommando.copy( 40 | () -> projectAsResolutionRoot().getDependencies().stream() 41 | .filter(toolboxCommando.parseDependencyMatcherSpec(depSpec)) 42 | .map(toolboxCommando::toArtifact), 43 | toolboxCommando.artifactSink(sinkSpec, dryRun)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/CopyTransitiveMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.ResolutionScope; 12 | import eu.maveniverse.maven.toolbox.shared.Result; 13 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 14 | import java.util.List; 15 | import org.apache.maven.plugins.annotations.Mojo; 16 | import org.apache.maven.plugins.annotations.Parameter; 17 | import org.eclipse.aether.artifact.Artifact; 18 | 19 | /** 20 | * Resolves selected dependencies transitively and copies all of them to target. 21 | */ 22 | @Mojo(name = "copy-transitive", threadSafe = true) 23 | public final class CopyTransitiveMojo extends MPMojoSupport { 24 | 25 | /** 26 | * The artifact sink spec (default: "null()"). 27 | */ 28 | @Parameter(property = "sinkSpec", defaultValue = "null()", required = true) 29 | private String sinkSpec; 30 | 31 | /** 32 | * The resolution scope to resolve (default is 'runtime'). 33 | */ 34 | @Parameter(property = "scope", defaultValue = "runtime", required = true) 35 | private String scope; 36 | 37 | /** 38 | * The dependency matcher spec. 39 | */ 40 | @Parameter(property = "depSpec", defaultValue = "any()") 41 | private String depSpec; 42 | 43 | @Override 44 | protected Result> doExecute() throws Exception { 45 | ToolboxCommando toolboxCommando = getToolboxCommando(); 46 | ResolutionScope resolutionScope = ResolutionScope.parse(scope); 47 | return toolboxCommando.copyTransitive( 48 | resolutionScope, 49 | projectDependenciesAsResolutionRoots(toolboxCommando.parseDependencyMatcherSpec(depSpec)), 50 | toolboxCommando.artifactSink(sinkSpec, dryRun)); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/DirtyTreeMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.ResolutionScope; 12 | import eu.maveniverse.maven.toolbox.shared.Result; 13 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import org.eclipse.aether.collection.CollectResult; 17 | 18 | /** 19 | * Displays dependency dirty tree of Maven Project. 20 | */ 21 | @Mojo(name = "dirty-tree", threadSafe = true) 22 | public class DirtyTreeMojo extends MPMojoSupport { 23 | /** 24 | * The resolution scope to display, accepted values are "runtime", "compile", "test", etc. 25 | */ 26 | @Parameter(property = "scope", defaultValue = "runtime", required = true) 27 | private String scope; 28 | 29 | /** 30 | * The dependency matcher if you want to filter as eager as Lenny wants. 31 | */ 32 | @Parameter(property = "dependencyMatcher", defaultValue = "any()", required = true) 33 | private String dependencyMatcher; 34 | 35 | /** 36 | * Set it {@code true} for verbose tree. 37 | */ 38 | @Parameter(property = "verboseTree", defaultValue = "false", required = true) 39 | private boolean verboseTree; 40 | 41 | /** 42 | * The level up to you want to see dirty tree. Note: keep it low, otherwise this call is OOM pronect. 43 | * Default: 3 44 | */ 45 | @Parameter(property = "dirtyLevel", defaultValue = "3", required = true) 46 | private int dirtyLevel; 47 | 48 | @Override 49 | protected Result doExecute() throws Exception { 50 | ToolboxCommando toolboxCommando = getToolboxCommando(); 51 | return toolboxCommando.dirtyTree( 52 | ResolutionScope.parse(scope), 53 | projectAsResolutionRoot(), 54 | dirtyLevel, 55 | verboseTree, 56 | toolboxCommando.parseDependencyMatcherSpec(dependencyMatcher)); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/DmListMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import java.util.List; 13 | import org.apache.maven.plugins.annotations.Mojo; 14 | import org.apache.maven.plugins.annotations.Parameter; 15 | import org.eclipse.aether.graph.Dependency; 16 | 17 | /** 18 | * Displays dependency management list of Maven Project. 19 | */ 20 | @Mojo(name = "dm-list", threadSafe = true) 21 | public class DmListMojo extends MPMojoSupport { 22 | /** 23 | * Set it {@code true} for verbose list. 24 | */ 25 | @Parameter(property = "verboseList", defaultValue = "false", required = true) 26 | private boolean verboseList; 27 | 28 | @Override 29 | protected Result> doExecute() throws Exception { 30 | return getToolboxCommando().dmList(projectAsResolutionRoot(), verboseList); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/DmTreeMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import org.apache.maven.plugins.annotations.Mojo; 13 | import org.apache.maven.plugins.annotations.Parameter; 14 | import org.eclipse.aether.collection.CollectResult; 15 | 16 | /** 17 | * Displays dependency management tree of Maven Project. 18 | */ 19 | @Mojo(name = "dm-tree", threadSafe = true) 20 | public class DmTreeMojo extends MPMojoSupport { 21 | /** 22 | * Set it {@code true} for verbose tree. 23 | */ 24 | @Parameter(property = "verboseTree", defaultValue = "false", required = true) 25 | private boolean verboseTree; 26 | 27 | @Override 28 | protected Result doExecute() throws Exception { 29 | return getToolboxCommando().dmTree(projectAsResolutionRoot(), verboseTree); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/DumpMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import java.io.File; 13 | import java.io.IOException; 14 | import java.io.OutputStream; 15 | import java.nio.file.Files; 16 | import java.util.Collections; 17 | import java.util.Map; 18 | import java.util.Properties; 19 | import org.apache.maven.plugins.annotations.Mojo; 20 | import org.apache.maven.plugins.annotations.Parameter; 21 | import picocli.CommandLine; 22 | 23 | /** 24 | * Dumps the MIMA environment. 25 | */ 26 | @Mojo(name = "dump", threadSafe = true) 27 | public class DumpMojo extends MPMojoSupport { 28 | /** 29 | * Output it as Java Properties format. 30 | */ 31 | @CommandLine.Option( 32 | names = {"--asProperties"}, 33 | defaultValue = "false", 34 | description = "Output it as Java Properties format") 35 | @Parameter(property = "asProperties", defaultValue = "false", required = true) 36 | private boolean asProperties; 37 | 38 | /** 39 | * Output it into given file (only if asProperties=true). 40 | */ 41 | @CommandLine.Option( 42 | names = {"--toFile"}, 43 | description = "Output it into given file (only if asProperties=true)") 44 | @Parameter(property = "toFile") 45 | private File toFile; 46 | 47 | @Override 48 | protected Result doExecute() throws IOException { 49 | if (asProperties) { 50 | Result> result = getToolboxCommando().dumpAsMap(); 51 | Properties properties = new Properties(); 52 | properties.putAll(result.getData().orElse(Collections.emptyMap())); 53 | if (toFile != null) { 54 | toFile.getParentFile().mkdirs(); 55 | try (OutputStream fos = Files.newOutputStream(toFile.toPath())) { 56 | properties.store(fos, "Toolbox dump"); 57 | } 58 | } else { 59 | properties.store(System.out, "Toolbox dump"); 60 | } 61 | return Result.success("success"); 62 | } else { 63 | // dumps to console for human consumption 64 | return getToolboxCommando().dump(); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/EffectiveModelAggregatorMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import org.apache.maven.model.Model; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | 17 | /** 18 | * Shows effective model for project; is aggregator mojo. 19 | */ 20 | @Mojo(name = "effective-model", aggregator = true, threadSafe = true) 21 | public class EffectiveModelAggregatorMojo extends MPMojoSupport { 22 | /** 23 | * Set the project selector, like {@code -rf} Maven command uses it, can be {@code :A} or {@code G:A}. If the 24 | * selector is set, it must match exactly one project within reactor, otherwise it will fail. By default, 25 | * selector is {@code null}, and Maven session "current project" is used. 26 | */ 27 | @Parameter(property = "selector") 28 | private String selector; 29 | 30 | @Override 31 | protected Result doExecute() throws Exception { 32 | ToolboxCommando toolboxCommando = getToolboxCommando(); 33 | return toolboxCommando.effectiveModel(getReactorLocator(selector)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/EffectiveModelMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import org.apache.maven.model.Model; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | 16 | /** 17 | * Shows effective model for project. 18 | */ 19 | @Mojo(name = "effective-model-all", threadSafe = true) 20 | public class EffectiveModelMojo extends MPMojoSupport { 21 | @Override 22 | protected Result doExecute() throws Exception { 23 | ToolboxCommando toolboxCommando = getToolboxCommando(); 24 | return toolboxCommando.effectiveModel(getReactorLocator(null)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/LibYearMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.ResolutionScope; 12 | import eu.maveniverse.maven.toolbox.shared.Result; 13 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | 17 | /** 18 | * Calculates "libyear" for Maven Projects (for direct dependencies or transitively). 19 | */ 20 | @Mojo(name = "libyear", threadSafe = true) 21 | public class LibYearMojo extends MPMojoSupport { 22 | /** 23 | * Resolution scope to resolve (default 'test'). 24 | */ 25 | @Parameter(property = "scope", defaultValue = "test", required = true) 26 | private String scope; 27 | 28 | /** 29 | * Artifact version matcher spec string to filter version candidates, default is 'noSnapshotsAndPreviews()'. 30 | */ 31 | @Parameter(property = "artifactVersionMatcherSpec", defaultValue = "noSnapshotsAndPreviews()") 32 | private String artifactVersionMatcherSpec; 33 | 34 | /** 35 | * Artifact version selector spec string to select "latest", default is 'major()'. 36 | */ 37 | @Parameter(property = "artifactVersionSelectorSpec", defaultValue = "major()") 38 | private String artifactVersionSelectorSpec; 39 | 40 | /** 41 | * Make libyear transitive, in which case it will calculate it for whole transitive hull. 42 | */ 43 | @Parameter(property = "transitive", defaultValue = "false") 44 | private boolean transitive; 45 | 46 | /** 47 | * Make libyear show up-to-date libraries with age as well. 48 | */ 49 | @Parameter(property = "upToDate", defaultValue = "false") 50 | private boolean upToDate; 51 | 52 | @Override 53 | protected Result doExecute() throws Exception { 54 | ToolboxCommando toolboxCommando = getToolboxCommando(); 55 | return toolboxCommando.libYear( 56 | "project " + mavenProject.getId(), 57 | ResolutionScope.parse(scope), 58 | projectAsResolutionRoot(), 59 | transitive, 60 | upToDate, 61 | toolboxCommando.parseArtifactVersionMatcherSpec(artifactVersionMatcherSpec), 62 | toolboxCommando.parseArtifactVersionSelectorSpec(artifactVersionSelectorSpec), 63 | getRepositoryVendor()); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/ListRepositoriesMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.ResolutionScope; 12 | import eu.maveniverse.maven.toolbox.shared.Result; 13 | import java.util.List; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import org.eclipse.aether.repository.RemoteRepository; 17 | 18 | /** 19 | * Resolves transitively current project and outputs used repositories. 20 | */ 21 | @Mojo(name = "list-repositories", threadSafe = true) 22 | public final class ListRepositoriesMojo extends MPMojoSupport { 23 | /** 24 | * The resolution scope to display, accepted values are "runtime", "compile", "test", etc. 25 | */ 26 | @Parameter(property = "scope", defaultValue = "runtime", required = true) 27 | private String scope; 28 | 29 | @Override 30 | protected Result> doExecute() throws Exception { 31 | return getToolboxCommando() 32 | .listRepositories(ResolutionScope.parse(scope), "project", projectAsResolutionRoot()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/ParentChildTreeMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import org.apache.maven.plugins.annotations.Mojo; 13 | import org.apache.maven.plugins.annotations.Parameter; 14 | import org.eclipse.aether.collection.CollectResult; 15 | 16 | /** 17 | * Displays project inheritance of Maven Projects. 18 | */ 19 | @Mojo(name = "parent-child-tree", aggregator = true, threadSafe = true) 20 | public class ParentChildTreeMojo extends MPMojoSupport { 21 | /** 22 | * Set the project selector, like {@code -rf} Maven command uses it, can be {@code :A} or {@code G:A}. If the 23 | * selector is set, it must match exactly one project within reactor, otherwise it will fail. By default, 24 | * selector is {@code null}, and Maven session "current project" is used. 25 | */ 26 | @Parameter(property = "selector") 27 | private String selector; 28 | 29 | @Override 30 | protected Result doExecute() throws Exception { 31 | return getToolboxCommando().parentChildTree(getReactorLocator(selector)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/PluginClasspathMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPPluginMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.ResolutionRoot; 12 | import eu.maveniverse.maven.toolbox.shared.ResolutionScope; 13 | import eu.maveniverse.maven.toolbox.shared.Result; 14 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 15 | import org.apache.maven.plugins.annotations.Mojo; 16 | import org.apache.maven.plugins.annotations.Parameter; 17 | 18 | /** 19 | * Resolves transitively a project given plugin and outputs its classpath. 20 | */ 21 | @Mojo(name = "plugin-classpath", threadSafe = true) 22 | public class PluginClasspathMojo extends MPPluginMojoSupport { 23 | /** 24 | * The resolution scope to display, accepted values are "runtime", "compile", "test", etc. 25 | */ 26 | @Parameter(property = "scope", defaultValue = "runtime", required = true) 27 | private String scope; 28 | 29 | @Override 30 | protected Result doExecute() throws Exception { 31 | ToolboxCommando toolboxCommando = getToolboxCommando(); 32 | ResolutionRoot root = pluginAsResolutionRoot(toolboxCommando, true); 33 | if (root != null) { 34 | return toolboxCommando.classpath(ResolutionScope.parse(scope), root); 35 | } else { 36 | return Result.failure("No such plugin"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/PluginListRepositoriesMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPPluginMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.ResolutionRoot; 12 | import eu.maveniverse.maven.toolbox.shared.ResolutionScope; 13 | import eu.maveniverse.maven.toolbox.shared.Result; 14 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 15 | import java.util.List; 16 | import org.apache.maven.plugins.annotations.Mojo; 17 | import org.apache.maven.plugins.annotations.Parameter; 18 | import org.eclipse.aether.repository.RemoteRepository; 19 | 20 | /** 21 | * Resolves transitively a project given plugin and outputs used repositories. 22 | */ 23 | @Mojo(name = "plugin-list-repositories", threadSafe = true) 24 | public final class PluginListRepositoriesMojo extends MPPluginMojoSupport { 25 | /** 26 | * The resolution scope to display, accepted values are "runtime", "compile", "test", etc. 27 | */ 28 | @Parameter(property = "scope", defaultValue = "runtime", required = true) 29 | private String scope; 30 | 31 | @Override 32 | protected Result> doExecute() throws Exception { 33 | ToolboxCommando toolboxCommando = getToolboxCommando(); 34 | ResolutionRoot root = pluginAsResolutionRoot(toolboxCommando, true); 35 | if (root != null) { 36 | return toolboxCommando.listRepositories(ResolutionScope.parse(scope), "plugin", root); 37 | } else { 38 | return Result.failure("No such plugin"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/PluginResolveMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPPluginMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.ResolutionRoot; 12 | import eu.maveniverse.maven.toolbox.shared.Result; 13 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 14 | import java.util.Collection; 15 | import java.util.Collections; 16 | import java.util.List; 17 | import java.util.stream.Collectors; 18 | import org.apache.maven.plugins.annotations.Mojo; 19 | import org.apache.maven.plugins.annotations.Parameter; 20 | import org.eclipse.aether.artifact.Artifact; 21 | 22 | /** 23 | * Resolves transitively given project build plugin. 24 | */ 25 | @Mojo(name = "plugin-resolve", threadSafe = true) 26 | public class PluginResolveMojo extends MPPluginMojoSupport { 27 | /** 28 | * Resolve sources JAR as well (derive coordinates from GAV). 29 | */ 30 | @Parameter(property = "sources", defaultValue = "false") 31 | private boolean sources; 32 | 33 | /** 34 | * Resolve javadoc JAR as well (derive coordinates from GAV). 35 | */ 36 | @Parameter(property = "javadoc", defaultValue = "false") 37 | private boolean javadoc; 38 | 39 | /** 40 | * Resolve GnuPG signature as well (derive coordinates from GAV). 41 | */ 42 | @Parameter(property = "signature", defaultValue = "false") 43 | private boolean signature; 44 | 45 | /** 46 | * The artifact sink spec (default: "null()"). 47 | */ 48 | @Parameter(property = "sinkSpec", defaultValue = "null()", required = true) 49 | private String sinkSpec; 50 | 51 | @Override 52 | protected Result> doExecute() throws Exception { 53 | ToolboxCommando toolboxCommando = getToolboxCommando(); 54 | Collection roots; 55 | ResolutionRoot root = pluginAsResolutionRoot(toolboxCommando, false); 56 | if (root != null) { 57 | roots = Collections.singleton(root.getArtifact()); 58 | } else { 59 | roots = allProjectPluginsAsResolutionRoots(toolboxCommando).stream() 60 | .map(ResolutionRoot::getArtifact) 61 | .collect(Collectors.toList()); 62 | } 63 | return toolboxCommando.resolve( 64 | roots::stream, sources, javadoc, signature, toolboxCommando.artifactSink(sinkSpec, dryRun)); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/PluginTreeFindMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPPluginMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.ResolutionRoot; 12 | import eu.maveniverse.maven.toolbox.shared.ResolutionScope; 13 | import eu.maveniverse.maven.toolbox.shared.Result; 14 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 15 | import org.apache.maven.plugins.annotations.Mojo; 16 | import org.apache.maven.plugins.annotations.Parameter; 17 | 18 | /** 19 | * Collects paths to matched artifact from plugins, if exists. 20 | */ 21 | @Mojo(name = "plugin-tree-find", threadSafe = true) 22 | public class PluginTreeFindMojo extends MPPluginMojoSupport { 23 | /** 24 | * The resolution scope to display, accepted values are "runtime", "compile", "test", etc. 25 | */ 26 | @Parameter(property = "scope", defaultValue = "runtime", required = true) 27 | private String scope; 28 | 29 | /** 30 | * The artifact matcher spec. 31 | */ 32 | @Parameter(property = "artifactMatcherSpec", required = true) 33 | private String artifactMatcherSpec; 34 | 35 | /** 36 | * Set it {@code true} for verbose tree. 37 | */ 38 | @Parameter(property = "verboseTree", defaultValue = "false", required = true) 39 | private boolean verboseTree; 40 | 41 | @Override 42 | protected Result doExecute() throws Exception { 43 | ToolboxCommando toolboxCommando = getToolboxCommando(); 44 | ResolutionRoot root = pluginAsResolutionRoot(toolboxCommando, false); 45 | if (root != null) { 46 | getOutput().doTell("Paths found in plugin {}", root.getArtifact()); 47 | toolboxCommando.treeFind( 48 | ResolutionScope.parse(scope), 49 | root, 50 | verboseTree, 51 | toolboxCommando.parseArtifactMatcherSpec(artifactMatcherSpec)); 52 | } else { 53 | for (ResolutionRoot resolutionRoot : allProjectPluginsAsResolutionRoots(toolboxCommando)) { 54 | getOutput().doTell("Paths found in plugin {}", resolutionRoot.getArtifact()); 55 | toolboxCommando.treeFind( 56 | ResolutionScope.parse(scope), 57 | resolutionRoot, 58 | verboseTree, 59 | toolboxCommando.parseArtifactMatcherSpec(artifactMatcherSpec)); 60 | } 61 | } 62 | return Result.success(true); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/PluginTreeMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPPluginMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.ResolutionRoot; 12 | import eu.maveniverse.maven.toolbox.shared.ResolutionScope; 13 | import eu.maveniverse.maven.toolbox.shared.Result; 14 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 15 | import org.apache.maven.plugins.annotations.Mojo; 16 | import org.apache.maven.plugins.annotations.Parameter; 17 | 18 | /** 19 | * Collects project given plugin and output its dependency tree. 20 | */ 21 | @Mojo(name = "plugin-tree", threadSafe = true) 22 | public class PluginTreeMojo extends MPPluginMojoSupport { 23 | /** 24 | * The resolution scope to display, accepted values are "runtime", "compile", "test", etc. 25 | */ 26 | @Parameter(property = "scope", defaultValue = "runtime", required = true) 27 | private String scope; 28 | 29 | /** 30 | * The dependency matcher if you want to filter as eager as Lenny wants. 31 | */ 32 | @Parameter(property = "dependencyMatcher", defaultValue = "any()", required = true) 33 | private String dependencyMatcher; 34 | 35 | /** 36 | * Set it {@code true} for verbose tree. 37 | */ 38 | @Parameter(property = "verboseTree", defaultValue = "false", required = true) 39 | private boolean verboseTree; 40 | 41 | @Override 42 | protected Result doExecute() throws Exception { 43 | ToolboxCommando toolboxCommando = getToolboxCommando(); 44 | ResolutionRoot root = pluginAsResolutionRoot(toolboxCommando, false); 45 | if (root != null) { 46 | toolboxCommando.tree( 47 | ResolutionScope.parse(scope), 48 | root, 49 | verboseTree, 50 | toolboxCommando.parseDependencyMatcherSpec(dependencyMatcher)); 51 | } else { 52 | for (ResolutionRoot resolutionRoot : allProjectPluginsAsResolutionRoots(toolboxCommando)) { 53 | toolboxCommando.tree( 54 | ResolutionScope.parse(scope), 55 | resolutionRoot, 56 | verboseTree, 57 | toolboxCommando.parseDependencyMatcherSpec(dependencyMatcher)); 58 | } 59 | } 60 | return Result.success(true); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/ProjectDependencyTreeMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import org.apache.maven.plugins.annotations.Mojo; 13 | import org.apache.maven.plugins.annotations.Parameter; 14 | import org.eclipse.aether.collection.CollectResult; 15 | 16 | /** 17 | * Displays project interdependencies of Maven Projects. 18 | */ 19 | @Mojo(name = "project-dependency-tree", aggregator = true, threadSafe = true) 20 | public class ProjectDependencyTreeMojo extends MPMojoSupport { 21 | 22 | /** 23 | * Set it {@code true} for verbose tree. 24 | */ 25 | @Parameter(property = "showExternal", defaultValue = "false", required = true) 26 | private boolean showExternal; 27 | 28 | /** 29 | * Set the project selector, like {@code -rf} Maven command uses it, can be {@code :A} or {@code G:A}. If the 30 | * selector is set, it must match exactly one project within reactor, otherwise it will fail. By default, 31 | * selector is {@code null}, and Maven session "current project" is used. 32 | */ 33 | @Parameter(property = "selector") 34 | private String selector; 35 | 36 | @Override 37 | protected Result doExecute() throws Exception { 38 | return getToolboxCommando().projectDependencyTree(getReactorLocator(selector), showExternal); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/ResolveMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 13 | import java.util.List; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import org.eclipse.aether.artifact.Artifact; 17 | 18 | /** 19 | * Resolves selected dependencies. 20 | */ 21 | @Mojo(name = "resolve", threadSafe = true) 22 | public class ResolveMojo extends MPMojoSupport { 23 | /** 24 | * The dependency matcher spec. 25 | */ 26 | @Parameter(property = "depSpec", defaultValue = "any()") 27 | private String depSpec; 28 | 29 | /** 30 | * Resolve sources JAR as well (derive coordinates from GAV). 31 | */ 32 | @Parameter(property = "sources", defaultValue = "false") 33 | private boolean sources; 34 | 35 | /** 36 | * Resolve javadoc JAR as well (derive coordinates from GAV). 37 | */ 38 | @Parameter(property = "javadoc", defaultValue = "false") 39 | private boolean javadoc; 40 | 41 | /** 42 | * Resolve GnuPG signature as well (derive coordinates from GAV). 43 | */ 44 | @Parameter(property = "signature", defaultValue = "false") 45 | private boolean signature; 46 | 47 | /** 48 | * The artifact sink spec (default: "null()"). 49 | */ 50 | @Parameter(property = "sinkSpec", defaultValue = "null()", required = true) 51 | private String sinkSpec; 52 | 53 | @Override 54 | protected Result> doExecute() throws Exception { 55 | ToolboxCommando toolboxCommando = getToolboxCommando(); 56 | return toolboxCommando.resolve( 57 | () -> projectAsResolutionRoot().getDependencies().stream() 58 | .filter(toolboxCommando.parseDependencyMatcherSpec(depSpec)) 59 | .map(toolboxCommando::toArtifact), 60 | sources, 61 | javadoc, 62 | signature, 63 | toolboxCommando.artifactSink(sinkSpec, dryRun)); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/SubprojectTreeMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.Result; 12 | import org.apache.maven.plugins.annotations.Mojo; 13 | import org.apache.maven.plugins.annotations.Parameter; 14 | import org.eclipse.aether.collection.CollectResult; 15 | 16 | /** 17 | * Displays subproject collection of Maven Projects. 18 | */ 19 | @Mojo(name = "subproject-tree", aggregator = true, threadSafe = true) 20 | public class SubprojectTreeMojo extends MPMojoSupport { 21 | /** 22 | * Set the project selector, like {@code -rf} Maven command uses it, can be {@code :A} or {@code G:A}. If the 23 | * selector is set, it must match exactly one project within reactor, otherwise it will fail. By default, 24 | * selector is {@code null}, and Maven session "current project" is used. 25 | */ 26 | @Parameter(property = "selector") 27 | private String selector; 28 | 29 | @Override 30 | protected Result doExecute() throws Exception { 31 | return getToolboxCommando().subprojectTree(getReactorLocator(selector)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/TreeFindMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.ResolutionRoot; 12 | import eu.maveniverse.maven.toolbox.shared.ResolutionScope; 13 | import eu.maveniverse.maven.toolbox.shared.Result; 14 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 15 | import java.util.List; 16 | import org.apache.maven.plugins.annotations.Mojo; 17 | import org.apache.maven.plugins.annotations.Parameter; 18 | import org.eclipse.aether.artifact.Artifact; 19 | 20 | /** 21 | * Collects paths to matched artifact, if exists. 22 | */ 23 | @Mojo(name = "tree-find", threadSafe = true) 24 | public class TreeFindMojo extends MPMojoSupport { 25 | /** 26 | * The resolution scope to display, accepted values are "runtime", "compile", "test", etc. 27 | */ 28 | @Parameter(property = "scope", defaultValue = "runtime", required = true) 29 | private String scope; 30 | 31 | /** 32 | * The artifact matcher spec. 33 | */ 34 | @Parameter(property = "artifactMatcherSpec", required = true) 35 | private String artifactMatcherSpec; 36 | 37 | /** 38 | * Set it {@code true} for verbose tree. 39 | */ 40 | @Parameter(property = "verboseTree", defaultValue = "false", required = true) 41 | private boolean verboseTree; 42 | 43 | @Override 44 | protected Result>> doExecute() throws Exception { 45 | ToolboxCommando toolboxCommando = getToolboxCommando(); 46 | ResolutionRoot root = projectAsResolutionRoot(); 47 | getOutput().doTell("Paths found in project {}", root.getArtifact()); 48 | return toolboxCommando.treeFind( 49 | ResolutionScope.parse(scope), 50 | root, 51 | verboseTree, 52 | toolboxCommando.parseArtifactMatcherSpec(artifactMatcherSpec)); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/TreeMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | package eu.maveniverse.maven.toolbox.plugin.mp; 9 | 10 | import eu.maveniverse.maven.toolbox.plugin.MPMojoSupport; 11 | import eu.maveniverse.maven.toolbox.shared.ResolutionScope; 12 | import eu.maveniverse.maven.toolbox.shared.Result; 13 | import eu.maveniverse.maven.toolbox.shared.ToolboxCommando; 14 | import org.apache.maven.plugins.annotations.Mojo; 15 | import org.apache.maven.plugins.annotations.Parameter; 16 | import org.eclipse.aether.collection.CollectResult; 17 | 18 | /** 19 | * Displays dependency tree of Maven Project. 20 | */ 21 | @Mojo(name = "tree", threadSafe = true) 22 | public class TreeMojo extends MPMojoSupport { 23 | /** 24 | * The resolution scope to display, accepted values are "runtime", "compile", "test", etc. 25 | */ 26 | @Parameter(property = "scope", defaultValue = "runtime", required = true) 27 | private String scope; 28 | 29 | /** 30 | * The dependency matcher if you want to filter as eager as Lenny wants. 31 | */ 32 | @Parameter(property = "dependencyMatcher", defaultValue = "any()", required = true) 33 | private String dependencyMatcher; 34 | 35 | /** 36 | * Set it {@code true} for verbose tree. 37 | */ 38 | @Parameter(property = "verboseTree", defaultValue = "false", required = true) 39 | private boolean verboseTree; 40 | 41 | @Override 42 | protected Result doExecute() throws Exception { 43 | ToolboxCommando toolboxCommando = getToolboxCommando(); 44 | return toolboxCommando.tree( 45 | ResolutionScope.parse(scope), 46 | projectAsResolutionRoot(), 47 | verboseTree, 48 | toolboxCommando.parseDependencyMatcherSpec(dependencyMatcher)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/mp/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023-2024 Maveniverse Org. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v2.0 5 | * which accompanies this distribution, and is available at 6 | * https://www.eclipse.org/legal/epl-v20.html 7 | */ 8 | 9 | /** 10 | * The MP package contains Mojos that require Project. Hence, the MP package name. 11 | */ 12 | package eu.maveniverse.maven.toolbox.plugin.mp; 13 | -------------------------------------------------------------------------------- /toolbox/src/main/resources/simplelogger.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023-2024 Maveniverse Org. 3 | # All rights reserved. This program and the accompanying materials 4 | # are made available under the terms of the Eclipse Public License v2.0 5 | # which accompanies this distribution, and is available at 6 | # https://www.eclipse.org/legal/epl-v20.html 7 | # 8 | 9 | org.slf4j.simpleLogger.defaultLogLevel=info 10 | org.slf4j.simpleLogger.showDateTime=false 11 | org.slf4j.simpleLogger.showThreadName=false 12 | org.slf4j.simpleLogger.showLogName=false 13 | org.slf4j.simpleLogger.logFile=System.out 14 | org.slf4j.simpleLogger.cacheOutputStream=true 15 | org.slf4j.simpleLogger.levelInBrackets=false 16 | org.slf4j.simpleLogger.warnLevelString=WARNING 17 | --------------------------------------------------------------------------------