-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
239 changed files
with
11,777 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,3 @@ | ||
# Toolbox | ||
# MDK | ||
|
||
The Toolbox project started with manifold aims: | ||
* replace `MIMA CLI`, provide drop-in replacement, but also continue improving it. | ||
* provide replacement for `maven-dependency-plugin`, offering similar (sub)set of Mojos | ||
* showcase how MIMA helps to write reusable Resolver code that runs in Maven (as Mojos) but also outside of Maven as well | ||
* 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 | ||
|
||
Structure of the project: | ||
* Module "shared" is a reusable library module, that depends on MIMA `Context` only (and Resolver APIs), and implements all the logic. | ||
* Module "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 | ||
"flavors": without prefix (i.e. "tree"), that requires project, and uses `MavenProject` to get the data for requests, and "gav-" | ||
prefixed ones (i.e. "gav-tree"), that do not require project, and is able to target any existing Artifact out there. | ||
|
||
To use it as Maven plugin, introspect available Mojos and parameters: | ||
``` | ||
$ mvn eu.maveniverse.maven.plugins:toolbox:help -Ddetail | ||
``` | ||
Or, to use it as CLI: | ||
``` | ||
$ jbang toolbox@maveniverse | ||
``` | ||
or you can download the CLI JAR from Maven Central and run it directly. | ||
See https://en.wikipedia.org/wiki/MDK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
api/src/main/java/org/apache/maven/plugins/deploy/spi/DeployerSPI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.maven.plugins.deploy.spi; | ||
|
||
import java.util.Map; | ||
import org.eclipse.aether.RepositorySystemSession; | ||
import org.eclipse.aether.deployment.DeployRequest; | ||
import org.eclipse.aether.deployment.DeploymentException; | ||
|
||
/** | ||
* Deployer SPI | ||
* | ||
* @since 3.2.0 | ||
*/ | ||
public interface DeployerSPI { | ||
void deploy(RepositorySystemSession session, DeployRequest deployRequest, Map<String, Object> parameters) | ||
throws DeploymentException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
kurt/src/main/java/eu/maveniverse/maven/mdk/kurt/KurtDeployerSPI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package eu.maveniverse.maven.mdk.kurt; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
import org.apache.maven.AbstractMavenLifecycleParticipant; | ||
import org.apache.maven.MavenExecutionException; | ||
import org.apache.maven.execution.MavenSession; | ||
import org.apache.maven.plugins.deploy.spi.DeployerSPI; | ||
import org.eclipse.aether.RepositorySystem; | ||
import org.eclipse.aether.RepositorySystemSession; | ||
import org.eclipse.aether.deployment.DeployRequest; | ||
import org.eclipse.aether.deployment.DeploymentException; | ||
import org.eclipse.aether.repository.RemoteRepository; | ||
import org.eclipse.sisu.Priority; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Kurt deployer SPI | ||
*/ | ||
@Singleton | ||
@Named("kurt") | ||
@Priority(10) | ||
public class KurtDeployerSPI extends AbstractMavenLifecycleParticipant implements DeployerSPI { | ||
private final Logger log = LoggerFactory.getLogger(getClass()); | ||
|
||
private final RepositorySystem repositorySystem; | ||
|
||
private final List<DeployRequest> deployAtEndRequests = Collections.synchronizedList(new ArrayList<>()); | ||
|
||
@Inject | ||
public KurtDeployerSPI(RepositorySystem repositorySystem) { | ||
this.repositorySystem = requireNonNull(repositorySystem); | ||
} | ||
|
||
@Override | ||
public void deploy(RepositorySystemSession session, DeployRequest deployRequest, Map<String, Object> parameters) | ||
throws DeploymentException { | ||
deployAtEndRequests.add(deployRequest); | ||
} | ||
|
||
@Override | ||
public void afterSessionEnd(MavenSession session) throws MavenExecutionException { | ||
boolean errors = !session.getResult().getExceptions().isEmpty(); | ||
|
||
if (!deployAtEndRequests.isEmpty()) { | ||
|
||
log.info(""); | ||
log.info("------------------------------------------------------------------------"); | ||
|
||
if (errors) { | ||
log.info("-- Not performing deploy at end due to errors --"); | ||
} else { | ||
log.info("-- Performing deploy at end --"); | ||
log.info("------------------------------------------------------------------------"); | ||
|
||
synchronized (deployAtEndRequests) { | ||
HashMap<RemoteRepository, DeployRequest> batched = new HashMap<>(); | ||
for (DeployRequest deployRequest : deployAtEndRequests) { | ||
if (!batched.containsKey(deployRequest.getRepository())) { | ||
batched.put(deployRequest.getRepository(), deployRequest); | ||
} else { | ||
DeployRequest dr = batched.get(deployRequest.getRepository()); | ||
deployRequest.getArtifacts().forEach(dr::addArtifact); | ||
deployRequest.getMetadata().forEach(dr::addMetadata); | ||
} | ||
} | ||
try { | ||
for (DeployRequest dr : batched.values()) { | ||
repositorySystem.deploy(session.getRepositorySession(), dr); | ||
} | ||
} catch (DeploymentException e) { | ||
log.error(e.getMessage(), e); | ||
throw new MavenExecutionException(e.getMessage(), e); | ||
} | ||
deployAtEndRequests.clear(); | ||
} | ||
} | ||
|
||
log.info("------------------------------------------------------------------------"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<extension> | ||
<exportedPackages> | ||
<exportedPackage>org.apache.maven.plugins.deploy.spi</exportedPackage> | ||
<exportedPackage>eu.maveniverse.maven.mdk.kurt</exportedPackage> | ||
</exportedPackages> | ||
|
||
<exportedArtifacts> | ||
<exportedArtifact>eu.maveniverse.maven.mdk:api</exportedArtifact> | ||
<exportedArtifact>eu.maveniverse.maven.mdk:kurt</exportedArtifact> | ||
</exportedArtifacts> | ||
</extension> |
Oops, something went wrong.