Adding additional java files to playframework clas

2019-06-24 07:27发布

I have a project that shares models with my android project. I have a separate eclipse project just for models and other shared code. I add this to my play project as a dependency in eclipse.

In eclipse, play compiles and starts without problem. However, I went to deploy to GAE and found that the compilation stage of play's packaging fails because it can't find the models.

I suspect I could hack the ant build files, but that seems brittle.

Is there a standard way to add extra directories to the play compilation source tree or the classpath?

2条回答
女痞
2楼-- · 2019-06-24 07:50

Make a jar-file with your classes and put it in /lib. That's where I put my libraries.

Files in the application /lib folder is automatically added to the class path by Play Framework. See Classpath settings

查看更多
We Are One
3楼-- · 2019-06-24 07:51

From Anatomy: "The app directory contains all executable artifacts: Java and Scala source code, templates and compiled assets’ sources" ... and further: "You can of course add your own packages, for example an app/utils package"

You can copy java source files to make a hierarchy of packages under /app, e.g.: /app/sharedcode/project2/models/domain1 and import that in WhateverController.scala as:

import sharedcode.project2.models.domain1._
查看更多
登录 后发表回答