Maven: The command 'mvn install' related issue - maven

I have found this very fascinating that 'mvn install' sometimes produces a .class file in the target directory and sometimes it doesn't. Can anyone tell me why is it so? How can I make sure I get the directory every single time?
It's a simple maven module which is added as part of a parent folder. When I execute 'mvn install' on this module, I get a target/test-classes folder but no target/classes folder. This happens on some occasions..
Let me break it up even more...
I create a module which initially has src/test/java and src/test/resources. So I add a source folder called src/main/java and src/main/resources. Now I install the module and I get to see the test-classes folder inside target and no classes folder.
Hope you got it.

Related

dist and native-win could not be activated, no POM in directory

Please explain what is required to be done stepwise.
How to activate -dist and native-win?
I saw your error contains there is no pom in this directory.
Maven can run only from the location where pom file exists so make sure pom file is there in your project.
For example, your project is inside C:\Users\HP then so maven will consider HP as a project and it will try to find pom file inside HP project.
This error is coming because you didnot place hadoop source package in the C:/User/HP directory. you can download appropriate source package from http://www.apache.org/dist/hadoop/core/
unzip it and place all the files & folder in C:/User/HP then run your maven package command. It should work

Create only 1 tar file with mvn package command

I am using maven, testng, selenium and java framework. I have mojo appassembler plugins to create maven build.
I noticed that when I create mvn package - there are few folders getting created under target. for example:
archive-tmp
end2end-1.0-bin.tar
generated-sources
maven-status
classes
end2end-1.0-jar-with-dependencies.jar
generated-test-sources
surefire-reports
end2end-1.0
end2end-1.0.jar
maven-archiver
test-classes
Here, after I untar end2end-1.0.bin.tar, I am able to run the build however it also depends on other folders, classes outside tar build. (inside target folder)
What I want to do is : to create only 1 tar file for entire build. So that other user can copy tar, untar and directly run it.
I know there are some configuration need to set in POM.xml for build. Does anyone have any specific ideas?
Thanks,

Project war file does not occur in dist folder

I run clean and build in netbeans web project.Past ,the war file was created in the dist folder. However I do same thing, but it was not created in dist folder. How can solve this problem?
Check the logs as it produces when you do clean and build using netbeans.It might show you the contexts and some paths it uses for creating a war.May be some of them might be missing.If it still does not help
try this
Stop the server.
Do clean and build and it will produce the war file now.
check the logs again.

How to make a path relative in the vmargs?

In my project I have an eclipse cdo-server which is set up as described here: http://wiki.eclipse.org/Setting_up_a_CDO_Server .
My project structure is like this:
-cdo-server plugin
|- config folder with cdo-server.xml
|- pom.xml
-cdo-server-product
|-pom.xml
-master
|-pom.xml
When I start my cdo-server.product as Eclipse application everything works fine.
When I build it and materialize it with Maven, it also has a BUILD SUCCESS. But when I start the CDO-CommonRepositoryServer.app which was built with Maven, there is the error:
!MESSAGE CDO server configuration not found:
/Users/pathtoCDO-Server/CDO-CommonRepositoryServer.app/Contents/MacOS/${resource_loc:/cdo.server/config}/cdo-server.xml.
This is logical, because this is the wrong path. When I enter the absolute path to the cdo-server.xml in the vmargs (-Dnet4j.config=/Users/pathtoCDO-config/cdo-server.xml) it also works. However, I want to make it relative, so that everybody in our git-repo can use it and not only in my folder structure.
Is there any possibility to make this path relative?
With -Dnet4j.config="${resource_loc:/cdo.server/config}" it only works when i run it as an eclipse application, but not as maven built .app file.
Update:
Now I can start the CDO-CommonRepository.app file if I take
-Dnet4j.config=../../../../../../../../../../cdo.server/config
as path, but then I can only start it with the maven built file and I cannot start it from inside Eclipse anymore...
I've created a new question for this new problem: Slash in property name in pom.xml
I just solved my problem in copying my files with Maven copy-resources in this stupid /Users/pathtoCDO-Server/CDO-CommonRepositoryServer.app/Contents/MacOS/${resource_loc:/cdo.server/config}/cdo-server.xml folder.

M2E Removes My Source Directory?

I have an existing library that I am building in Eclipse and have added the Maven nature to my project using m2e to add dependencies. When I convert it to a Maven project, my existing source directory (and my bin) become normal folders. Is there a reason for this? I am new to Maven, so I am likely doing something wrong, just not sure what...
My project structure is as follows:
workspace
project
src (in build path)
resources (in build path)
bin (output dir)
I tried both "mvn eclipse:eclipse" and right click on project -> Configure -> Convert to Maven Project, and both removed my src and resources folders from my build path, and after changing the structure to the below, changed the output to target/test-cases. Even if I manually adjust the build path and output, my dependencies don't resolve.
workspace
project
src (no longer in build path)
resources (no longer in build path)
bin (no longer output)
target (new output dir)
test-cases (empty)
I think you have the following structure when working with Eclipse (without Maven):
/workspace
/project1
.project
/src
/bin
But Maven want to use the following structure
/workspace
/project1
.project
pom.xml
/src
/main
/java
/resources
/test
/java
/target
/classes
/test-classes
and so on. So it is normal, that the folder src is no more directly a source folder for Eclipse, but now there are src/main/java, src/main/resources, ...
So it would be easier in the beginning to start with a new Maven project, and move your original sources to the directories they should belong to. Maven has a long tradition with its "convention over configuration", to deviate from that is possible. Have a look at the answer to "Handling unconventional source directory ..." to fix this.

Resources