CodexBloom - Programming Q&A Platform

Maven build scenarios with 'scenarios to execute goal on project' when using profile-specific dependency

👀 Views: 270 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-13
maven dependency-management profiles Java

I tried several approaches but none seem to work. I'm deploying to production and I've hit a wall trying to I'm learning this framework and I'm working with an scenario where my Maven build fails with the behavior message: `Failed to execute goal on project my-app: Could not resolve dependencies for project com.example:my-app:jar:1.0-SNAPSHOT: Failure to find com.example:my-dependency:jar:1.0 in https://my.custom.repo/repo` when using a specific profile... I've defined the dependency under a specific profile in my `pom.xml`, but it seems Maven isn't picking it up correctly, even though I can see the dependency in the effective POM. My `pom.xml` looks something like this: ```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-app</artifactId> <version>1.0-SNAPSHOT</version> <profiles> <profile> <id>custom-profile</id> <dependencies> <dependency> <groupId>com.example</groupId> <artifactId>my-dependency</artifactId> <version>1.0</version> </dependency> </dependencies> </profile> </profiles> </project> ``` When I activate the profile using `mvn clean install -Pcustom-profile`, it fails to find `my-dependency`. I've double-checked that the dependency is available in the specified repository, and I can even access it through a browser. I've also verified that the URL in my settings.xml is correctly pointing to the repository. I've tried cleaning the local repository (`mvn clean`) and updating snapshots (`mvn -U install`), but the behavior continues. Is there something I might be missing in my configuration or profile activation? Any guidance on getting this to work would be greatly appreciated. I'm working on a mobile app that needs to handle this. What am I doing wrong? The project is a REST API built with Java. Could this be a known issue? For context: I'm using Java on Linux. Thanks in advance! I'm working in a macOS environment. Thanks for your help in advance! My development environment is Windows 10. Any advice would be much appreciated. I've been using Java for about a year now.