Class MavenTools
java.lang.Object
uno.anahata.ai.nb.tools.MavenTools
Consolidated "super-tool" class for all Maven-related AI operations.
This class combines functionality from the deprecated Maven, MavenPom, and MavenSearch classes.
It serves as the single, definitive entry point for searching, modifying, and executing Maven tasks.
- Author:
- anahata
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AddDependencyResultaddDependency(String projectId, String groupId, String artifactId, String version, String scope, String classifier, String type) The definitive 'super-tool' for adding a Maven dependency.static booleandownloadDependencyArtifact(String projectId, String groupId, String artifactId, String version, String classifier, String type) Downloads a specific classified artifact for a single dependency.static StringdownloadProjectDependencies(String projectId, List<String> classifiers) Downloads all missing dependencies artifacts for a given Maven project.static List<DependencyScope> getDeclaredDependencies(String projectId) Gets the list of dependencies directly declared in the pom.xml.static StringGets the path to the Maven installation configured in NetBeans.static List<ResolvedDependencyScope> getResolvedDependencies(String projectId) Gets the final, fully resolved list of transitive dependencies for the project.static MavenBuildResultrunGoals(String projectId, List<String> goals, List<String> profiles, Map<String, String> properties, List<String> options, Long timeout) Executes a list of Maven goals on a Project synchronously.static MavenSearchResultPagesearchMavenIndex(String query, Integer startIndex, Integer pageSize) Searches the Maven index for artifacts matching a given query.
-
Constructor Details
-
MavenTools
public MavenTools()
-
-
Method Details
-
searchMavenIndex
public static MavenSearchResultPage searchMavenIndex(String query, Integer startIndex, Integer pageSize) throws Exception Searches the Maven index for artifacts matching a given query.- Parameters:
query- The search query.startIndex- The starting index (0-based) for pagination.pageSize- The maximum number of results to return.- Returns:
- a MavenSearchResultPage containing the found artifacts.
- Throws:
Exception- if an error occurs.
-
addDependency
public static AddDependencyResult addDependency(String projectId, String groupId, String artifactId, String version, String scope, String classifier, String type) The definitive 'super-tool' for adding a Maven dependency.- Parameters:
projectId- The ID of the project to modify.groupId- The groupId of the dependency.artifactId- The artifactId of the dependency.version- The version of the dependency.scope- The scope of the dependency.classifier- The classifier of the dependency.type- The type of the dependency.- Returns:
- an AddDependencyResult object.
-
getDeclaredDependencies
Gets the list of dependencies directly declared in the pom.xml.- Parameters:
projectId- The ID of the project to analyze.- Returns:
- a list of DependencyScope objects.
- Throws:
Exception- if an error occurs.
-
getResolvedDependencies
public static List<ResolvedDependencyScope> getResolvedDependencies(String projectId) throws Exception Gets the final, fully resolved list of transitive dependencies for the project.- Parameters:
projectId- The ID of the project to analyze.- Returns:
- a list of ResolvedDependencyScope objects.
- Throws:
Exception- if an error occurs.
-
getMavenPath
Gets the path to the Maven installation configured in NetBeans.- Returns:
- the Maven path.
-
runGoals
public static MavenBuildResult runGoals(String projectId, List<String> goals, List<String> profiles, Map<String, String> properties, List<String> options, Long timeout) throws ExceptionExecutes a list of Maven goals on a Project synchronously.- Parameters:
projectId- The ID of the project to run the goals on.goals- A list of Maven goals to execute.profiles- A list of profiles to activate.properties- A map of properties to set.options- A list of additional Maven options.timeout- The maximum time to wait for the build to complete.- Returns:
- a MavenBuildResult object.
- Throws:
Exception- if an error occurs.
-
downloadProjectDependencies
public static String downloadProjectDependencies(String projectId, List<String> classifiers) throws Exception Downloads all missing dependencies artifacts for a given Maven project.- Parameters:
projectId- The ID of the project to download dependencies for.classifiers- A list of classifiers to download.- Returns:
- a message indicating the result of the operation.
- Throws:
Exception- if an error occurs.
-
downloadDependencyArtifact
public static boolean downloadDependencyArtifact(String projectId, String groupId, String artifactId, String version, String classifier, String type) throws Exception Downloads a specific classified artifact for a single dependency.- Parameters:
projectId- The ID of the project to use for repository context.groupId- The groupId of the dependency.artifactId- The artifactId of the dependency.version- The version of the dependency.classifier- The classifier of the artifact to download.type- The type of the dependency.- Returns:
- true on success, false on failure.
- Throws:
Exception- if an error occurs.
-
