Like Stephen S., answer, but using the maven-dependency-plugin . Based on this blog post .
I changed the name of the corrected library (not the version), but it depends on your needs, which is better for you.
The dependency on the source library should be marked as <optional>true</optional> . Otherwise, projects depending on your patched library will also depend on the source library, which means that both the patched and the original version will be in the class path, which can lead to all problems.
If your project is a child project, you can still use a completely different version of groupId and version than your parent pom. Never mind.
You can exclude classes that you fix from unpacking, but this is probably not necessary because Maven will first unzip the source library and then compile your new version, which means that the original classes are overwritten. Nice!
<?xml version="1.0"?> <project xmlns="http://maven.apache.org/POM/4.0.0"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>my.company</groupId> <artifactId>my.company</artifactId> <version>1.2.3</version> <relativePath>../pom.xml</relativePath> </parent> <groupId>com.foo</groupId> <artifactId>foo-bar-patched</artifactId> <version>4.5.6</version> <build> <plugins> <plugin> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <goals> <goal>unpack</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>com.foo</groupId> <artifactId>foo-bar</artifactId> <outputDirectory>${project.build.directory}/classes</outputDirectory> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>com.foo</groupId> <artifactId>foo-bar</artifactId> <version>4.5.6</version> <optional>true</optional> </dependency> </dependencies> </project>
source share