wouterhardeman / play2-maven-plugin

Automatically exported from code.google.com/p/play2-maven-plugin
0 stars 0 forks source link

Allow usage of Maven directory structure #22

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Change sourceDirectory or resource/directory to anything but app/conf
2. Clean & compile

What is the expected output? What do you see instead?
Play2 templates and routes are not compiled. I would expect this to work =)

A short look into the source code would suggest that making a parameter out of 
both appDirectoryName and confDirectoryName in the CompileMojos should be 
enough to make that work. If it is just that, I could provide a patch.

Cheers,
Michael

Original issue reported on code.google.com by michael....@googlemail.com on 8 Jan 2014 at 2:29

GoogleCodeExporter commented 8 years ago
You are right, "app" and "conf" directory names are hardcoded now.

1. Templates

There is one source root directory in Maven project 
(project/build/sourceDirectory) but more can be added at runtime (using 
"build-helper-maven-plugin" for example)
In Play(SBT) project there is a sequence of source root directories named 
"unmanagedSourceDirectories".
So Maven and SBT have similar configurations.
Play! templates compiler searches template files in all 
"unmanagedSourceDirectories".

"PlaySettings.scala" fragment:

    sourceGenerators in Compile <+= (state, unmanagedSourceDirectories in Compile, sourceManaged in Compile, templatesTypes, templatesImport) map ScalaTemplates,

2. Routes

Play! routes compiler works differently. It does not search routes files in all 
resources root directories ("unmanagedResourceDirectories" setting). There is 
"confDirectory" setting in "PlaySettings.scala". It's single directory, not a 
sequence of directories.

"PlaySettings.scala" fragment:

    confDirectory <<= baseDirectory / "conf",

    sourceGenerators in Compile <+= (state, confDirectory, sourceManaged in Compile, routesImport, generateReverseRouter, namespaceReverseRouter) map { (s, cd, sm, ri, grr, nrr) =>
      RouteFiles(s, Seq(cd), sm, ri, grr, nrr)
    },

In Maven plugin I will not search routes files in all resource directories. I 
will add "confDirectory" plugin configuration parameter (pointing to "conf" 
directory by default) and will use this parameter.

3. Assets

"PlaySettings.scala" fragment:

    sourceDirectory in Compile <<= baseDirectory / "app",

    lessEntryPoints <<= (sourceDirectory in Compile)(base => ((base / "assets" ** "*.less") --- base / "assets" ** "_*")),
    coffeescriptEntryPoints <<= (sourceDirectory in Compile)(base => base / "assets" ** "*.coffee"),
    javascriptEntryPoints <<= (sourceDirectory in Compile)(base => ((base / "assets" ** "*.js") --- (base / "assets" ** "_*"))),

"sourceDirectory" key is different from "unmanagedSourceDirectories". Default 
SBT value for "sourceDirectory in Compile" is baseDirectory / "src/main". It's 
overridden in Play! and points to baseDirectory / "app". This is the same 
location as for source files, but technically this is different setting.
How should I parametrize it in Maven?
For example, if you want sources to be located in "src/main/java" and 
"src/main/scala" (as is in SBT by default), where would you expect assets? In 
"src/main/java/assets" and "src/main/scala/assets" ("assets" subdirectories of 
source roots) or in "src/main/assets" (location outside of source roots)?
The simplest solution would be adding "sourceDirectory" plugin configuration 
parameter, but I don't like it. I must think about it. And what do you think?

Original comment by gslowiko...@gmail.com on 9 Jan 2014 at 8:39

GoogleCodeExporter commented 8 years ago
1. (templates compilation) implemented in 
http://code.google.com/p/play2-maven-plugin/source/detail?r=369

Original comment by gslowiko...@gmail.com on 3 Apr 2014 at 1:41

GoogleCodeExporter commented 8 years ago
https://code.google.com/p/play2-maven-plugin/source/detail?r=588 - "conf" 
directory location parametrized.

Original comment by gslowiko...@gmail.com on 31 May 2014 at 6:33

GoogleCodeExporter commented 8 years ago
https://code.google.com/p/play2-maven-plugin/source/detail?r=589 - assets 
directory location parametrized.

Original comment by gslowiko...@gmail.com on 31 May 2014 at 6:44

GoogleCodeExporter commented 8 years ago
New 1.0.0-alpha7-SNAPSHOT snapshot deployed.

Original comment by gslowiko...@gmail.com on 31 May 2014 at 7:06