I am building my java project using maven but couldn't succeed. So, can anyone please tell me the essential tags and their corresponding values required in pom.xml to build a project? Also, how do i add the storm dependencies manually from command line?
My directory structure of project :
ROOT
|
|----com--->test----->newpackage---->*.class
|--- META-INF------>MANIFEST.MF
|----resource----->words.txt
|----pom.xml
|-----*.jar
Initially i tried Maven Link and create the pom.xml
like this :
<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">
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>com.test.newpackage</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
But, after that i use mvn package
. It throw this exception :
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: unknown
POM Location: /home/naresh/Desktop/SharedFolder/StormEclipse/pom.xml
Reason: Not a v4.0.0 POM. for project unknown at /home/naresh/Desktop/SharedFolder/StormEclipse/pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Not a v4.0.0 POM. for project unknown at /home/naresh/Desktop/SharedFolder/StormEclipse/pom.xml
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:404)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:272)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.project.InvalidProjectModelException: Not a v4.0.0 POM. for project unknown at /home/naresh/Desktop/SharedFolder/StormEclipse/pom.xml
at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1599)
at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1571)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:506)
at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:604)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:487)
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:391)
... 12 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Mon Jul 22 14:38:24 IST 2013
[INFO] Final Memory: 1M/15M
[INFO] ------------------------------------------------------------------------
After that i used this link Maven link 2 and created the pom.xml like this :
<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.test.newpackage</groupId>
<artifactId>wordcount</artifactId>
<version>0.0.1</version>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.test.newpackage</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<!-- Repository where we can found the storm dependencies <repository>
<id>clojars.org</id> <url>http://clojars.org/repo</url> </repository> -->
</repositories>
<dependencies>
<!-- Storm Dependency -->
<dependency>
<groupId>storm</groupId>
<artifactId>storm</artifactId>
<version>0.8.1</version>
</dependency>
</dependencies>
</project>
This time it throw this exception :
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) storm:storm:jar:0.8.1
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=storm -DartifactId=storm -Dversion=0.8.1 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=storm -DartifactId=storm -Dversion=0.8.1 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) com.test.newpackage:wordcount:jar:0.0.1
2) storm:storm:jar:0.8.1
----------
1 required artifact is missing.
for artifact:
com.test.newpackage:wordcount:jar:0.0.1
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
About your structure:
Maven assumes the java classes to be in src/main/java
and the resources (anything in your folder resource
and your META-INF dir) in src/main/resources
. The directory structure you described will not work even if you tweak maven a bit because of the java classes in the root dir (recursion). Why don't you use the default structure? You should really have a good reason to change this.
storm Dependency:
You already have the link to the external repository in your POM. But it is outcommented. This should work as expected. If you are behind a proxy you have to define a proxy in your settings.xml
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