In Eclipse link two dynamic web projects to another project working as a library - eclipse

Is there a way to split up a Dynamic Web Project in Eclipse into two libraries and link them up properly?
So, I'd like to have a library project and two other applications specific web projects. Both using the library project.
I looked into the "references" option in Eclipse to link projects up but didn't work as intended. I also looked into Web Fragment feature but that didn't let me define servlets which need to be defined in the lib project as well as the servlets will be the same for both projects.
Also, is there a way to overlay content from the lib project by content defined in each project? Example:
-Lib
-WEB-INF
-img.jpg
-AppProjectA (using Lib project)
-WEB-INF
-img.jpg
I'd like to be able to use the Lib project in AppProjectA and replace the img.jpg file imported from the lib project with the one defined in AppProjectA.
I looked into Maven overlay but that's a bit too crazy for what I need to do. I also prefer Ant script over Maven. Any ideas on how to accomplish what I need to do here?

I guess with sufficiently clever Ant you probably can achieve what you want, but I don't know of anything off the shelf. However do you really need to do this? Can you get the level of reuse by just referring to resources from the other web app?
Suppose you deploy them both, each with their own context root.
A page from appA can refer to appB
/appB/imgages/img.jpg
For common code, put it in a library JAR project, packaging the JAR in the root of the EAR, or in WEB-INF/lib of each app.

Related

outside lib in GitHub

I just recently used Github, and when I was trying to upload my java project I realized that I was using some external libraries like apahce poi in this project, and these files have to be stored in libs for my application to function, do I need to upload these files because I realize that might violate some issues(maybe ?).
If yes, then what is the correct way to upload or maybe just post a link to those dependency
Use a tool that provides a dependency management system such as Maven or Gradle (these are both common choices in the Java ecosystem). Your project will then include a configuration file that Maven or Gradle will use to download dependencies so you don't need to distribute them with your project.

How do I make a multiproject gradle build in STS eclipse?

I have 2 separate projects in STS Eclipse, both using gradle to build. One is a web application. The other is a data access library that the web application uses. I have the buildship plugin for this.
Normally, I would simply change the project properties to include the data project in the web application's build path/project references/etc to make this work, but we're switching over to using Gradle for this.
I have a working build.gradle file in each project, but I don't know how to make the web app's build script build and include the data project.
I've looked for various tutorials and examples, and they talk about a root project that contains both projects inside. I have no idea how to create this.
How do I go about setting this up?
Furthermore, I'm concerned about SVN in a setup like this. I want to be able to commit each project separately since other applications will use the data access library, which is why it's a separate project. My understanding is that a nested project structure suggested by gradle would cause the entire root project to be committed as 1 entry, with both subprojects.
This would then mean that I would have to copy the data access project into all the other projects that need to use it, which would make maintaining the code a pain. At that point, I might as well not have a separate data access project and instead just include all that code in a package in the web app.
The solution to this issue was the "includeflat" command in the settings.gradle

How to create a java project as a jar for GWT

I'm wanting to use some java code as a reusable component jar in my GWT 2.4 application.
I need access to that code on the client side, so I've read that the steps involved are to
add an entry in the main projects gwt.xml file pointing to this project,
include a gwt.xml file in the jar
and put the java code under a client folder.
I assume that this has to be a gwt project itself, otherwise there would be no need to add the inherits entry or is it not possible to use a regular java project client-side?
Is there anything else I need to do for this (other than ensure the libraries in the jar fall under the JRE Emulation Reference list)?
We don't use the plugin functionality in Eclipse, but to use another project in your GWT project all you need to do is define a .gwt.xml module file in your project that you want to use in your GWT project and reference that module file with <inherits.../> in your main GWT project. You will also obviously need to add that project as a reference in the build path in Eclipse, so you don't get compilation errors. And all of that is besides the fact that your referenced project has to comply to the JRE emulation reference so it can be fully GWT compilable.

Set up an Eclipse Dynamic Web Project referencing another project

I've got a simple Dynamic Web project set up in Eclipse 3.6 Helios, but am having trouble getting it to make use of the code in another project that I've got.
I've added a reference to my other project to the build path of my web project, and I've got no problems in terms of compiling, only in terms of deploying and testing the result. The built web application doesn't have a jar in the WEB-INF/lib directory, so fair enough it can't find the code. The question is how I set this up. I've looked through the help that I can find and googled a bit but can't find anything obvious that helps out.
How do I set up my web project so that on deploying it it magically has the code from my dependent project inside it?
Thanks.
Note: Ideally I'd like a solution that doesn't involve setting up some kind of build tool. The web project deploys itself without recourse to any build tool (or at least none visible to end user), so was rather hoping that a references project could be integrated into that easily.
What goes in the deployment is determined not by the build path but by the Deployment Assembly entry in Preferences for the dynamic web project.
Use some build tool like ANT or Ivy or Maven that, on build, copies all the dependencies to WEB-INF/lib
Using a build tool is a good practice to automate build, test and deployment. You may also be interested in plug-ins like Maven Reactor.

Dynamic lib(rary) in Eclipse for NON-Dynamic Web Projects

Is there a way to add a dynamic library folder to a plain Java project similar to WEB-INF/lib in a Dynamic Web Project?
I mean, can I specify a simple folder, let's just call it lib, and have Eclipse monitor it for any library jars I might want to add or remove.
Currently I only know this behaviour from the Web App Libraries where any jar you copy into WebContent/WEB-INF/lib is automatically added to the class path, but in "regular" Java Projects I need to add every jar by hand.
Yes and no. It requires writing a suitable extension to the org.eclipse.jdt.core.classpathContainerInitializer. If you're in the Package Explorer, though, you can just select all the jars within the View and use the context menu to add/remove them to/from the Java Build Path.