├── .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 extends Project> 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