How do I reference play framework third party modules without referencing an absolute path? - module

Here is my situation. I have a play app which uses the guice module. In order to work with the guice module:
I installed it using play install guice. This installs it in the $PLAY_HOME/modules which is fine by me. I don't want to edit the module files in any way whatsoever.
Then I declared the module in my dependencies.yml like so: - play -> guice 1.2
Within my app, I ran play dependencies, and this resoles the module just fine and creates a modules/guice-1.2 file that references the guice module.
The issue is that the content of that file is something like the following: /some-absolute-path/play-1.2.x/modules/guice-1.2.
That works fine when working locally for development. But when I want to move to a production server, with a different install of Play! (i.e. with a different absolute path to it) it will obviously fail.
So what's the best way to deal with this?
For now I've resorted to declaring the module in the application.conf file like this: module.guice=${play.path}/modules/guice-1.2.
Unfortunately the ${play.path} magic doesn't seem to work on those generated files.
By the way I use version 1.2.3 of Play!

you should try with ${application.path} in your dependencies.yml file, like in this example
require:
- play -> crud
- provided -> DateHelper 1.0
repositories:
- provided:
type: local
artifact: "${application.path}/jar/[module]-[revision].jar"
contains:
- provided -> *
see this question: How can I specify a local jar file as a dependency in Play! Framework 1.x

When you run in production you will either resync the dependencies (via play deps command) with the local installation of Play or in some scenarios you can precompile everything and then there will be no issues with the paths.
That second scenario is the one with Heroku, for example.

It's not answer to your question, but I have faced with same issue.
I don't want to call resync the dependencies on production.
I don't want to ask my team members, install special module.
I don't want to commit file containing absolute path with module location.
The only workaround that I find: do not install module in Play! application, just include jars which use this module manually. play-guice.jar should be included as #opensas suggested, aopalliance and com.google.inject as regular dependencies in dependencies.yml.
The funny thing, that resync dependencies is also deleting .svn files, so back-up its before calling this command.

Related

Include git information on parceljs build

