How to mark .jar file as excluded from publish/export structure? - eclipse

I have a .war project in Eclipse. It is probably not relevant but I should mention that it was converted from a maven project using mvn eclipse:eclipse plugin.
I saw a warning that various .jar files on the Build Path were not being exported. To fix this I went to Project Properties -> Deployment Assembly and added the jars that needed to go into the .war
However, one .jar file does not need to go into the .war because it will be provided by the container. It is on the build path merely to get the project to compile.
For this .jar file, I want to get rid of the warning. One way was to Ctrl+1 to QuickFix which caused the Properties->Java Build Path->Libraries tab->...jar file to have an extra line on expanding it which says: Excluded from publish/export structure: (None)
My question is how could I have done this without Quick Fix? I could not find any way to exclude from publish/export structure without using the Eclipse Ctrl+1 Quick Fix.

There is no other UI beyond the quick fix for setting the ignore flag.

m2e-wtp automatically takes care of this for you - any dependency that has the scope as provided is excluded from the publish\export structure.

Related

Exclude Ivy Dependencies in WAR File

I use Eclipse and the Ivy plugin IvyDE.
I currently create a WAR file by using Eclipse's export to WAR functionality. I don't use an ANT build file - I let Eclipse handle that.
When I export to war, all the dependencies in the ivy.xml file get copied to the war file's bin directory. I want to exclude one (or more) of them. How do I do that?
What't the simplest way to accomplish this? If possible, I would like to avoid creating my own ANT build files and continue to use Eclipse's export tool and the IvyDE plugin.
For me the following did the trick:
copy the ivy.xml to e.g. ivy-nodeploy.xml
create/select the configurations you want to include in the deployment assembly in ivy.xml
create/select the configurations you don't want to include in the deployment assembly in ivy-nodeploy.xml
add a new ivy-library to the build path where you change the default ivy-filename to
ivy-nodeploy.xml
That way you still have all ivy managed libraries at compile time in your build path but only libraries configured in ivy.xml get included in the war file.
Right click on your project's ivy.xml, and choose "Add ivy library".
In the main tab are customization settings for the build configs, and it looks as though you can choose the conf you desire (i.e. set it to runtime). I war using Ant, so I've never tried it. I presume this will accomplish what you desire.

Errors in exporting eclipse deployable plug-ins and fragments

