How I can configure the Jar task in Gradle to create the jar file with the directory entries?
Like the "filesonly=false" option of Ant's jar task, or the Eclipse option "Add directory entries" in the Export Jar dialog.
To be honest, I cannot see where is the difference between a Jar with directory entries and one without them, but I have a Spring project which uses some #Component configured bean from an external Jar: if that Jar has the directory entries, Spring is able to find the beans, otherwise not (as stated in the Spring documentation itself).
UPDATE: I figured out that in the last releases (I'm currently using 1.0-m6) Gradle already was creating the Jar the right way, that is: with all the proper directory entries. My problem was due to a bug in a task of my own that was building the classes dir with incomplete content.
I still haven't found a way to have Gradle add the directory entries, but as I already stated in the question, the last releases of Gradle do it properly. So if anyone has same problem like me, a solution is to upgrade Gradle ;o)
Related
has any way to read a file inside on dependency?
For example, I have my pom.xml and I using the maven-antrun-plugin to copy the .war generated to my remote server, but i need to pass two attributes: keyfile and knowhosts, today, I have these files inside my project, in java/resources path, but i would like to know if has any way to wrapper these files in a .jar, and use this as dependency in my project, and read theses files from this dependency.
Thank very much!
I'm not sure if I understand your question correct so let's summarize your question how I understand it:
You have a project based on Maven and build a WAR file for deployment on an application server.
In your current situation you have two files in your projects resource folder that you read from/with your project code.
You want a situation that the two files are packed in a custom jar file and put that file as dependency on the classpath/in the pom file. The question is if you can still read them from your project code.
Yes, that's possible. If you add the dependency to the dependency list in the pom file the file will be also included in the war file and then available on the classpath of your application.
Only if your project jar is marked as sealed it won't work (Sealed jar files only can read classed from it's jar file and I think that is also not possible for resource files).
If this is also a good solution is more complex to answer and I can't answer that with the current limited info I have about your project.
Is there a way we can load all the jar files inside a folder, as dependencies in a maven project.
So that, I do not have to mention each and every jar files in pom.xml, just mention or tell maven to pick all the jar files from folder 'x' and build the system.
Is this supported by maven?
I think this is supported by ant. Not sure whether gradle supports either.
In
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#System_Dependencies
you see that you can reference single files, but there is no mechanism for directories. As I mentioned in the comment, using the disk is discouraged in general.
If you need the same set of dependencies in many projects, you can write a pom for that and use it (as parent or by setting a dependency to it).
ActiveMq v 5.10.1
I downloaded ActiveMq.
Went to its lib folder.
Selected and unzipped
activemq-web-5.10.1 and
activemq-kahadb-store-5.10.1
jars.
Went inside the respective META-INF folders and noticed this file named as DEPENDENCIES.
What is this DEPENDENCIES file ?
It seems related to dependency Management.
What does it do?
After searching with various different keywords, I was eventually able to figure out what is this DEPENDENCIES file.
It comes from Apache-Resource-Bundle. See Here http://maven.apache.org/apache-resource-bundles/
It is basically a way to ensure that any jar created by Apache is having some standard. For example, it includes License, Disclaimers.
The DEPENDENCIES file simple is a list of Dependencies on which the jar depends in pretty format.
It is not at all involved in dependency management. It is simply of packaging purposes.
I have created an OSGi bundle and I want to add two external jar files to it called mediasenseplatform.jar and tinyos.jar So I added this line into my manifest file:
Bundle-ClassPAth:.,mediasenseplatform.jar,tinyos.jar
but it doesn't work and I don't see these files in my bundle jar file. How can I solve this problem?
OSGi doesn't make jar files, it is a platform for deploying and running them. If you want to include these jars in your bunde (which is just another jar) then you have to put them in there yourself.
There are build tools like maven which can do this for you.
You may also want to take a look at this related question.
Developing on the Mac with IntelliJ 9.0.2 Community Edition.
I have a program which depends on two library jars. I have figured out how to get IntelliJ to make me a jar of my source (with the Artifact tab), and even to include the two jars in it.
However, if I get a listing of the jar file it produces, it looks like this:
com/acme/MyClass1.class
com/acme/MyClass2.class
...
mylib1.jar
myLib2.jar
And, no surprises, if I double-click the jar file, it gets a NoClassDefFoundError the first time it tries to access a class in one or other library jar.
It seems I need to tell IntelliJ to "inline" the library jars -- but this menu option is always greyed out!
Does anyone have any idea how to get jars inlined in a jar artifact?
IDEA doesn't support it yet, you can use Ant integration to package your jar (either by unpacking all the jars into the temp folder and then packaging the project output plus this temp folder into the single jar or by using some Ant task like jarjar).
If you want this feature to appear in the future IDEA versions, please vote for the request.
Having the dependency JARs included in your JAR should allow yoru code to run successfully. You probably don't have the JARs on your classpath.
I will use Maven Assembly plugin. Its simple and will give you a neat little jar file..