Create only 1 tar file with mvn package command - maven

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,

Related

Where m2 file is stored when installing apache maven on a unix box

I downloaded maven gz file, unzipped same, but i dont know where the m2 is stored. I imagine im missing a step but i cant see what one?
Is there aninstall script etc?
[root#atddpvm5 apache-maven-3.5.4]# cd /var/tmp/apache-maven-3.5.4/
[root#atddpvm5 apache-maven-3.5.4]# ls
apache-maven DEPENDENCIES doap_Maven.rdf LICENSE maven-builder-
support maven-core maven-model maven-plugin-api
maven-resolver-provider maven-settings-builder NOTICE README.md
CONTRIBUTING.md deploySite.sh Jenkinsfile maven-artifact maven-compat
maven-embedder maven-model-builder maven-repository-metadata maven-
settings maven-slf4j-provider pom.xml src
By default the .m2 folder is stored in the home folder of the user. In this case since you are using root, the path is most likely /root/.m2. You also have to use the -a switch with ls to see that folder, since it's a hidden folder (it starts with a .). Note that the folder will only be created on the first usage of Maven, i.e. when you call a maven command on a maven project, like mvn clean install.
Additionally it looks like you have downloaded the source distribution of Maven, which only makes sense if you want to work on Maven itself. You might want to download the binary distribution, if you just want to use it.

Read files within maven plugin

I am trying to create a maven-plugin that generates new files based on a template file (basically using the FreeMarker language). I can successfully generate the files if I run the maven plugin from the directory of my maven-plugin project since my plugin accesses the template file based on a relative path.
However, if I try to run the plugin in some other java project directory, I cannot find the template file. I do not want to copy the templated file into the new java project.
I searched around to see if the maven plugin can access files within itself when another project is using the plugin but wasn't successful. Most of the documentation refers to accessing the java project files, and not the maven-plugin files.
Is this even possible or is there a better approach/workaround to tackle the problem?
Edit (Directory structure):
Maven-Plugin (FileGenerator):
src
--main
--java
--FileGenerator.java (references the TemplateFile based on the path to the root project)
TemplateFile
If I run the plugin as a standalone, I am able to generate new files based on the TemplateFile. I achieve the following structure
Maven-Plugin (FileGenerator):
src
--main
--java
--FileGenerator.java
TemplateFile
NewFile1
NewFile2
However, if I run the plugin in another directory (such as part of another java project) with the command mvn myplugin:mypluginplugin:1.0-SNAPSHOT:build
Another Java Project
src
--main
--java
--AnotherFile.java
pom.xml
I get an error mentioning that the TemplateFile cannot be found. Is there a way for the plugin to reference the TemplateFile regardless of where it is run at?
Ideal Output After running plugin
Another Java Project
src
--main
--java
--AnotherFile.java
pom.xml
NewFile1
NewFile2

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

Maven: The command 'mvn install' related issue

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.

Migrate a report created with Makefile into a Maven site report

I am quite new to maven but asked to move my current report which is created by a Makefile in a subdirectory via make all into a mvn site report.
I put all my non-java stuff for my report into a legacy-report directory. So the current tree looks roughly like this:
pom.xml
legacy-report/
Makefile
www/ # <<< created by 'make all'
index.html
subtree-1/
pom.xml
src/
subtree-2/
pom.xml
src/
So my questions to enable mvn site for my legary-report are
What maven (reporting) plugin should I use?
How should I change the directory layout?
How do I integrate that into the main pom.xml?
Do I need a pom.xml in my legacy-reporting dir, what does it look like (roughly)?
So after clearing what you are really talking about you should take a look here for the plugin:
http://graphviz-maven-plugin.bryon.us/index.html
Which will give you the opportunity to create graphivz graphics via Maven. The question is if there is a way to create an index.html of it.

Resources