• 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

exec-maven-plugin

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
i've a project with exeternal jar as dependencies and i can't run it using the exec-maven-plugin.
This is the POM:



The prompt from maven is:



As you can see the system can't find the external library but i dunno how can solve this issue.
 
Saloon Keeper
Posts: 15630
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

Why are all your dependencies in the system scope?
 
Enrico Pinzaglia
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've read that for jar files the scope must be system. If i try to change it i will get an error.
 
Stephan van Hulst
Saloon Keeper
Posts: 15630
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using the system scope tells Maven that it doesn't need to do anything to get the dependencies from anywhere, because the dependencies are already available at the path specified by <systemPath>.

It looks like most of the dependencies in your POM are libraries that aren't present in any public repository, so I guess that's the reason that the scope was set to system. This is still not the proper way to do things. Instead, such dependencies should be installed to a public, company or local repository before you build your project.

Anyway, is there a file fontchooser.jar in the lib/ directory in your project? If not, then that is the problem you are having.
 
Saloon Keeper
Posts: 27886
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Enrico Pinzaglia wrote:I've read that for jar files the scope must be system. If i try to change it i will get an error.


That's the problem with reading things on the Internet. The Lizard people get on there and post fake information. I read about it on the Internet.

The default scope for Maven dependencies is "compile", which says to pull the dependency jars from a Maven repository for compiling the code and for inclusion in the target. That's usually what you need. Exceptions being things like the JEE jars which are provided by webservers for webapps to use.
 
Enrico Pinzaglia
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Anyway, is there a file fontchooser.jar in the lib/ directory in your project? If not, then that is the problem you are having.


Yes
 
Stephan van Hulst
Saloon Keeper
Posts: 15630
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you show us your project's directory structure?

Regardless, even though we might find a solution that preserves your current POM, I STRONGLY recommend installing your dependencies to a local repository (might even be a repository inside your project directory so you can commit the dependencies to source control) and then using the compile scope, as one normally would.
 
Tim Holloway
Saloon Keeper
Posts: 27886
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Can you show us your project's directory structure?

Regardless, even though we might find a solution that preserves your current POM, I STRONGLY recommend installing your dependencies to a local repository (might even be a repository inside your project directory so you can commit the dependencies to source control) and then using the compile scope, as one normally would.



I don't know about a "repository in your project directory". As as far as I know, Maven only allows one repository per user and if not, it would still make things messy, as it would break Maven's transportability.

As it happens, the CodeRanch JForum software has the problem that a number of critical libraries used to build the app are not in public Maven repositories and cannot be built locally (at least reliably). My solution for Mavenizing the JForum build process was to create an "external lib" directory" in the project, copy those jars there and include scripts/instructions on how to install them into one's local Maven repo before doing builds.
 
Enrico Pinzaglia
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is not my project but a open source project. The directory structure is:

 
Stephan van Hulst
Saloon Keeper
Posts: 15630
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:I don't know about a "repository in your project directory". As as far as I know, Maven only allows one repository per user and if not, it would still make things messy, as it would break Maven's transportability.


Why does it hurt? I'm pretty sure you can configure multiple repositories, and you can configure a repository path that's relative to the project's base directory, similar to how OP configured their systemPaths. It should not affect the build for different systems/users.

I haven't verified though.
 
Stephan van Hulst
Saloon Keeper
Posts: 15630
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Enrico Pinzaglia wrote:Is not my project but a open source project.


In that case, can you link to where the project is hosted?
 
Tim Holloway
Saloon Keeper
Posts: 27886
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:

Tim Holloway wrote:I don't know about a "repository in your project directory". As as far as I know, Maven only allows one repository per user and if not, it would still make things messy, as it would break Maven's transportability.


Why does it hurt? I'm pretty sure you can configure multiple repositories, and you can configure a repository path that's relative to the project's base directory, similar to how OP configured their systemPaths. It should not affect the build for different systems/users.

I haven't verified though.



A repository has a URL. A local copy of a project does not, unless Maven honors the "file:" protocol in URLs and even then, it would have to be relative to the project directory and not an absolute file URL. Otherwise you break the portability of the POM. Maven has very firm opinions on non-portable resources in POMs.

Maven actually references dependencies from the user's Maven cache, and the location of the cache is determined from the localRepository setting in the Maven config file. It defaults to ${user.home}/.m2/repository/ and must be given as an absolute path. There Can Be Only One. Repository URLs given in the Maven config and/or POM files provide the sources from which Maven will search for dependencies and install them into the localRepository.

Note also that you can't just dump JARs into a directory and call it a repository. Maven expects definite directory structure and metadata. The only safe way to catalog a JAR into a repository is to do a "mvn install" of the artefact in question. The actual internal repository structure is not fixed for all time, and they've changed it once already. Maven tracks this automatically. Assembling a repository manually doesn't
 
Stephan van Hulst
Saloon Keeper
Posts: 15630
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:A repository has a URL. A local copy of a project does not, unless Maven honors the "file:" protocol in URLs and even then, it would have to be relative to the project directory and not an absolute file URL.


Yes, it allows the file protocol and you can also use a predefined project property to refer to the project directory.

The actual internal repository structure is not fixed for all time, and they've changed it once already. Maven tracks this automatically. Assembling a repository manually doesn't


You can use Maven commands to build the repository, and a project should be bound to a specific Maven version anyway.
 
Enrico Pinzaglia
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So if i just understand i have to install the jar files in a local repository and then use them. Is that correct?
 
Stephan van Hulst
Saloon Keeper
Posts: 15630
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roughly speaking, yes.

If you have a link to the open source project, we might write down some concrete steps for you to follow.
 
Tim Holloway
Saloon Keeper
Posts: 27886
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Enrico Pinzaglia wrote:So if i just understand i have to install the jar files in a local repository and then use them. Is that correct?



Si. Again, I don't recommend making a local repository be part of your project, but if you don't want to do like me and catalog JARs into your Maven cache, you can always set up an independent external repository.

If you're sharing stuff like this between multiple developers, you could also consider setting up a local repository server such as Nexus. That way you can not only keep your "orphan" JARs under Maven control, you get the benefit that the local repo server will cache for the entire user group, reducing the load on the Internet for repo fetches. There are also benefits for DevOps and co-ordination between developers.
 
Stephan van Hulst
Saloon Keeper
Posts: 15630
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, I just tried this out in a different project of mine:

This creates a folder named repository in your project directory and installs the dependency in that folder.

Then, you can add something like this to your project POM:

I explicitly added the central repo, because it ensures that the Maven Central Repository is searched for dependencies first. Only if the dependency can't be found will it look in the project-specific repository. You can swap these two around if you want the private repository to have higher precedence.

I don't really see any issues with this. It's portable, and you don't need separate build instructions for other contributors. If you use the maven-wrapper-plugin to generate a mvnw build script, you can fix the Maven version used for your project and building the project will be as easy as running "mvnw clean install". Contributors don't even need to have Maven installed for this to work.
 
Tim Holloway
Saloon Keeper
Posts: 27886
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Next, install Jenkins as part of the Maven project. (snarf)

I just don't like putting stuff into a Maven project that a basic "mvn install" can't/won't automatically deal with. Especially complex stuff. Especially generated stuff that doesn't generate into the target directory. It mocks the "mvn clean" paradigm. Also the "unzip-and-build-immediately" paradigm.

In any event, all of the above (including what I do) is moot, since for a single project, the better way is to simply put the non-managed JARS into the classpath in /src/main/resources. That also applies to loose classes, if you have any.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic