cescoffier / maven-play2-plugin

A Maven Plugin to build Play2 applications
Apache License 2.0
49 stars 41 forks source link

The Build.scala and Maven POM should be kept in sync #16

Closed cescoffier closed 12 years ago

cescoffier commented 12 years ago

This issue is actually a metadata syncing issue between Maven and SBT. If you change the version in the Maven build, it's not mirrored in the Build.scala file.

So for example, if the Maven version is 1.0.0-SNAPSHOT and the SBT version is empty (""), you get a weird zip file:

The distribution use the following basedir:

my-app-

Such as in

creating: my-app-/
creating: my-app-/lib/
inflating: my-app-/lib/commons-image-io-0.4.0.jar  

So, we should try to keep those metadata synced.

cescoffier commented 12 years ago

Fixed in master.

anttipoi commented 12 years ago

Would it make sense to extend this to project properties?

If I have a multi-project maven build with a play project as a sub-project, I'll likely set up common dependency versions as properties in a root pom. Then every project can rely on the properties to keep dependency versions in sync.

If maven-play-plugin would expose

via environment variables (for example) the play SBT build specification could pick properties from its environment. There would be no need for the build file rewriting step, which has a hacky feel to it.

Commons-exec supports setting up environment for the invoked command line, it seems.

cescoffier commented 12 years ago

Hi,

That would be really good. Do you know how I can transfer such properties in SBT ? I've tried with: val appName = ${appName} and play dist -DappName="myApp", but it didn't work.

anttipoi commented 12 years ago

java.lang.System.getenv(), I think.

cescoffier commented 12 years ago

I'm more worried by the SBT side, how to you indicates to SBT the variables to replace. In our case, what can I write in the Build.scala to replace the appName by the value given as environment variable ?

2012/5/16 Teemu Antti-Poika < reply@reply.github.com

java.lang.System.getenv(), I think.


Reply to this email directly or view it on GitHub:

https://github.com/cescoffier/maven-play2-plugin/issues/16#issuecomment-5740295

anttipoi commented 12 years ago

I was thinking along these lines:

def fromEnv(name: String) = System.getenv(name) match {
  case null => None
  case value => Some(value)
}
val appName = fromEnv("APP_NAME").getOrElse("my-appt")
val appVersion = fromEnv("APP_VERSION").getOrElse("1.0-SNAPSHOT")
cescoffier commented 12 years ago

Ok, I agree it's a much better solution.

So several things:

anttipoi commented 12 years ago

I don't think there's much need to force that build file on all users or to touch users' build files at all.

If the values are offered as env variables, anyone can choose to use them (as above, that could be offered as an example) and get values from pom to sbt build; or not, in which case pom and build files are not synched?

cescoffier commented 12 years ago

So, that would mean disabling the current sync completely, and let the user write the SBT code he wants ?

anttipoi commented 12 years ago

That's what I was thinking.

cescoffier commented 12 years ago

Ok, I will modify the code to follow this. We will need to be really clear in the documentation.

cescoffier commented 12 years ago

Re-open issue to implement the new behavior

cescoffier commented 12 years ago

The proposed way is now implemented.