I have a multi module sbt/Scala project, and I want to write a maven plugin that depends on the scala code.
For the moment, I have the plugin in a separate project, using maven (maven-plugin packaging, and deps on the scala code). I therefore have 2 projects : one sbt and one maven. So I need to build (and publishM2) the sbt one and then build the other with maven.
Can the maven plugin be aggregated into the sbt build, so that I have only one multi-module project ?
Do I need to keep the pom.xml and "invoke" it from sbt ?
Can I build the mvn plugin directly in sbt (what about the packaging "maven-plugin" then) ?
Related
I'm trying to use the alfresco-pdf-toolkit addon in my Alfresco Maven project, is there anyway to include the amp in the pom.xml file of my project?
Yes, assuming your project uses the all-in-one archetype of the Alfresco Maven SDK, you can add an AMP dependency as an overlay.
Go look in the repo pom.xml for an example. You'll see something like:
<overlay>
<groupId>${alfresco.groupId}</groupId>
<artifactId>alfresco-spp</artifactId>
<type>amp</type>
</overlay>
Which is how the all-in-one project brings in the SPP dependency. You can add additional AMPs below that.
You must have already run "mvn install" for the AMPs you are depending on so that they are installed in your local Maven repo, or they must be available in some other maven repo that your build knows about.
I pulled down the sources and build/published it locally. I want to debug into sources jars. When I publish it locally, I clearly see it also publishes source jars.
[info] published securesocial-testkit_2.10 to local\ws.securesocial\securesocial-testkit_2.10\master-SNAPSHOT\srcs\securesocial-testkit_2.10-sources.jar
I don't know how to reference this jar.
Changing "ws.securesocial" %% "securesocial" % "master-SNAPSHOT" to "ws.securesocial" %% "securesocial" % "master-SNAPSHOT-sources" doesn't work.
Add withSources() to the dependency definition.
From Download Sources in the official documentation of sbt:
Downloading source and API documentation jars is usually handled by an
IDE plugin. These plugins use the updateClassifiers and
updateSbtClassifiers tasks, which produce an Update Report referencing
these jars.
To have sbt download the dependency's sources without using an IDE
plugin, add withSources() to the dependency definition. For API jars,
add withJavadoc(). For example:
libraryDependencies += "org.apache.felix" % "org.apache.felix.framework" % "1.8.0" withSources() withJavadoc()
Note that this is not transitive. Use the update-*classifiers tasks
for that.
You can also run sbt update-classifiers to download sources and javadoc jars for all project dependencies at once
For sbt 1.0, command is sbt updateClassifiers
For me, it worked better with
sbt ';reload plugins; updateClassifiers'
The goal is to have a standalone Play Framework (2.2) application having an additional status window open containing some javafx (javafx-8) elements.
Since JavaFX classes are now on the default runtime classpath for an Oracle Java 8 implementation using javafx.* in my classes and compiling with sbt should just be fine.
However sbt can't find these classes and quits with
play.api.UnexpectedException: Unexpected exception[NoClassDefFoundError: javafx/application/Application]
when executing
..\path-to-play-framework-2.2\play project run
The best way to fix this problem seems to be the modification of build.sbt in the project directory. What can I do to add the missing (class) path?
Sadly JavaFX doesn't link that easily to an sbt build. You need to set your JAVA_HOME environment variable and do modifications to your build file.
Here I have a repository where this is set up. The important bit if you are using an sbt build rather than a scala build is this one:
unmanagedJars in Compile += Attributed.blank(
file(System.getenv("JAVA_HOME") + "/jre/lib/jfxrt.jar")),
fork in run := true
The reason for this is that jfxrt.jar is the archive containing the JavaFX runtime and it is not included in the classpath of an sbt project by default.
Anotherway is to set the Classpath for sbt. This can be done on the machines which can't resolve JavaFX.
SBT_OPTS="-Xbootclasspath/p:/usr/share/java/openjfx/jre/lib/ext/jfxrt.jar"
I forked a Scala library from GitHub, and I want to import it to another project.
How can I tell sbt where to find this package?
For example, I'm writing a program in ~/code/scala/myProgram, and I want to import a library from ~/code/scala/otherlib.
If it is supported by the project you have cloned (that is, if it supports SBT and is configured to publish to a repository), you can publish it locally with the sbt command sbt publish-local. For example:
cd ~/code/scala/otherlib
sbt publish-local
This will build and publish this library in your local Ivy repository (typically ~/.ivy2/local). Note that you will need to repeat this each time you modify the otherlib sources.
After the project's published locally to the local Ivy repository, you can specify otherlib as a dependency in your SBT project, using the regular SBT dependency for the original version of the forked library (assuming that you haven't changed its ID, version, group ID, etc.). For example, by adding:
libraryDependencies += "com.some_company" % "otherlib" % "1.0.0"
to your build.sbt file.
Now, when you build your project, it will find otherlib in your local Ivy repository (as if it'd been pulled down from a regular repository) and will use your custom version of it.
If otherlib doesn't support SBT, or isn't configured to publish to a repository, and you do not want to modify it to do so, then you can simply copy its .jar file(s) to the /lib directory (~/code/scala/myProgram/lib) of your project.
SBT supports git repositories out of the box. The support is for clone and checkout. See my answer to Can SBT refresh git uri dependency (always or on demand)? or Using Git local repository as dependency in SBT project?, that boil down to the following in build.sbt:
lazy val gitRepo = "git:file:///Users/jacek/sandbox/so/sbt-git/git-repo/#master"
lazy val g = RootProject(uri(gitRepo))
lazy val root = project in file(".") dependsOn g
Once you define the dependency (between projects) you can use it - the git-hosted project - with no other configuration.
I have scala project that I use sbt to manage and I have a sbt plugin (sbt-twirl to be specific) that I need for the project. Now I would like to use Eclipse for editing/debugging the project. As usual, I used sbt-eclipse to generate the Eclipse project files and use scala-ide plugin in Eclipse. However, the Eclipse project does not compile the code that requires the sbt-twirl plugin. I am guessing that the sbt used by Eclipse is not picking up the sbt-twirl plugin. Is there any way to configure Eclipse's sbt to use the sbt-twirl plugin (configure either automatically through sbt-eclipse, or manually in Eclipse)?
I am using Eclipse Indigo (3.7.2) with Scala IDE 2.0.2 .
Thanks in advance.