I'm working on an embedded Jetty + Wicket app and I'm using buildr. Right now, Buildr isn't including the HTML files (which are in the main source folder, alongside my *.java files) in the jar. How can I tell buildr to include them in the compilation/package step?
Thanks for the suggestions, I think I'm close. Maybe the question I should be asking is how to get the .HTML files into the right place in the target/classes/ subdirectory? I've confirmed that if I can get the .html files in the target/classes folder, package(:jar) archives them. I'm going to start looking at that.
Thanks for the suggestions, I think I'm close. Maybe the question I should be asking is how to get the .HTML files into the right place in the target/classes/ subdirectory? I've confirmed that if I can get the .html files in the target/classes folder, package(:jar) archives them. I'm going to start looking at that.
It sounds like what you want to do, then, is treat the java source paths as resource paths. Here's how I do that in a project I converted to buildr after it was already pretty large:
# Uses before_define to default all projects to including their resources from
# src/main/java instead of src/main/resources (& similar for test) if
# those source directories exist
module InlineResources
include Buildr::Extension
before_define do |p|
[
[p.resources, p._("src/main/java")],
[p.test.resources, p._("src/test/java")]
].each do |res, path|
if File.exist?(path)
res.from(path).exclude("**/*.java")
end
end
end
end
class Buildr::Project
include InlineResources
end
This will put the *.html files in target/resources and from there they will be added to the package.
Buildr take contents in src/main/webapp folder for war file contents. You need to keep the html files inside that.
It depends on where in the WAR they need to go, but generally you can do something like this:
package(:war).include(_(:source, :main, :java, "**/*.html"))
The :war package is a specialization of the :jar package, which is a specialization of the :zip package, so you can use any of the documented methods for :jar or :zip on a :war, too.
Related
I have a NetBeans project that uses the GSON library. I've tried including the GSON.jar file without requiring future users to separately download it. However it doesn't seem to work. The project looks for the file from the relative path of my computer so the file isn't found on another user's computer. Is there a way to include GSON.jar and "Export to Zip" and keep the reference in the project itself? I'm lost!
Thank you
Exporting a Project to ZIP zips up the project folder only, and not anything outside of the folder, including dependencies. If you include the GSON.jar file in the project folder, then the JAR file will be included in the .ZIP file. It's a good practice anyway since NetBeans will use a relative classpath and thus if you move the project itself NetBeans won't give you an error message when loading the project.
I'm writing an SBT plugin. In this plugin, I need to add files to the resources directory within the resulting jar.
I don't want to change anything from the source directory (otherwise the user/developer may not understand why files appear to directory he's responsible for), but only in the generated jar.
How can I do that, is there a folder in target that correspond to the resource directory?
It seems like this is done by the "package" command, so if I can override the package command I might be able to do what I want.
Seems like I need to add stuff to resourceManaged.
My environment:
Netbean 6.9.1
Glassfish 3.0.1
Windows 7
Goal:
When my coworkers opens the Netbean Project, the library is already referenced without them manually create library, adding jars into it and reference it.
Detail:
I created Netbean project and the project has reference to few jar files in the folder.
Currently whoever opens the project for the first time, they have to manually create library and refer it to the project.
My project location:
C:\Users\masatosan\Desktop\myProject\myApp
My library location:
C:\Users\masatosan\Desktop\myProject\lib\myLib
The myLib folder contains:
some1.jar
some2.jar
some3.jar
I can achieve my goal if I create reference to individual jar file by defining to project.properties file like below: (creating reference to sqljdbc4.jar)
file.reference.sqljdbc4.jar=../lib/sqljdbc4.jar
javac.classpath=\
${libs.restlib_gfv3ee6.classpath}:\
${file.reference.sqljdbc4.jar}:
But my case is different since I have 3 jars in the myLib folder and wanting to reference them all.
Is it possible to reference all jars in myLib folder?
Please let me know if you need more clarification.
I'm sorry, but it doesn't work that way. When you create a project, you have to add the jar files individually.
However, if you put your lib folder under your project, netbeans will refer to them via relative paths. Then when you share the project (lib directory included), netbeans will be able to automatically find the jar files when the next person uses the project. That way you only have to add jar files once.
Short of using a dependency management tool like maven (which Netbeans has good support for), this is really the best solution. It uses a bit more disk space (obviously), but that's never been a huge issue for me.
I figured how so let me share.
Tool --> Library then library window pop up.
Create library called "MyLib" which contains multiple jars.
Add "MyLib" to your project. This change will be written to project.properties file under nbproject folder.
project.properties file indicates the classpath of lib reference you just added.
It should look like something below
javac.classpath=\
${libs.Excella.classpath}:\
${libs.MyLib.classpath}
Now someone else opens the project from different machine and she just needs to do step#1 and #2, which is to create library with same library name i.e. "MyLib"
I think this is what Bill was saying originally but thought it would be helpful to give step by step instructions since I finally figured .... after long time :D
I am compiling an app which is a sample app that uses an api. The api contains interface files (java files) and aidl files. Now I have problem in one of the interface file it cannot recognize the one of these aidl files exists in my project.
I have linked the whole api to the build path.
Does anyone has any idea ??
I had the same error, but it was fixed when I cleaned and rebuilded the project.
Projects -> clean project so it can automatically rebuild.
Look closely at your manifest file, check that the package etc are
spelled as you'd expect.
Also dont forget to paste the server's *.aidl and parcelable implementation (java) to your client project. These files has to have the same name and package as they were in the server project.
Here is some similar posts which might help:
ITelephony.aidl not compiling in eclipse
There are basically two possibilities.
(most likely) you need to make the folder that contains aidl files source folder. if you haven't done so, please do it.
You need a clean build.
Today when I compile my java sources the eclipse deletes all the class folder content (also files which are not classes) and recreate all the classes.
This is not good for me, is it possible to configure the eclipse not to delete all the classes folder content but just to run over all the classes instead?
The classes folder is not a good place to store your resources, it is supposed to be a pure output folder.
If you need non-classes on your classpath, you simply need to put them somewhere on the source path, Eclipse will copy them to the classes directory. This means you can do one of two thngs:
Simply mix your resources with your .java files in the same source-path
create a separate source-path just for your resources (call it "res" for example) and keep your .java files and your resources separate.