• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

New To Maven

 
Ranch Hand
Posts: 146
  • Number of slices to send:
    Optional 'thank-you' note:
After having a problem with Ant I was encouraged by people here to move to Maven, it seems very slick and everything works in Netbeans which I use to generate my code.
I tend to have a development area where I build and test and a folder call JRun which holds the current executables.
What I want to do now is copy the executables across from the development area to the JRun folder so I can call them from Task Scheduler, buttons and other scripts.
How do I get Maven to build the JAR files and copy them across to the JRun directory. I don't want to do this every time I build it in the development area as I may not want to put it in the run area until I've tested it fully.
I have one central library and several other files which depend on that, my test case is a project called Slicer.
This is the batch file I have written to copy across the files, it is run in the JRun directory:

It builds the Central.jar fine and copies it properly to the JRun directory renaming it to Central.jar but then it fails to build the Slicer.jar saying:
[ERROR] Failed to execute goal on project Slicer: Could not resolve dependencies for project com.mycompany:Slicer:jar:1.0-SNAPSHOT: Could not find artifact com.mycompany:Central:jar:1.0-SNAPSHOT
At first I thought it was because I renamed it, but I let it copy the whole name including the snapshot bit and it still failed.
I don't want to have to build each project from Netbeans (that's a pain) I just want to run the batch file and have it copy the current version of everything to the JRun directory, preferably with names not including the snapshot bits. I only want to do this when I'm ready so I don't want to put it in the POM which makes it do it every time.
 
Saloon Keeper
Posts: 27851
196
  • Number of slices to send:
    Optional 'thank-you' note:
If I read that correctly, you are not cataloging the Central SNAPSHOT jar into your local Maven repository where Maven can then find it for dependency resolution, You need the "mvn install" goal to do that. Just building the package isn't enough.

Incidentally, while you can do all that manual stuff for small-scale efforts, there are also tools that help maanage those processes for larget efforts.

For example, the Nexus server acts both as a site-wide shared Maven repository for your internal projects and as a cache to lessen the load when lots of developers are pulling stuff from the central Maven repos.

Building, running tests, and deploying are handled by projects like Jenkins. It provides a dashboard with status reporting.

Both apps come with their own embedded Tomcat servers that run them. They're fairly easy to set up.
 
Neil Barton
Ranch Hand
Posts: 146
  • Number of slices to send:
    Optional 'thank-you' note:
Thanks Tim,
So I added the install line to my script so it looks like this:

When I run the resulting java -jar Slicer.jaqr I get : no main manifest attribute, in Slicer.jar
Which is weird because it is defined in the pom.xml.
The pom.xml for Slicer.jar is below (in case it helps):
 
Tim Holloway
Saloon Keeper
Posts: 27851
196
  • Number of slices to send:
    Optional 'thank-you' note:
Helpful hint: You can stack multiple goals on a single Maven command. Like so:

Some goals implicitly invoke other ones. For example, the "assemble" goal implies "compile" and "war:war". Offhand I don't know if install implies assemble, but you can always five it a try!

I don't believe that your mainClass element is in the right place. I'm thinking that it would be in a "jar plugin" element. But I don't have anything handy to check against at the moment. Hopefully one of our other experts can help.
 
Neil Barton
Ranch Hand
Posts: 146
  • Number of slices to send:
    Optional 'thank-you' note:
I guess what I want to do is create a custom action in the project properties called Release and have that available. The release action would copy the compiled jar to the run directory.  I could then call this release action from a script that would do all of my projects.
I can't understand why that is so difficult!
So my question is:
How do you create an action in the POM that can do the build and copy to the run directory?
How do you stop that action being run every time you do a compile?
 
Tim Holloway
Saloon Keeper
Posts: 27851
196
  • Number of slices to send:
    Optional 'thank-you' note:
"Custom actions" in Maven are called "mojos". Maven is, in fact, nothing but a collection of mojos wired to goals and other support mechanisms.

A Mojo is actually just a JavaBean, so if's not that hard to create your own if you need to.

On the other hand, there is a very good chance that one of the standard mojo's can already take care of what you need. With the caveat that Maven absolutely hates absolute file locations because a POM is supposed to be portable. Thus, deployment is generally made to a server rather than as a simple file copy.

You don't talk to mojos directly. You invoke Maven goals. Unless you invoke a goal that directly or indirectly the mojo will not perform.

For example, unless you invoke the "clean" goal directly, Maven will not delete the project's /target directory to clean out intermediate and final products of previous builds.

If you invoke the Maven "compile" goal, all it will do is compile. It will not create a WAR or JAR.

If you invoke the Maven "jar:jar" goal, it will assemble the jar components in a prototype directory structure under /target and then run the jar utility to make a JAR file.

If you invoke the Maven "assembly" goal, it will transsitively invoke the compile and jar goals, but not the "clean" goal.

And if you invoke the "install" goal, the assembled product will be deployed to your local maven repository.

Having said all that, I'd probably just build a command file to do the build with a separate OS "COPY" command line in it to do brute-force file copying.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic
vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |