wouterhardeman / play2-maven-plugin

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

How do you specify SubProjects #31

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
http://www.playframework.com/documentation/2.2.x/SBTSubProjects

Specifically when you have a subproject under the directory structure and you 
want to share it's Routes.

Currently, if I follow the example on the play website and add admin.Routes 
even if I add <artifactId>admin</> in my pom and include it as a dependency it 
will not pick it up with the following error:

not found: value admin
[ERROR]   List[(String,Routes)](("admin",admin.Routes)

Part Build.scala:
lazy val admin = sbt.Project(
    id = "admin",
    base = file("modules/admin-webui-service")).settings(
      version := appVersion,
      libraryDependencies ++= adminDeps).settings(javaSettings: _*)

...
val main = play.Project(...).dependsOn(
      admin
  ).aggregate(
      admin
  )

How to get the equivalent to work? Thanks.

Original issue reported on code.google.com by lramo...@gmail.com on 2 May 2014 at 12:07

GoogleCodeExporter commented 8 years ago
Nevermind, works now, I had <packaging>jar</> instead of play2.

Original comment by lramo...@gmail.com on 2 May 2014 at 1:00

GoogleCodeExporter commented 8 years ago
OK, here are my test projects for reference:

https://play2-maven-plugin.googlecode.com/svn/tags/test-projects-1.0.0-alpha6/pl
ay21/multimodule
https://play2-maven-plugin.googlecode.com/svn/tags/test-projects-1.0.0-alpha6/pl
ay22/multimodule

Original comment by gslowiko...@gmail.com on 2 May 2014 at 7:30

GoogleCodeExporter commented 8 years ago
I tried creating a play2 module (minus the routes file) using the 
play22/multimodule example that correctly compiles but when running install to 
the local m2 repo the resulting pom has play2 packaging but a jar is produced 
such that when adding the submodule as a dependency in another play2 project 
the resolution fails since a play2 extension is not created. While I can 
manually update the generated pom in the local m2 repo and change the packaging 
to be jar to get the resolution to succeed it seems like I am missing a setting 
that should do this for me.

Original comment by eric.phe...@gmail.com on 4 May 2014 at 12:26

GoogleCodeExporter commented 8 years ago
"play2" packaging produces "jar" file (file extension is not equal to 
packaging). When resolving "play2" dependency Maven searches file with "jar" 
extension, not "play2".

One thing is required for this mechanism to work - 
"<extensions>true</extensions>" in plugin definition.

What is not working for you? My original test project or your project? I need 
more details. Can you attach your project and Maven execution log (run Maven 
with -X flag), or at least a log if you cannot publish your project?

Original comment by gslowiko...@gmail.com on 4 May 2014 at 7:58

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I didn't author it but I an using the project 
https://github.com/orrsella/play-maven-integration for testing this plugin. 
When running mvn clean install from the project I see:

[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ my-application-play ---
[INFO] Building jar: 
/Users/epheatt/dev/play-maven-integration/my-application-play/target/my-applicat
ion-play-1.0.0-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.5.1:install (default-install) @ 
my-application-play ---
[INFO] Installing 
/Users/epheatt/dev/play-maven-integration/my-application-play/target/my-applicat
ion-play-1.0.0-SNAPSHOT.jar to 
/Users/epheatt/.m2/repository/com/example/my-application-play/1.0.0-SNAPSHOT/my-
application-play-1.0.0-SNAPSHOT.jar
[INFO] Installing 
/Users/epheatt/dev/play-maven-integration/my-application-play/pom.xml to 
/Users/epheatt/.m2/repository/com/example/my-application-play/1.0.0-SNAPSHOT/my-
application-play-1.0.0-SNAPSHOT.pom

When I add this to my other play project that I am trying to use this 
application as a module dependency and run play clean compile, I see:

[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn]  [FAILED     ] 
com.example#my-application-play;1.0.0-SNAPSHOT!my-application-play.play2:  (0ms)
[warn] ==== local: tried
[warn]   
/Users/epheatt/dev/play-2.2.1/repository/local/com.example/my-application-play/1
.0.0-SNAPSHOT/play2s/my-application-play.play2
[warn] ==== Local Maven Repository: tried
[warn]   
file:///Users/epheatt/.m2/repository/com/example/my-application-play/1.0.0-SNAPS
HOT/my-application-play-1.0.0-SNAPSHOT.play2
[warn] ==== Typesafe Releases Repository: tried
[warn]   
http://repo.typesafe.com/typesafe/releases/com/example/my-application-play/1.0.0
-SNAPSHOT/my-application-play-1.0.0-SNAPSHOT.play2
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::              FAILED DOWNLOADS            ::
[warn]  :: ^ see resolution messages for details  ^ ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: 
com.example#my-application-play;1.0.0-SNAPSHOT!my-application-play.play2
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
sbt.ResolveException: download failed: 
com.example#my-application-play;1.0.0-SNAPSHOT!my-application-play.play2

So I can see that the pom is found in the local m2 repository but because of 
the packaging specified in the pom the error is thrown due to the extension 
difference. I've attached the logs from the install in the com.example project 
and compile from my other project.

Original comment by eric.phe...@gmail.com on 5 May 2014 at 4:30

Attachments:

GoogleCodeExporter commented 8 years ago
play-maven-integration's way of Maven and SBT "cooperation" is tricky IMO, but 
quite interesting.
Unfortunately it didn't work for me on Windows.

I've installed Maven module, used it as a dependency in pure SBT project, and I 
got the same error. This means it's a problem in SBT (or Ivy). It expects file 
extension to be the same as the packaging inside pom.xml file.

There is a workaround, but first I don't know if you have multi-module build at 
all (as shown in play-maven-integration example). I see two different paths in 
your logs.
Your problem is interesting, you should have created separate issue, but it's 
to late now.

The workaround is changing packaging from "play2" to "jar".

change:

...
    <packaging>play2</packaging>
...
            <plugin>
                <groupId>com.google.code.play2-maven-plugin</groupId>
                <artifactId>play2-maven-plugin</artifactId>
                <extensions>true</extensions>
            </plugin>
...

to

...
    <packaging>jar</packaging>
...
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <skipMain>true</skipMain> <!-- skip compile -->
                    <skip>true</skip> <!-- skip testCompile -->
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.google.code.sbt-compiler-maven-plugin</groupId>
                <artifactId>sbt-compiler-maven-plugin</artifactId>
                <version>${sbt-compiler.plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.google.code.play2-maven-plugin</groupId>
                <artifactId>play2-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>routes-compile</goal>
                            <goal>template-compile</goal>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
...

It's verbose, but it works for me.

I will ask SBT team if there is a way to make it work without this change.

Original comment by gslowiko...@gmail.com on 6 May 2014 at 7:13

GoogleCodeExporter commented 8 years ago
That fixed it. Thanks!

Original comment by eric.phe...@gmail.com on 7 May 2014 at 4:48

GoogleCodeExporter commented 8 years ago
I found much better solution.

Use "play2" packaging in Maven, but in SBT add to "build.sbt" this:

// If your Maven artifact is not deployed, only installed in local Maven 
repository
resolvers += "Local Maven Repository" at Path.userHome.asFile.toURI.toURL + 
".m2/repository"

classpathTypes += "play2"

libraryDependencies +=
  "com.example" % "my-application-play" % "1.0.0-SNAPSHOT" artifacts( Artifact("my-application-play", "jar", "jar") )

Original comment by gslowiko...@gmail.com on 15 May 2014 at 9:18