1
votes

Background: I am in the process of integrating TypeScript into a Play Framework (2.2.6) and I am trying to use mumoshu's plugin to do so. Problem is, the plugin has problems when running "play dist" on a windows machine. I've forked the code from GitHub in order to make some modifications to the source so I can continue using the plugin.

Question: I have a play framework plugin in the traditional source structure:

project/build.properties
project/Build.scala
project/plugins.sbt
src/main/scala/TypeScriptPlugin
src/main/scala/TypeScriptKeys.scala
...<other code>

I'd like to include this plugin into another project but I don't really know where to start and how to hookup the settings.

From previous suggestions, I've been able to add the module to my project as follows:

// In project/Build.scala...
object ApplicationBuild extends Build{
    lazy val typeScriptModule = ProjectRef(file("../../../play2-typescript"), "play2-typescript")

    lazy val main = play.Project(<appName>, <appVersion>, <appDependencies>).settings(typescriptSettings: _*).dependsOn(typeScriptModule).aggregate(typeScriptModule)
}

Where typescriptSettings is defined in the other project... I think, I'm still not 100% sure what typescriptSettings IS other than adding this settings call enabled the plugin to work. This worked fine originally when I had included the plugin in the plugins.sbt file and imported the package com.github.mumoshu.play2.typescript.TypeScriptPlugin._ but now that I'm including the source and explicitly including the module, I can't just import the package... Or at least not the way I used to.

I am still new to scala/sbt and I am having difficulty finding helpful resources online. Any help would be appreciated.

2

2 Answers

0
votes

There a lots of activator template examples of this. I have a project where we followed the https://typesafe.com/activator/template/play-multidomain-auth path. Specifically, to address your question; the plugins in the root project play-multidomain-auth/project/ are accessible in the modules (play-multidomain-auth/modules/admin/, .../common, and .../web).

This example is the cleanest example I've seen in using multi-project design however that opinion is very subjective.

I hope this helps.

0
votes

Assuming in the same parent directory you have two directories:

  • play2-typescript: which is a clone of mumoshu's play2-typescript
  • play2-typescript-testapp: which is the play app in which you're testing your changes

You need to create, inside play2-typescript-testapp's project directory a file like so:

play2-typescript.sbt

val metaBuild = (project in file(".")
  dependsOn ProjectRef(file("../../play2-typescript"), "play2-typescript")
)

Note:

The relative path is to the play2-typescript plugin project, and is relative to the project directory inside play2-typescript-testapp.

Change that to what is correct in your setup, and consider that you can also define it as an absolute path.