I have an eclipse plug-in working fine within eclipse environment.
I wanted to export it into a jar file, so I chose Export > Deployable plug-ins and fragments.
I could get a jar file, but an error was reported.
Opening the log file, it reports that I have 1242 problems (191 errors, 1051 warnings). This is some copy from the error log.
2. ERROR in /Users/LSclipse/src/lsclipse/LSDiffRunner.java (at line 61)
import edu.washington.cs.induction.OnePipeLineScript;
^^^
The import edu cannot be resolved
----------
3. ERROR in /Users/LSclipse/src/lsclipse/LSDiffRunner.java (at line 261)
OnePipeLineScript.getMatchingForRefFinder(projName, proj1, proj1Loc
^^^^^^^^^^^^^^^^^
OnePipeLineScript cannot be resolved
Why I got errors? I had 2049 warnings, but no error when I compile the plugin in eclipse IDE.
ADDED
The main project references two other projects, and references many external libraries. I attach the package view and Java build path.
There were multiple issues involved for this problem. However, the core issue was that the project apimatching and originanalysis were not eclipse plugins but just java projects. As a result, those two projects were not included in the final jar file to break the build.
Symbolic linking the two projects into the main project
I solved this issue by symbolic link the src directory into the main eclipse plugin project.
ln -s /workspace/seal/edu.ucsc.originanalysis/src /LSclipse/originanalysis
ln -s /workspace/seal/edu.ucsc.apimatching/src /LSclipse/apimatching
From the Java Build Path/Source tab, I added those two included projects as source. Eclipse Java Missing required source folder: 'src'
Now I have eclipse plugin jar file without error.
Then click F-5 to refresh the project explorer and check they are java src directory.
Select the included projects in Build tab.
Updating bin.include and source.. in build.properties tab is important. One should understand that in bin.include the ordering is also critical. lib/cdtparser.jar and lib/cdtcore.jar should be placed prior to the user of them - origin analysis/.
Copying jar files for included project into main project
I also had to copy some jar files in those projects file into the main project, and select them in Binary Build tab.
And add tim in Runtime/Classpath tab.
Select the JavaSE-1.6 in Execution Environments.
I have lots of "Must Override a Superclass Method" errors. With the hint from this post - 'Must Override a Superclass Method' Errors after importing a project into Eclipse , I removed the J2SE-1.5 to resolve this issue.
You can not add third party libraries into class path of Java when developing a plug-in. It is the way to build standard Java application, but plug-in is a kind of OSGi bundle that has itself rule for class loading.
The correct way is adding third party libraries into the class path of your plug-in.
Add below declaration into MANIFEST.MF of your plug-in,
Bundle-ClassPath: lib/log4j-1.2.7.jar,
xml-apis.jar,
...
Check those links [1], [2] for understanding it.
This is what have a question on and see as potential solutions to potential problems.
Is this class comfing from a referenced jar or is it in the actual plugin edu.washington.cs.induction.OnePipeLineScript;
You seem to have a lot of soure folders and wondering if your build.properties file is showing any warnings and that you also have this defined for each of the source folders in your build.properties source.. = src/
Your external jar libraries appear to be in a folder that is of type source which is not correct. It should be a non-source folder (which you can tell a source folder by the package icon decorator) and you should make sure in your manifest editor that for runtime you have the lib checked so that it includes the jars in the build. To unmark it as a source folder select the drop down menu in your navigator view go to filters and uncheck .resources which will then show the .classpath file in that file you will see the folder to be kind="src" (i believe) remove that.
Somehow it also looks like you have linked source folders which is a practice I would not suggest and am not sure if that will cause problems when exporting the plugin. If you can avoid linked source folders that would be better.
Also it seems like you are confusing java build path configuration for plain java applications with plugins running in OSGI which is not configured through java build path but your manifest.editor So as a rule of thumb if its a plugin don't even bother trying to configure the java build path because OSGI is different, that could be causing issues as well
Select "Use class files complied in the workspace" in Options works for me.

Trying to include a maven built library in Eclipse, giving missing artifact error

I've seen that there are quite a few questions regarding this problem, but unfortunately none have solved it for me. Here is a screencap of what's going on:
It is dependent on the android-support-v4 jar file which as you can see is added to my build path. It the exact jar file from the maven library directory's libs folder. I've tried the following:
Restarting Eclipse
Cleaning the project
Right-clicking the project and updating dependencies
Updating project configuration Disabling and re-enabling workspace resolution
Nothing has helped. Is there any other tricks to getting this resolved? All of the answer's I've seen suggest doing these things that I have already tried.
Thanks a lot!
Actual root cause:
The OP JMRboosties reports in this instance having to desactivate Proguard (the tool which shrinks, optimizes, and obfuscates your code by removing unused code and renaming classes, fields, and methods with semantically obscure names)
disabling proguard on the line where the error occurred (the <plugin> item) in pom.xml solved the problem
(See "How to use ProGuard with android-maven-plugin ").
Certain side-effects can result from using Proguard: For example, the Proguard page does mention:
The default proguard.cfg file tries to cover general cases, but you might encounter exceptions such as ClassNotFoundException, which happens when ProGuard strips away an entire class that your application calls.
Original answer:
As mentioned in this GitHub post:
you need to use maven Android SDK Deployer to install it:
I'm going to deploy my own android artifacts to my personal repository to avoid having this problem again.
If you're not explicitly using Maven you can just import it as a regular Android project into eclipse and it'll pick up the .jar from the libs/ directory.
(Note your android-support-v4.jar isn't in libs in your project)
declare it in your pom.xml.
You have to install both Android 1.6 and the compat lib using the maven SDK deployer for now.
cd to platforms/platform-4/ and extras/compatibility-v4/ in the deployer and run mvn install in each.
Hopefully the compat lib makes it into maven central soon so I can avoid this step.
Again, the project is set up to be used as a normal Android project in eclipse too completely separate from maven.
File, New, Project, Android, use existing sources, select library/ folder.
Assuming you're using m2e-android behind the scenes, the reason you're getting compile problems is that the m2e-android plug-in strips out all provided scope dependencies from the Eclipse project classpath.
We do this because, due to changes in ADT 16.0.0, any JAR file in the Eclipse classpath will be packaged into distributable APK file.

Maven/Eclipse: The default build path for resources excluded everything

I'm using M2E for maven integration with eclipse. My unit tests reference property files in the resources/ directory. Well, everything fine in the command line test (mvn test). However, in Eclipse, the resources couldn't be found.
Check the Java Build Path, there, all resources entries are marked with Excluded: **. (I deem it should only exclude .java/.class files) Then, after removed the exclude pattern, the problem fixed.
I'm not sure whether I should remove all Excluded ** by hand, or maybe I doesn't use M2E correctly.
P.S. The projects are imported by Existing Maven Projects.
It does this on purpose, to allow the maven-resource-plugin to do the resource copying. You might have filters enabled after all. I have pestered the m2e list about this, you are welcome to file a bugzilla and join in the pestering. it is really annoying.

how to fix Eclipse losing reference to third party jar in project sets

Occasionally I see eclipse lose the reference to the third party jars contained in the a projects. (you get the the build path error stating the jar cannot be found)
Its easy enough to fix as you can remove the jar, save the properties of the project and then go in and re-add the jar that it could not find, eclipse can then see the path to the jar and you can then compile again.
the problem is that if you have a lot of projects in your build you would have to do this task a lot.
Is there anything you can do to force eclipse to recognise that it actually has the jar on its classpath?
I have also faced the similar situation many times with my projects in eclipse. The jar file path is correct in the .classpath file and the jar is present still eclipse do that. To fix it you open the .classpath file and resave it and refresh the probject in eclipse and it builds fine.
That's a weird behaviour...
If that's ok you can use Maven 2 for your projects. This means that you have to follow Maven's project structure, which is quite ok, but it can be a pain if you decide to migrate old projects.
Then you can run mvn eclipse:eclipse whenever you want and that will fix your problem in a few seconds.