Is there a good way to mavenify a play! framework application?

后端 未结 4 1223
野性不改
野性不改 2020-12-31 09:20

I am using play as web app framework and I love it, but I would like to know if there is a good way to declare the pom for a play! app ?

As the sources files are mea

4条回答
  •  情话喂你
    2020-12-31 10:21

    An updated answer to this question as play install does not work with Play 2

    I just had to mavenify a Play 2 application.

    To do this, I used play2-maven-plugin and sbt-pom-reader.

    I used sbt-pom-reader to keep the hot reloading feature which is not supported by play2-maven-plugin yet.

    This is how you need to configure your play2-maven project:

    /
      pom.xml                  <- Your maven build
      build.sbt                <- the sbt Play 2 configuration
      project/
         build.properties      <- the sbt version specification
         build.scala           <- the sbt build definition
         plugins.sbt           <- the sbt plugin configuration
    
      ..                       <- Whatever files are normally in your maven project.
    

    Each of the files should have the following contents.

    pom.xml:

    
    
        4.0.0
        org.foo
        bar
        0.0.1-SNAPSHOT
        play2
        My mavenified Play 2 application
        
            UTF-8
            UTF-8
            2.2.1
            2.10
            1.0.0-alpha5
            2.10.2
        
        
            
                typesafe
                Typesafe - releases
                http://repo.typesafe.com/typesafe/releases/
                
                    false
                
            
        
        
            
                org.scala-lang
                scala-library
                ${scala.version}
            
            
                com.typesafe.play
                play_${play2-scala.version}
                ${play2.version}
            
            
            
                com.typesafe.play
                play-java_${play2-scala.version}
                ${play2.version}
            
        
        
            ${basedir}/app
            
                
                    ${basedir}/conf
                
                
                    ${basedir}
                    
                        public/**
                    
                
            
            
            
                
                    com.google.code.play2-maven-plugin
                    play2-maven-plugin
                    ${play2.plugin.version}
                    true
                    
                        
                            com.google.code.play2-maven-plugin
                            play2-provider-play22
                            ${play2.plugin.version}
                        
                    
                    
                    
                        java
                    
                
            
        
    
    

    build.sbt:

    play.Project.playJavaSettings //or play.Project.playScalaSettings
    

    project/build.properties:

    sbt.version=0.13.0
    

    project/build.scala:

    object BuildFromMavenPomSettings extends com.typesafe.sbt.pom.PomBuild
    

    project/plugins.sbt:

    addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.1")
    
    addSbtPlugin("com.typesafe.sbt" % "sbt-pom-reader" % "1.0.1")
    

    Now you can use Maven for builds and SBT for development with hot reload.

提交回复
热议问题