What is the difference between Java Build Path - Add External JARs Button and Add Variable Button Functionality,
Why its required. Please explain in detail.
Both can be used to achieve the same thing: add a JAR to your build path.
Suppose you have a project P1 that wants to use a JAR installed by supplier S1, which happens to be located at C:\S1\aproject\jars\Useful.jar
Client Add External JARs, navigate, select, and we're done.
But, consider these cases.
1). Suppose you have several projects that all want to use that same JAR? You end up repeating that for projects P1-PN. Gets dull. What's worse, suppose you install a new version of S1's stack, now you need to update all those project's build paths to reference
C:\S1\aproject-**v2**\jars\Useful.jar
And what's worse, if you miss one then you are running two versions of the JAR that may be really bad!
2). You share a project with a colleage who happens to have S1 product installed in a different location. They now need to amend the project to point to
E:\MyFavouriteThings\S1\aproject\jars\Useful.jar
And if you are using an SCM you may tread on each others toes.
So:
Instead Add Variable allows you to define a Workspace variable (ie. specific to your environment) which can then be used to reference that JAR
$(S1_JARS)\\Useful.jar
Now you a single place to update to a new version of S1, and each developer can set his own value for S1_JARs.
I would recommend using Variables for non-trivial development scenarios.
Related
we have some dependent/common jars of the plugin which we are currently placing in .lib of ContentNavigator application and referring the same in build.xml of ContentNavigator. while we placed the jars in local and tried to give the local path in build.xml it didn't worked out.Can anyone suggest what is the recommended way of doing it?
I've applied the following approaches:
Embed/extract all the content(.class files) of the dependency-jars within the navigator plugin. While the upside is that you have a nice bundle containing all your dependency-classes, it might cause some problems with signed jar's. Or on files that are duplicate amongst your dependencies.
Make use of the "Shared Library" concept. You basically "attach" jar's to the classloader of your server/JVM, Application(ear) or module(war). In your case you would probably attach the shared-library to the navigator.ear, allowing all plugins to access the dependencies you register as a sharedlibrary. One huge downside is (in my experience) that you need to reboot websphere every time you update one of the library-jars.
A third option is to move the functionality out of your ICN Plugin, and let another EAR/EJB do the work (and reference to it from the plugin using a jndi lookup).
I personally prefer option 3 because it's the cleanest way to bundle your functionality&dependencies in an EAR. But option 2 will be a good call when libraries are truely common and won't be updated often.
p.s. In your question you mention the build aspect of your software as well (e.g. "how to correctly reference the dependencies"). You might want to look into the concepts of "dependency management" (using Ant, IVY is a good choice, but i would suggest moving to Maven, or Gradle)
I'm looking for an ant task that would allow me to do things like e.g. rename an Eclipse project, just as if I clicked "Refactor > Rename" (so it would rename both the directory, and the project name, and tell the workspace where to find the updated project).
I remember vaguely, that there was some project which already provides such tasks, but I can't find it anymore (or maybe I only dreamed it?)
If there isn't, then I'm ideally looking for a complete example how to implement something like this (including which libraries I need etc.)
Two existing Ant addons with specific tasks for Eclipse i know of :
Ant4Eclipse
Ant-Eclipse
but i don't know if they provide a solution for your needs - never used them.
After all you may use some low level approach, means simply editing the eclipse config files (.project ..) programmatically !?
I am working with eclipse on a mavenized project which has a significant number of modules/subfolders/maven subprojects.
Whenever I look for a resource, or make any kind of research, it shows me every occurrences in every project times two because of the target folder...
example:
projectA/projectB/src/main/resource/.../Foo.xml
if I look for a string that is in foo.xml, it will show:
projectA/projectB/src/main/resource/.../Foo.xml
projectB/src/main/resource/.../Foo.xml
projectA/projectB/target/main/resource/.../Foo.xml
projectA/projectB/target/main/resource/.../Foo.xml
That is a lot for one file. Besides, let say that the prohectA is intended to create a pom, not a war, a jar, or a ear... The problem is now, that if I select this entry, I won't be able to use the auto completion, or the inspect element functionality (that I can't work without!!!!). Even worse: if i select a target directory, my changes will be overwritten on the next maven build...
What can I do? At the moment, I am just paying attention, but it is kind of painful... And I do not have time to go through all the project to mark them one by one as derived (basically around 1000 clicks), so they do not come up in the searches... Besides, the target folder would just appear again after the next maven build.
Any ideas?
The perfect way would be to have eclipse recognize the subproject nature of these, and not show the different occurrences... and maybe setup a filter for the target resources... I do not know if it is possible.
I am also willing to write a tiny script, if people are kind enough to explain to me what eclipse files it should modify in order to accomplish this.
Import the sub projects as separate Eclipse projects (this should happen automatically if you point the Maven import wizard at the master project directory). Keep the master project closed if you're not editing it. You'll still get the target folder version of resources, but at least only once.
You could use that AutoDeriv Eclipse plugin here AutoDeriv to list the paths you'd like to mark as derived, and discard from research etc. as you would do in a .gitignore file.
Once it's done, resources are always correctly marked as derived, even after a maven clean/install.
[edit]
You can write rules at workspace level, to handle several projects at once.
Exclusion rules allows you to mark everything as derived, except for a peculiar folder or file.
Since the 1.3.0 version, Eclipse decoration helps you to quickly see the effects of the plugin.
Disclamer, I wrote it =)
How do I reference another project which has code I wish to leverage in XCode 4. In particular I'm trying to make use of the NSDate extensions from here.
Some notes:
I was assuming I should probably reference rather than trying build a framework
I tried copying the existing "Hello World" xcode project file across into my project, however this didn't seem to work
Do I need to create a new "Target" based on "coco touch static library" option?
Then would I need to Edit the current Product Scheme so that when I build the new target would build
What do I need to do on my project side exactly - should going Add Files, and choosing the extensions Xcode Project File be enough?
thanks
I was assuming I should probably reference rather than trying build a framework
yes, reference and link with it, unless you need only a bit of it. at this stage, separating the bits you want may be an advanced topic (depends on the lib's layout/depends as well). you should prefer to reference and link because it will normally minimize your maintenance time, especially if you use it in multiple projects.
I tried copying the existing "Hello World" xcode project file across into my project, however this didn't seem to work
you don't create a project, you add the library's xcode project to your app or library, set the lib as a dependency, add the library to your search paths if needed, then link with the library.
Do I need to create a new "Target" based on "coco touch static library" option?
no
Then would I need to Edit the current Product Scheme so that when I build the new target would build
no. you configure it as a dependency. you may need to alter the lib's build settings if there is a major conflict, which the linker or compiler would point out.
What do I need to do on my project side exactly - should going Add Files, and choosing the extensions Xcode Project File be enough?
start with the process outlined above.
There is no reason to bring in an actually project. Either you can bring in the source files themselves and you could even use the same exact files instead of copying them if you want. However, if you have more than just a few files, and you don't think you will be changing the code much, then creating a static library would probably be the best option.
I have 2 projects and I want to use in the first project, a class (i.e. view controller) of the second. Instead of importing all the files of the second project in the first one, is there a way to link it like a framework or library?
I tried the following unsuccessfully:
Dragged-dropped SecondProject.xcodeproj and checked SecondProject.app as a target
Added it as a dependency project in the first project dependencies
Pointed to the header files by adding in the "Header Search Paths" a path pointing to the second project which I copied in a subfolder of the first project.
When I include "SecondProjectViewController.h" I get no errors but when I try to instantiate it I get the "OBJ C referenced from" error.
Any help is deeply needed and appreciated! =)
F.
As an experienced developer I would suggest not sharing code this way across projects. The simple reason is that changes in one project will then directly effect other projects, often rendering them un-compilable. For example, if you share a controller class and decide to implement a change with a new import, then any project that uses that class will be broken until you open then in xcode and ensure that the imported class is available.
A better method is to compile your first project as a static library or framework. I'd also recommend ensuring that it is version some way. For example, in my projects I create static frameworks and store them in a directory called "v0.0.1", "v0.0.2" etc.
The framework can then be dragged and dropped into a second project to use it. The second project then refers to it via the directory path. The advantage of doing this is that if I then change the first project, the second one if not effected by the changes until I choose to update the frameworks path.
Sharing files between projects will work for small cases, that being 2 or 4 projects, but once you have more than that it rapidly becomes un-manageable.
You have only a few steps to go:
4) in First project, click the disclosure triangle in the Groups and Files section for the Second Project reference. this will display the targets of Second Project.
5) Drag the target reference (e.g., static library) from Second Project to the target in First Project's link phase.
That should clear up all the linker errors for the symbols which exist in Second Project's library. Of course, you'll have to remove those sources (based in second Second) which are compiled and linked from First.
Managing static libraries for huge codebases is dead easy this way (although I prefer the build up to the minute (as well as several build variants), and don't reference archived binaries as Derek does). Learning to minimize changes which break builds takes time to learn. dynamic libraries are a bit different - depending on their distribution, you may want to version (as Derek outlined). It's good to share, but you should put the shared exported symbols in a library, which is a dependency of both apps. Just be careful not to add too much unnecessary objc symbols to the library - objc symbols and their references cannot be stripped from the final executable and they will cause runtime collisions if they appear in two images (dylib, app, static lib) within the same process.
You can add the view controller's files to your 1st project regardless of where they are on disk -- the project will make a reference to their location.