CodexBloom - Programming Q&A Platform

Maven scenarios to use local repository when publishing artifacts with specific classifier

👀 Views: 61 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-13
maven artifact deployment multi-module Java

I just started working with I've looked through the documentation and I'm still confused about Quick question that's been bugging me - Hey everyone, I'm running into an issue that's driving me crazy... I'm working with an scenario where Maven is not resolving the artifacts from my local repository when I try to publish them using a specific classifier. I have a multi-module project set up, and I'm trying to deploy an artifact with the classifier 'sources'. Despite having the artifact available in my local `.m2` repository, Maven seems to ignore it during the deployment phase. Here's the relevant part of my `pom.xml`: ```xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>my-module</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> <configuration> <classifier>sources</classifier> </configuration> </plugin> </plugins> </build> </project> ``` When I run the command `mvn clean deploy`, I get the following behavior message: ``` [behavior] Failed to execute goal on project my-module: Could not find artifact com.example:my-module:jar:sources in local (file://${user.home}/.m2/repository) -> [Help 1] ``` I've already checked that the artifact with the classifier 'sources' actually exists in my local repository under `~/.m2/repository/com/example/my-module/1.0-SNAPSHOT/my-module-1.0-SNAPSHOT-sources.jar`. I've also tried running `mvn clean install` to ensure everything builds correctly before deploying, but the question continues. It seems like Maven is not recognizing the classifier during the deployment phase. I've ensured that there are no typos in the classifier name and that the artifact is not corrupted. Is there a misconfiguration in my `pom.xml`, or is there something else I might be missing that could cause Maven to ignore the local artifact? For context: I'm using Java on Windows. Is there a better approach? Cheers for any assistance! For context: I'm using Java on Windows 11.