I have looked through everything I can find on StackOverflow and I could not find an answer. I have just built out a new machine and I have projects that compiled and built on previous installations just fine. But my new machine won't. Everything appears to be building correctly (no build errors, dependencies included properly), but the actual class files (code I wrote) from my project are not included in the jar. I then created a simple helloWorld project with a some what minimal POM file to see of the problem still exists. I did the build from the command line to take eclipse out of the equation.
Class Code
package com.zoverge.utils;
public class HelloWorld {
/**
* @param args
*/
public static void main(String[] args) {
String message = args[0];
System.out.println(message);
}
}
My POM file
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zoverge.utils</groupId>
<artifactId>helloworld</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>Hello World</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.java.version>1.6</project.build.java.version>
<org.apache.maven.plugins.maven-compiler-plugin.version>2.5.1</org.apache.maven.plugins.maven-compiler-plugin.version>
</properties>
<build>
<plugins>
<!-- Maven will compile our source java classes using the "project.build.java.version"
specified -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${org.apache.maven.plugins.maven-compiler-plugin.version}</version>
<configuration>
<source>${project.build.java.version}</source>
<target>${project.build.java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.zoverge.utils.HelloWorld</mainClass>
</manifest>
</archive>
<finalName>HelloWorld</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies/>
</project>
The resulting build produces 2 jar files (as expected) helloworld-1.0.jar and HelloWorld.jar. Neither jar contains the compiled class file for HelloWorld.java. I think this has to be a problem with my environment because this behavior is the same for other projects that worked fine on other dev machines, but I can't seem to figure out the difference. I do not have access to my previous dev machine to compare the configuration. My .m2/setting.xml is basically empty.
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>${user.home}/.m2/repository</localRepository>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
I found my problem. The problem was the folder structure. Maven assumes a /src/main/java/ structure. my structure was different and was not overridden in the POM.xml. matching the standard path or overridding the path in the POM.xml fixed the problem.
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