I have a TypeScript/React web app that uses ParcelJS and I would like to have either a step in the build or a simple way of using a resource file that holds git information.
Not sure if there is something that can generate the git information during the build, I'm using npm to launch parcel.
If parcel can load a resource file and make it accessible that could also work by having properties.
My end goal would be to display version and git commit point in the webapp.
I'm going to assume you're using parcel2 (I'm not sure this would be possible in parcel1).
Parcel2 uses babel to transpile typescript by default (through the #parcel/transformer-babel plugin). The babel configuration for this plugin can be over-ridden by simply including a .babelrc (for configuration relevant to only a subset of the project) or babel.config.json file (for configuration that will apply to the entire project). See this scenario matrix that I made in the process of fixing this bug for details about exactly what babel config files should be picked up by parcel. (The "proposed fixes" are merged into parcel2 as of the latest nightly release).
With the ability to supply your own babel configuration, you should be able to use this babel plugin to inject git repository information into your code.
(Since you're using typescript, you'll also need to make sure to include #babel/preset-typescript or #babel/plugin-transform-typescript in your babel config as well).

Play 2 dependency on a local module in Intellij Idea

I am kind of new to PlayFramework 2 and can not figure out how to resolve play 2 application dependencies. I need to add dependency on a local module loaded in IntellijIdea, not a jar file or repository.
While adding module dependencies in Idea project setting works just fine and ide itself is able to resolve them (autocompletion, imports etc are working), when trying to run in play2, its compiler cannot resolve any dependencies.
I manually configured Build.scala (adding val appDependencies = Seq("" % "" % "")) but am puzzled as to what resolvers I should use. I cannot point to a jar file, as it is a work in progress and such a file should be updated too often. Doing so would defeat the whole purpose of managed dependencies.
Play's main build mechanism uses SBT, which needs to know how to find all sources required for the build. There are several options for this:
make your module an SBT project itself and publish it to your local ivy repository. However that might be somewhat complex at this stage, and would involve adding your local ivy repository to the resolvers and re-publishing every time you change something in the module
declare your module as a sub-project. Play's documentation describes the process of working with sub-projects, I think this is the way you'd like to try out since then the idea command on Play's console will generate the IntelliJ configuration for the main application and the module.

How can I get Eclipse to use my IVY_HOME variable when downloading ivy dependencies?

My company uses extensive use of ivy to download dependencies. Some of these dependencies are huge (~500MB) and take a while to download from the remote repositories.
To build our application we have an ant script that will first resolve all the dependencies and the deploy to the server.
I have set an "IVY_HOME" environment variable so that all the dependencies are downloaded to D:\ivy_home instead of C:\Users\.ivy2\ - this is because D: is my SSD which is significantly faster, and it is where my local server directories are located - so copying files from ivy_home to the server is super fast.
But for some reason when I am using IvyDE plugin inside eclipse - it always wants to download a separate copy of all the dependencies and puts them into my C:\ which is causing several issues:
Local publishes from the ant script will not be picked up in eclipse since they are placed into a different location
Dependencies already downloaded in D: will not get picked up which makes the ivy Resolve inside eclipse much slower than it needs to be
The dependencies are in a slower drive in eclipse so performing searches, and executing these jars is also slower
How about creating symlink to replace the .ivy2 in Users to D? I've tried it on my own and it's looks working fine.
Open cmd as root, and then execute this line
mklink /d C:\Users\{username}\.ivy2 D:\.ivy2
I'd create an ivysettings.xml file and specify the location of my cache using the caches directive. See the following answer for example:
can I turn off the .ivy cache all together?
Why don't you set up IVY globally with the ivysettings.xml along with a property file.
This property file could have this:
ivy.default.ivy.user.dir=D:\ivy_home
For individual projects you could uncheck "enable project specific settings" for each IvyDE library management, so they would use IVY global settings, with one extra eclipse environment configuration.

How do I configure the SpringSource OBR in Eclipse?

If I understand it properly, SpringSource has a public OBR which contains OSGi bundles for many third party jars. I would like to use it in Eclipse, but I can't get Eclipse to connect to it.
I have tried:
http://ebr.springsource.com
It hangs there for ages, and returns as error:
Error reading update site http://ebr.springsource.com.
The XML stream is not a valid default "site.xml" file.
The root tag is not site.
And I have tried:
http://ebr.springsource.com/repository
Which returns quickly as error:
No repository found at http://ebr.springsource.com/repository.
So, what URL am I meant to use?
[EDIT] Made some research after getting my first answer. I found this site which claims to have a list of public OBR repositories:
OSGi Bundle Repository:
http://www.osgi.org/obr/browse?cmd=repository&_xml=1
Spring Enterprise Bundle Repository:
http://sigil.codecauldron.org/spring-external.obr
http://sigil.codecauldron.org/spring-release.obr
But none of them work with Eclipse either. I'm just more confused now.
What I (think I) understand is:
1) SpringSource EBR is a Repository of OSGi Bundles, without being a "OSGi Bundle Repository". This makes no sense to me. What's the point?
2) An "OSGi Bundle Repository" is just a XML file that defines the configuration of a Repository of OSGi Bundles.
So, If I give http://sigil.codecauldron.org/spring-external.obr to Eclipse, instead of http://ebr.springsource.com, I would expect Eclipse to use the content of that file to access http://ebr.springsource.com, but it doesn't work either.
So which one of the possible reason is it:
1) http://sigil.codecauldron.org/spring-external.obr is outdated or wrong
2) http://sigil.codecauldron.org/spring-external.obr is not compatible with Eclipse (apparently, it works with Apache Felix)
3) An "Eclipse Update Site" is NOT an OBR (and neither is it a Maven Repository), although it should also contain OSGi bundles. If that is the case, then it wouldn't make much sense either, since Eclipse is OSGi-based.
SpringSource EBR is not an Eclipse Update Site, so it cannot be used this way. It is also not an OBR, at least currently. But Eclipse PDE doesn't use OBR anyway (though Bndtools does).
You can use it as a Maven repository, I think.

IntelliJ IDEA and PlayFramework modules

After a lot of good comment about IDEA, I decided to give it a try. I downloaded the Community Edition and would like to use it for PlayFramework development.
I have followed official documentation and some other information gathered around, but I have not succeeded completely. When using a project with differents (play) modules, the different classes are not found.
For example when using Secure module, IDEA keeps complaining about not finding Secure.class. It has to be a classpath issue. I tried to attach Java source & classes ($PLAY/modules/secure/) in module settings (F4), class is still not found. Did I miss something?
BTW, I have done a play dependencies and play idealize, which seems to add another module Secure into project in IDEA.
Thanks,
The answer is to run the following:
play deps
play idealize
This forces the IDEA .iml project file to be refreshed with the updated class path entries for the new module (in this case Secure).
A issue I came across using IntelliJ and Playframework.
The log4j.properties file or log4j.xml file are not in classpath by default. You have to add the conf as a source folder in module settings.
You need to add the Secure module you have created in IDEA as a dependency to the main application module:
Go to File -> Project Structure
Choose the main module
Choose the Dependencies tab
Click Add -> Module Dependency
Choose the IDEA Module you created for the Play Secure module
Also make sure you have the correct source path selected for the Secure module in IDEA.