views:

82

answers:

3

Quite new to maven here so let me explain first what I am trying to do:

We have certain JAR files which will not be added to the repo. This is because they are specific to Oracle ADF and are already placed on our application server. There is only 1 version to be used for all apps at anyone time. In order to compile though, we need to have these on the class path. There are a LOT of these JARS, so if we were to upgrade to a newer version of ADF, we would have to go into every application and redefine some pretty redundant dependencies. So again, my goal is to just add these JARs to the classpath, since we will control what version is actually used elsewhere.

So basically, I want to just add every JAR in a given network directory (of which devs do not have permission to modify) to maven's classpath for when it compiles. And without putting any of these JAR files in a repository. And of course, these JARs are not to be packaged into any EAR/WAR.

edit:

Amongst other reasons why I do not want to add these to the corporate repo is that:

  1. These JARs are not used by anything else. There are a lot of them, uncommon and exclusive to Oracle.
  2. There will only be one version of a given JAR used at anyone time. There will never be the case where Application A depends on 1.0 and Application B depends on 1.1. Both App A and B will depend on either 1.1 or 1.2 solely.
  3. We are planning to maintain 100+ applications. That is a lot of pom.xml files, meaning anytime we upgrade Oracle ADF, if any dependency wasn't correctly specified (via human error) we will have to fix each mistake every time we edit those 100+ pom.xml files for an upgrade.
+1  A: 

Although you explicitly stated you don't want them in the repository, your reasons are not justified. Here's my suggestion:

  • install these jars in your repostory
  • add them as maven dependencies, with <scope>provided</scope>. This means that they are provided by your runtime (the application server) and will not be included in your artifacts (war/ear)

Check this similar question

It is advisable that an organization that's using maven extensively has its own repository. You can see Nexus. Then you can install these jars in your repository and all developers will use them, rather than having the jars in each local repository only.

(The "ugliest" option would be not to use maven at all, put put the jars on a relative location and add them to the classpath of the project, submitting the classpath properties file (depending on the IDE))

Bozho
These JARs are uncommon and exist in no known repo. Can you list a reason why they should be added to the repo?
Zombies
Also, everytime the JARs change (we upgrade) we would have to go into 100 some applications and edit the dependencies...
Zombies
@Zombies see my update
Bozho
We do intend to have our own central repo. And Nexus will most likely factor into that. And we want to put JARs in that repo, but not these uncommon ADF JARs because of other reasons. So, we do not want to add these ADF JARs to the dependencies... Wouldn't it be a nightmare to have to go into 100+ applications, and then redefine the dependencies for each JAR that was updated?
Zombies
what are these jars actually?
Bozho
Some of them are proprietary Oracle Jars used for ADF runtime. We are going to have our own strategy for managing these. But then again I am wondering that perhaps putting them into a central repo might be best. Not sure atm. adf-richclient-api-11.jar would be an example. Some are much more common like javax.jsp_1.1.0.0_2-1.jar
Zombies
I sense something very wrong with this. Typically, a library would have no more than 3-4 jars. javax.jsp isn't related to ADF - it's something ADF depends on. Maven would handle these dependencies automatically.
Bozho
So you are saying I should add adf-richclient-api-11.jar to internal repo? What happens when we update ADF to adf-richclient-api-12.jar ? Do we have to touch every application and each some 20-30 ADF jar versions?
Zombies
every application decides for itself whether or not to upgrade its version. You store all jars in the repository, under the appropriate versions. Mass-upgrading is a hard thing anyway, and using maven it would be easier.
Bozho
+1  A: 

I see three options:

  1. Put the dependencies in a repository (could be a file repository as described in this answer) and declare them with a scope provided.
  2. Use the dirty system scope trick (i.e. declare the dependencies with a system scope and set the path to the jars in your file system.
  3. Little variation of #2: create a jar with a MANIFEST.MF referencing all the jars (using a relative path) and declare a dependency on this almost empty jar with a system scope.

The clean way is option #1 but others would work too in your case. Option #3 seems be the closest to what you're looking for.

Update: To clarify option #3

Let's say you have a directory with a.jar and b.jar. Create a c.jar with a Class-Path entry in its META-INF/MANIFEST.MF listing other jars, something like this:

Class-Path: ./a.jar ./b.jar 

Then declare a dependency in your POM on c (and only on c) with a system scope, other jars will become "visible" without having to explicitly list them in your POM (sure, you need to declare them in the manifest but this can be very easily scripted).

Pascal Thivent
Regarding #3. Would we be able to add all JARs in a given directory or must we specify each JAR, one-by-one?
Zombies
+1  A: 

Hi,

if you are developing ADF (10g / 11g I guess) components, I suppose you'll be using JDeveloper as IDE. JDeveloper comes with a very rich Library Management Tool that allows you to define which libaries are required for compiling or which ones should be packaged for deployment. I I suppose you will already know how to add libraries to projects and indicate in the deployment profile which ones should be picked while packaging. If you want to keep your libraries out of maven, maybe this could be the best approach. Let´s say the libraries you refer too are the "Webcenter" ones, using this approach will guarantee you you have the adequate libraries as JDeveloper will come with the right version libraries.

Nevertheless, as you are using maven I would not recommend to keep some libraries out of control and maven repositories. I´d recommend choose between maven and Oracle JDeveloper library management. In our current project we are working with JDeveloper ADF 11g (and WebCenter) and we use maven, it simply make us library management easier. At the end of the day, we will have a big amount of third party libraries (say Apache, Spring, etc.) that are useful to be managed by maven and not so many Oracle libraries really required for compiling in the IDE (as you would only need the API ones and not their implementations). Our approach has been to add the Oracle libraries to our maven repository whenever they are required and let maven to control the whole dependency management.

As others say in their answers if you don´t want the dependencies to be included in any of your artifacts use <scope>provided</scope>. Once you configure your development environment you will be grateful maven does the work and you can (almost) forget about dependency management. To build the JDeveloper IDE files we are using the maven jdev plugin, so mvn jdev:jdev would build generate our project files and set up dependencies on libraries and among them to compile properly.

Updated:

Of course, you need to refer to ADF libraries in your pom files. In our project we just refer to the ones used on each application, say ADF Tag Libraries or a specific service, not the whole ADF/WebCenter stack. For this purpose use the "provided" scope. You can still let JDeveloper to manage your libraries, but we have found that it's simpler to either have a 100% JDeveloper libraries approach or a 100% maven approach. If you go with the maven approach it will take you some time to build your local repo at first, but once that's done it's very easy to maintain, and the whole cycle (development, build, test, packaging and deployment) will be simpler, having a more consistent configuration. It's true that in a future you'll have to update to later ADF versions, but as your repository structure will already be defined it should be something fast. For future upgrades I'd recommend to keep the ADF version as a property on the top pom, that will allow you to switch faster to a new version.

Marcos Carceles
What about upgrades to ADF? don't you have to respecifiy each dependency for every single application?
Zombies
@Zombies Of course, you need to refer to ADF libraries in your pom files. In our project we just refer to the ones used on each application, say ADF Tag Libraries or a specific service, not the whole ADF/WebCenter stack. (See updated answer)
Marcos Carceles