-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add project based libyear Mojo (#34)
and some other fixes
- Loading branch information
Showing
12 changed files
with
225 additions
and
68 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
shared/src/main/java/eu/maveniverse/maven/toolbox/shared/ArtifactVersionSelector.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,44 @@ | ||
/* | ||
* Copyright (c) 2023-2024 Maveniverse Org. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
package eu.maveniverse.maven.toolbox.shared; | ||
|
||
import java.util.List; | ||
import java.util.function.BiFunction; | ||
import org.eclipse.aether.artifact.Artifact; | ||
import org.eclipse.aether.version.Version; | ||
|
||
/** | ||
* Selector that selects artifact version. | ||
*/ | ||
public interface ArtifactVersionSelector extends BiFunction<Artifact, List<Version>, String> { | ||
/** | ||
* Selector that returns artifact version. | ||
*/ | ||
static ArtifactVersionSelector identity() { | ||
return new ArtifactVersionSelector() { | ||
@Override | ||
public String apply(Artifact artifact, List<Version> versions) { | ||
return artifact.getVersion(); | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* Selector that return plan last version. | ||
*/ | ||
static ArtifactVersionSelector last() { | ||
return new ArtifactVersionSelector() { | ||
@Override | ||
public String apply(Artifact artifact, List<Version> versions) { | ||
return versions.isEmpty() | ||
? identity().apply(artifact, versions) | ||
: versions.get(versions.size() - 1).toString(); | ||
} | ||
}; | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.