I don't like the idea of mixing scripts with Java source code. I understand it makes sense from the perspective that scripts and Java are both "source code", but the nice thing about keeping the Java source separate is it can be removed during deployment - reducing the project's footprint on the target server.

Adrian Crum
Sandglass Software
www.sandglass-software.com

On 1/21/2015 12:36 AM, Jacopo Cappellato wrote:

On Jan 20, 2015, at 4:29 PM, Adrian Crum <adrian.c...@sandglass-software.com> 
wrote:

I suggested a Maven-like folder structure years ago, and there was pushback 
from Adam. He was concerned that test classes would reside in the same package 
as the classes being tested - which would expose their implementation.

This is a non problem: even if we split the main and test classes using the 
src/main and src/test folders we are still free to place them in the packages 
we like.


The classpath under the script folder is not necessary. That was used before we had 
FlexibleLocation and the "component://" URL feature. So, instead of your 
suggestion we could do:

script/groovy/FooScript_1.groovy
script/groovy/FooScript_2.groovy
script/minilang/BarScript_1.xml
script/minilang/BarScript_2.xml
script/js/BazScript_1.js

+1 on the idea of getting rid of the "classpaths" for Minilang as a general 
direction; I still think they should go under src/minilang but at this point this is just 
a matter of personal taste.
As regards Groovy, with it you can implement classes and not just scripts and 
having the ability to define the packages will be very useful especially when 
we will have more services implemented in Groovy.
Again, I think they should go into src/main/groovy or src/test/groovy.


(Yes, the Service Engine supports JavaScript.)

To use FooScript_1.groovy you can use two methods:

1. The  "component://" URL feature:

component://mycomponent/script/groovy/FooScript_1.groovy

2. The classpath:

groovy/FooScript_1.groovy

Option 2 could have problems with name clash, so I have always preferred option 
1.

While we are having this discussion, we could also consider changing the 
package naming from

org.ofbiz.*

to

org.apache.ofbiz.*

+1!!!

Jacopo



Adrian Crum
Sandglass Software
www.sandglass-software.com

On 1/20/2015 3:41 AM, Jacopo Cappellato wrote:
In my opinion it would be nice to review how we organize the code in our 
components and switch to a directory layout that is more inline with what other 
projects are doing, for example:

http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html

More specifically I would like to switch from, for example:

script/org/ofbiz/product/
src/org/ofbiz/product/
src/org/ofbiz/product/test/

to:

src/main/java/org/ofbiz/product/
src/main/minilang/org/ofbiz/product/
src/main/groovy/...
src/test/java/org/ofbiz/product/

What do you think?

Jacopo


Reply via email to