So I run maven package
to build my dependencies into a jar. However, I need Maven to ignore any compilation errors and package the jar regardless.
How would this be accomplished? My pom.xml
is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<!-- Project specific stuff would be here... -->
<build>
<sourceDirectory>wherever</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<!-- etc... -->
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
Searching through SO only showed me how to ignore compilation errors from unit testing. I simply want my package to be compiled despite any errors in the code.
Edit: People seem to be bashing on me. I've been doing Java for 5 years. I know you're not supposed to compile with errors. I know what it entails.
My boss programs with me. He specifically said, "I can compile with errors in Eclipse, so compile with errors in Maven." It's not because I am ignorant, or because I refuse to accept my mistakes. It is because that is what I was specifically ordered to do. I did not ask this question because I am incompetent as many of you would like to assume.
Hate on me all you want, just know that you are doing so unfairly.
We can force update in maven by using –U options by using mvn clean install command. In that –U means force update the dependencies of the snapshot. The release dependencies are updated is suppose there are not updated previously.
The difference is that the Maven Assembly Plugin will automatically copy all required dependencies into a jar file. In the descriptorRefs part of the configuration code, we provided the name that will be added to the project name. Output in our example will be named as core-java-jar-with-dependencies. jar.
Building on Top of @wings Answer
You can use the flag failOnError=false
in your pom
, too
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<failOnError>false</failOnError>
</configuration>
</plugin>
or via command line
mvn package -Dmaven.compiler.failOnError=false
Maybe this is what you want: https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#failOnError
Set failOnError=false
to ignore compilation errors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With