How to include .class files in intellij jar build - class

I have set up my artificat so it appropriately builds a jar file and includes the source, manifest file etc. However, it does not include the class file. Is there a way to include that as well?
Thanks!

Class files are included by default into the jar artifact you create for the module.
It's controlled by the compile output entry in the artifact:
You may not have the classes included if the source roots are misconfigured or the files are excluded from compilation, or for some other reasons described in this answer.
See this answer for the sample project link that you can download and verify the correct project/artifact configuration so that you can compare it with yours and find what's wrong.

Related

Include scala source files in sbt pack output jar

How can the scala source files of a project be included in the generated target jar produced by sbt pack?
Currently, when an IDE user of my jar tries to jump to a function in the library they will only get decompiled version of the code instead of the original source. However, other libraries pull from artifact repositories have the ability to jump to the original source code.
Thank you in advance for your consideration and response.
I think you can use:
packageSrc: Creates a jar file containing all main source files and
resources. The packaged paths are relative to src/main/scala and
src/main/resources. Similarly, test:packageSrc operates on test source
files and resources.
sbt Command Line Reference

NetBeans Include External JAR in Export to Zip

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.

SBT plugin: add resources to resulting jar?

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.

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

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.

Creating a JAR file, some classes are missing

I'm creating a JAR file in Eclipse and for some reason classes are missing. The classes that are not included are referenced in other JAR files included on my build path. What doesn't make sense is that the behavior is not consistent. Some classes on the build path get included while others do not. Any ideas?
The step I take to create my JAR file, is to export all the source folders.
JAR files are libraries, and that means - thinking object oriented:
If the classes are referenced in other JAR that included in your build, so they have to be part of the included JAR files and not part on your new JAR.
That's the whole idea of a library - If I understand your question right.
If your JAR uses those external classes, so you have to include those classes's JAR files in your project.
I hope I understood you correctly.
When I need to distribute something for internal use, I use the Maven assembly plugin: it allows you to create jars with dependencies. This is very useful if you only want to pass around one single jar: http://maven.apache.org/plugins/maven-assembly-plugin/usage.html