Add java.math.BigDecimal in Lift project managed by sbt

76 views
Skip to first unread message

Anton Andriyevskyy

unread,
Jul 23, 2011, 11:18:00 AM7/23/11
to lif...@googlegroups.com
What is the correct way to import java.math.BigDecimal?

When in my .scala file I write:
import java.math.BigDecimal
...it does not recognize such namespace (IntelliJ IDEA 10.5.1)


Also, my project is managed by sbt and edited in IntelliJ IDEA 10.5.1 - must I add some package to the project first?
And whether it must be done with sbt or in IDE?

Thanks,
Anton

Tyler Weir

unread,
Jul 23, 2011, 12:53:57 PM7/23/11
to lif...@googlegroups.com
Just because IDEA does not recognize it, it does not mean it's incorrect.

I bet it compiles.  And I just tried it without issue.

In these early days, one must still second guess IDEs.

Andreas Joseph Krogh

unread,
Jul 23, 2011, 1:16:19 PM7/23/11
to lif...@googlegroups.com
I use IDEA-10.5.1 with scala-plugin 0.4.1230 and IDEA recognises it just fine. I use Maven.

Could you be more specific about what you mean by "recognise"?
-- 
Andreas Joseph Krogh <and...@officenet.no>
Senior Software Developer / CTO
Public key: http://home.officenet.no/~andreak/public_key.asc
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Rosenholmveien 25       | know how to do a thing and to watch         |
1414 Trollåsen          | somebody else doing it wrong, without       |
NORWAY                  | comment.                                    |
Org.nr: NO 981 479 076  |                                             |
                        |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+

Todd O'Bryan

unread,
Jul 23, 2011, 1:17:32 PM7/23/11
to lif...@googlegroups.com
IDEA does this to me quite a bit. Go under File->Project Structure,
click the Project choice in the list and either Edit your JSDK or
create a New one that points to the directory where your Java SDK is.
(The SDK was probably in red before you did that, at least if you're
having the same problem I seem to have.)

I have to do this when the SDK gets updated (and thus moved) or when I
git clean the project and re-create the IDEA files.

By the way, if you use SBT 0.10.x, the command to re-create the IDEA
files is a simple gen-idea and that usually finds any new dependencies
I've added. I also remember that setting up the IDEA plugin for 0.10.x
was as simple as adding a line to the project/plugins/build.sbt file.

Todd

> --
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/liftweb/-/qCFEiqpKCkkJ.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to
> liftweb+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>

Anton Andriyevskyy

unread,
Jul 23, 2011, 2:15:48 PM7/23/11
to lif...@googlegroups.com
Todd, what you proposed with creating a new JSDK worked well, thanks.
And yes, it was red in my IDE configuration in "project" tab.

Because I'm newbie with java and build tools, I would like to ask some more questions:

1. What we have done is just changed configuration for IDEA, but we are building and running with SBT,
does this mean that there is another configuration in SBT config files somewhere that tells to SBT about this dependency?

2. I have used latest lift_basic example, and it looks like it contains sbt < 0.1
Will it be simple and useful to upgrade to 0.1?
Can you describe how to do it, please?

3. Also, you mentioned about versioning with git.
From what I understand .idea folder is ignored by git,
so anyone cloning my project to its local machine will require him to configure JSDK,
and theoretically it's possible that each developer will setup its own version of JSDK.
If it's true, then I do not understand which one will be used when building with SBT tool.

Alternatively, maybe this dependency (eg, version of JSDK) can be set somewhere in SBT,
maybe build.properties file or something like this,
an then the IDEA-lization plugin will scrape this configuration and make .idea project aware about it?

I'm confused on how all this works.

P.S. My current build.properties file:

#Project properties
project.organization=Betbot
sbt.version=0.7.5
project.version=0.1
def.scala.version=2.7.7
build.scala.versions=2.9.0-1
project.initialize=false
lift.version=2.4-M3

Thanks,
Anton

Anton Andriyevskyy

unread,
Jul 23, 2011, 2:19:37 PM7/23/11
to lif...@googlegroups.com
andreak:

>> Could you be more specific about what you mean by "recognise"?

By this I mean that there is no "dropdown hint" when I'm trying to write:
import java.<something>
"java" gets highlighted with red color.

P.S. I'm trying to import RoundingMode and to use Java's rounding methods:
... I have not found such wrappers in Scala, but I need them because I'm dealing with gambling odds (prices),
and I need rounding up and down and sometimes even to some specific increment  (like round to 0.02 increment).

Todd O'Bryan

unread,
Jul 23, 2011, 3:02:51 PM7/23/11
to lif...@googlegroups.com
On Sat, Jul 23, 2011 at 2:15 PM, Anton Andriyevskyy <x.me...@gmail.com> wrote:
> Todd, what you proposed with creating a new JSDK worked well, thanks.
> And yes, it was red in my IDE configuration in "project" tab.
> Because I'm newbie with java and build tools, I would like to ask some more
> questions:
> 1. What we have done is just changed configuration for IDEA, but we are
> building and running with SBT,
> does this mean that there is another configuration in SBT config files
> somewhere that tells to SBT about this dependency?

I'm not sure, either. I think that SBT is smarter about finding the
Java home directory than IDEA is, which is why you can type > compile
at the SBT prompt and have things work fine, even when IDEA can't find
the Java home directory. Unless you have a bunch of JDKs in your
filesystem, you shouldn't have to worry about SBT and IDEA checking
your code against different versions, but I suppose that's
theoretically possible and could drive you batty.

> 2. I have used latest lift_basic example, and it looks like it contains sbt
> < 0.1
> Will it be simple and useful to upgrade to 0.1?
> Can you describe how to do it, please?

It took me a few hours of fiddling, but it's not horrible.
Instructions are here:

https://github.com/harrah/xsbt/wiki/Migrating-from-SBT-0.7.x-to-0.10.x

I don't know whether it's worth it or not, but I like the idea that
projects share dependencies rather than all having a copy in
lib-managed. You do need to add the web and idea plugins:

https://github.com/siasia/xsbt-web-plugin
https://github.com/mpeltonen/sbt-idea/tree/sbt-0.10

> 3. Also, you mentioned about versioning with git.
> From what I understand .idea folder is ignored by git,
> so anyone cloning my project to its local machine will require him to
> configure JSDK,
> and theoretically it's possible that each developer will setup its own
> version of JSDK.
> If it's true, then I do not understand which one will be used when building
> with SBT tool.
> Alternatively, maybe this dependency (eg, version of JSDK) can be set
> somewhere in SBT,
> maybe build.properties file or something like this,
> an then the IDEA-lization plugin will scrape this configuration and make
> .idea project aware about it?
> I'm confused on how all this works.

I can't help you much, since I'm just as confused. My only advice
would be to make sure that everybody is using the same major Java
version. There may be a setting for the Java version in SBT as there
is for the Scala version, but I haven't come across it.

Todd

Reply all
Reply to author
Forward
0 new messages