Import external resource with Freemarker or Velocity in Liferay - liferay-6

I want to import an external resource from the filesystem to a Webcontent Template in Liferay (6.1). Can this be done with an include instruction (#include) from Freemarker or Velocity ?

By Velocity - No, the security rule allowed only import (include) templates from the Template-Root directory, see Velocity documentation: https://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html#include
By Freemarker - Yes, see the docu: http://freemarker.org/docs/ref_directive_import.html

Related

Sylius plugin - how to use listeners and classes properly inside package

Good day,
I got my own package that I've installed into Sylius based on Sylius plugin-skeleton. The main class in /src folder of that plugin is called, but I need to work with other classes from /src folder. For example I got /src/Menu/RewriteMenu.php that I need to trigger method via services.yaml and I need to do this inside package - not to configure listener inside Sylius project. How can I achieve it? Thank you very much for response.
You can have a src/Resources/config/services.yaml file with your services declarations there.
You then need to import the configurations from the root configuration files. For example, to import your plugin's services, you can do this:
# config/packages/_sylius.yaml
imports:
...
- { resource: "#YourPluginName/Resources/config/services.yaml" }
In cases like this one, you can take a look at other Sylius plugins source code to see how they achieve things. But as a rule of thumb, anything that you customize in a root level basis, can be also done in a plugin moving the non-php stuff inside the src/Resources folder: configs (like services, serialization, validation, etc), templates, translations, assets, etc.

Where exactly does application.conf live in the project directory structure?

The Play website says it should be in "conf", but the Lagom default HelloeWorld example places it under the "resources" directory within /applicationProject/src/main". "conf/" does not even show up anywhere in the directory structure in Lagom. Can someone clarify?
According to default Play project layout
application.conf located at conf/application.conf. So if you will inject play.api.Configuration this will represent parsed and loaded config from that file.
On another hand I suppose, Lagom is library, which relies on default Maven project layout, which differs from default Play layout, in which src/main/resources is standard folder for resources like configuration, which is why in Lagom project example you see application.conf in another folder then in Play.
What you can do as an option: take play.api.Configuration.underlying and pass manually to Lagom code.
Or keep using standard Maven project layout for Play via special plugin introduced after version 2.6.8: https://www.playframework.com/documentation/2.6.x/Highlights26#PlayService-sbt-plugin-(experimental)
Hope this helps!

Scala and Velocity Templates

I need to customize the location of a VM templates. I´m using a plugin called "sbt avro" to generate Java classes based in an Avro Schema. Can I point my custom template directory in build.sbt? Thanks!

How can I import plugin projects from my workspace without specifying them?

I am developing an scripting environment for EMF and need to import the model plugin so that my script is able to use classes generated by the model, but in order to do that I need to explicitly add the plugin to my imports.
Can I do that automatically? Like adding all workspace plugins to my imports at runtime?
You can use DynamicImport-Package: * attribute in the bundle manifest to make all exported packages visible.
Note that packages imported via DynamicImport-Package are resolved every time a class from the package is needed. Consider selective dynamic import DynamicImport-Package: *;dynamic=mymodel or buddy policy as better alternatives.

How to export and import a set of rules selected from the predefined rules in the rules configuration of the Eclipse Plugin PMD?

I am using the plugin PMD for Eclipse and have zeroed in on a set of rules preexisting in my PMD rules configuration. I want to share these set of rules with my team mates . But when i try and export the Rules from PMD, it either exports only one rule OR if I use Ctrl + A on all the rules, it exports the rules but doesn't remember which rule was checked and which was unchecked.
Deleting rules that are not useful and then exporting only selected rules leads to hardcoding of the loaction of the XML file in the rule set .
For Example, If my xml file is stored in location X in my local directory,
the rulesets become
<rule ref="X/custom_PMD_rules.xml/AbstractClassWithoutAbstractMethod"/>
What is the correct way of sharing a set of rules in a team in PMD? I was able to share the rules in Checkstyle and code templates using simple export and import. Then why not in PMD.
I use an XML ruleset file to share rules with teammates. The ruleset can use a relative path to refer to other files. Or if all the rules are in one file, you can just import them to Eclipse and the location doesn't matter.