How to put a component's classes dir in classpath - moqui

I am building groovy classes under my src/main/groovy dir and I build them and the .class files are under build/classes, but when I run the code it does not see those classes.
What do I have to do to make those files be seen?

If your src and build directories are in a component directory you can have the build file either put the classes in the /classes directory or put them in a jar file in the /lib directory. You can also put class files and other classpath resources in the runtime/classes directory or in a jar file in the runtime/lib directory.
The Moqui classloader adds these to the classpath automatically at runtime.

Related

Should the /out folder in an intellij project be added to gitignore?

I have observed the following different files in my intellij java project -
.idea folder
.out folder
.iml file
.src folder
Out of these files I'm thinking of adding .idea folder, .out folder, .iml file to .gitignore? Am I right? Or do these folders and files hold some significance which needs tracked by git?
Please see how to handle files in .idea in terms of Git:
https://intellij-support.jetbrains.com/hc/en-us/articles/206544839-How-to-manage-projects-under-Version-Control-Systems
The .out folder can be added to .gitignore, since it is created once the project is built (when you press Run in IntelliJ).
The .iml file and the .idea folder stores information about your project. Do NOT add this to .gitignore, as it is needed when others clone your project and build it themselves.
Source/s:
https://stackoverflow.com/a/44362056/14368392
https://rider-support.jetbrains.com/hc/en-us/articles/207097529-What-is-the-idea-folder-

How does webpack determine which files/folders it will include in a bundle

I have a set of files in my project's src/main/resources folder - such as index.html, myproject.css, i18n.js
When I run webpack only one file is automatically copied over to the bundle, namely 118n.js. Why does this get bundled but nothing else?
Currently, all the .js files on the classpath are eligible to be bundled. This is why your i18n.js file is included in the resulting bundle.
Note, however, that it is not planned to continue to support this behavior (relying on .js files on the classpath). Instead, you should include which resources are eligible to be bundled with the jsSourceDirectories setting key. For instance, to include all the files of the src/main/resources directory:
jsSourceDirectories += (Compile / resourceDirectory).value

Include external files (not libraries) in a project in Intellij

I have a project ‘P’ in directory ‘P’. I want the use a css file in ‘P’ but the css file is not in directory ‘P’. It is at one level above ‘P’. Could I still include/use the css file in ‘P’ without changing the directory structure or making a copy of the css file?
Yes, you can add directories outside of the root project directory:
Project Structure → Modules → Sources → Add content root
Then after adding a directory, you can see it under your project root.

Packaging a Repast model as a jar file without including the source code?

I want to create a model jar file but not include the source code. Is it possible? The Repast model installer includes the source code by default, but I would like to hide it from the recipient of the model.
Yes, it’s possible but there is an important caveat. Compiled Java code distributed as binary files like jars can be trivially de-compiled back into the original source code with remarkable accuracy. If your goal is to protect proprietary source code then code obfuscation is required – see https://www.excelsior-usa.com/articles/java-obfuscators.html for more details. Code obfuscation is unfortunately a fairly complicated subject.
There are two ways to omit the project source code from the Repast model installer:
Method 1 – Remove /src elements from the model installer configuration files. This will instruct the model installer to omit /src files in the installer jar. The compiled agent classes will be in the usual project /bin folder.
In the /installer/installation_compnents.xml file, around line 156 comment the following:
<!--
<pack name="Sources" required="no">
<description>The model source code</description>
<file src="$StagingOptionalArea/src" targetdir="$INSTALL_PATH/Geography"/>
</pack>
-->
The “” denote the start and end of the code block that is commented. Next, in the /installer/installation_coordinator.xml file, comment around line 62:
<!-- Copy optional files to a separate directory -->
<copy todir="${StagingOptionalArea}" overwrite="true" failonerror="false">
<fileset dir="." casesensitive="no">
<!-- <include name="**/src/**" /> -->
<include name="**/docs/**" />
</fileset>
</copy>
Here you only want to comment the single line that copies the /src folder and not the /docs folder (although you can if you like). Now just build the model installer as usual.
Method 2 – export the /src folder to a jar file. This method does not require any changes to the default installer files as in the first method. However it requires deleting the source code after exporting it to a JAR file which means you would need to work on a copy of the project to preserve your source code. To export the model code to a JAR file, right click on the /src folder and select Export… -> Java -> JAR file. In the export dialog, make sure the src folder is checked in the “Select resources to export” box and then specify the JAR file name and location. The best place to export the jar file in in the project /lib folder. Most other options should be left as default. Make sure that “Export Java source files and resources” is unchecked, otherwise it will copy the source into the jar file. After the JAR files is generated and you verify that it exists in the /lib folder, then delete the contents of the /src folder but not the /src folder itself. This will permanently delete the model source code, so again please work on a copy of the project if you take this route. Simply renaming or deleting the /src folder will cause the installer to fail, so the delete is required for this method. Last, the user_path.xml file in the .rs folder needs to be updated to reflect the change in the source code location. Change the line to assuming that the exported model JAR file is in the /lib folder. All of the model code is now in the single JAR file in your project/lib folder. The /src and /bin folder should be empty at this point. build the model installer as usual. The option to install source code will still appear in the installer, but no source is contained in the installer JAR so no source will be copied upon installation.

where to place images upload directory on a gradle project

I am using gradle and I have the default folder structure set by IntelliJ.
I am wondering where should I place an images uploads folder in this folder structure so that I can use it for running and testing?
I am thinking that it has something to do with gradle configuration file.