Play framework 2.5 not compiling source files (inside app folder) - playframework-2.5

We have a Play project with folder structure given in the link https://www.playframework.com/documentation/2.5.x/Anatomy.
We have addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.2") in plugins.sbt and in build.sbt we have added the below lines,
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.7"
While we give compile command (through activator), the project loads the dependency jars from build.sbt, but the .classes files are not generated in target folder.
Could anyone please help us in solving the issue?

We have solved the issue by adding the following line to build.sbt file,
javaSource in Compile := baseDirectory.value / "app"
After the addition of this, the .java files and .scala files inside the "app" folder gets compiled.

Related

Gradle: Copy one specific file from main project directory into subproject/build/libs

Searching in vain for examples on this humble task, none worked, I need to learn how to use gradle to copy one specific file from the main directory of a gradle project (containing subprojects) and into the /build/libs folder of one of the subprojects. Structure is this:
mainProject folder
file.txt
Subproject folder
build folder
libs folder
(I want to copy file.txt here)
This copy process shall be in the build.gradle (for the Subproject) file. I am using Android Studio and the subproject is a pure java application.
Thanks for any help.
You need to implement a custom task of type Copy to copy the file to the target directory. To access the file in the root project, you may use the rootProject property of the subproject.
task copyFileFromRootProject(type: Copy) {
from "${rootProject.projectDir}/file.txt"
into 'build/libs'
}

Add local Gradle source module by absolute path

I want to add a subproject to my Gradle project. The project is located somewhere on my hard disk drive, for example:
/A/Path/to/a/ProjectA
/Another/Path/to/another/ProjectB
What I want to achieve is to use ProjectB as a source module within Project A. However, all my attempts to do this so far - either by adding include /Another/Path/to/another/ProjectB or by adding include ':ProjectB'; project(':ProjectB').projectDir = ... in settings.gradle - just failed. Apparently, Gradle is not able to find the project.
How can I add ProjectB as a dependency without moving it from it's location?
Using Gradle 3.4.1, the following works for me (full example here):
include 'app', 'common'
def MY_PATH = '/Users/johndoe/foo'
assert new File("$MY_PATH/random/path/common").exists()
project(':common').projectDir = new File("$MY_PATH/random/path/common")
Thanks for your responses.
Turns out I've made several mistakes:
Adding the project to the built was dependent on the value of an environment variable. I replaced that with a property within gradle.properties.
I tested this by running the settings.gradle usind IntelliJ. I mistakingly expected this to work, but it didn't
I did not add the project as a dependency to the build.gradle file of the parent project.
It works now. Thank you all again!

Gradle - paths in multi-project builds

I have a multi-project gradle project with following directory structure:
+ project_root
+ module1
+ src
build.gradle
+ module2
+ src
build.gradle
+ web
..
build.gradle
settings.gradle
In module1/build.gradle among other things I have specified:
compileKotlin2Js.kotlinOptions {
outputFile = "web/script.js"
}
It is a special Kotlin JS setting that specifies output file path of compiled JS file.
Now my problem is, that when I build the whole project (project_root/build.gradle) the file ends up in the right directory (project_root/web), but when I accidentally run build on the module alone the file is saved in module directory (project_root/module1/web).
How can I fix paths in my build scripts, so file output will be saved in exactly the same directory no matter which build script I run (without specifying full path, I want a relative path)?
I don't know what Gradle plugin requires the path parameter in your code example, but all regular (non-3rd-party) Gradle plugins evaluate path parameters via Project.files(Object...) to avoid different locations when calling Gradle from various working directories.
I would suggest to use the above method (or its single file version Project.file(Object)) as well. You can even omit the project part, because the build.gradle file gets executed in the project scope:
compileKotlin2Js.kotlinOptions {
outputFile = file('web/script.js')
}
This will always evaluate the path relative to the project directory of the project your build.gradle belongs to. To evaluate a file relative to the project directory of the root project, use rootProject.files(Object...), for a path relative to the project directory of a subproject or any project in the build, use project(':path:to:project').files(Object...).

SBT JDKpackager error invoking method

Summary
I am having difficulty running and debugging a CLI application built with SBT Native Packager - browsing similar questions yielded little insight as they are either referring directly to JDK packager (via JavaFX) or are simply incomplete/unanswered. Running the application throws an error message that is hard to reason about and/or track down the root cause of (no logs).
Stack
JDK 8u60
SBT 0.13.9
sbt-native-packager 1.0.6
Inno Setup 5.5.8
The intention is to build Windows installation package - which seems correctly built (I am able to install it to another machine).
Error details
After installing the packaged app, one of two happens:
running the app without any command parameters does nothing (no errors printed to console, dead silent)
running the app with a parameter --help (which hits a code path in main method that prints out the help file) yields "Error invoking method" followed with "Failed to launch JVM" errors. I could not find any error logs or further precise hints. The application's bootstrap is practically a single class (containing main()) contained in its own SBT module, which in turn produces its own JAR.
Investigation
In absence of any idea where to start I started to investigate this with following results:
there are two bootstrap JARs produced, let's call them bootstrap.jar and bootstrap-launcher.jar
both contain MANIFEST.MF with the Main-Class element correctly populated
the former doesn't contain Class-Path element but contains elements like Implementation-Title and so on. It contains the compiled bootstrap class at the expected package. The Main-Class in its manifest file points to that package.
the latter is directly opposite the former: its manifest file contains Class-Path and Main-Class elements, nothing else. Additionally, it doesn't contain any compiled code whatsoever
Experiments
I performed the following experiments with bootstrap JARs:
deleting bootstrap.jar or bootstrap-launcher.jar
renaming and overwriting bootstrap-launcher.jar -> bootstrap.jar
renaming and overwriting bootstrap.jar -> bootstrap-launcher.jar
manually adding Class-Path entries from bootstrap.jar manifest file to bootstrap-launcher.jar's manifest file (a.k.a. desperation mode)
end result of these experiments is always the same: 'Class com...Bootstrap not found' exception thrown in a GUI window; no further explanations or stacktraces
At this point in time I have no other ideas so I would appreciate any insight.
Additionally, I see library dependencies correctly materialized in lib directory, so at least I surmise this is working correctly.
build.sbt
Lastly, for completion, I am attaching my current build.sbt file. The reason it's structured as is, is because I used to use sbt-assembly to produce a fat JAR - it worked quite nicely but new packaging was requested. Tracing down the issue, I removed all traces of sbt-assembly from build, except from plugins.sbt (simply as convenience of easier fallback, should the need arise).
lazy val root: Project = (project in file("."))
.aggregate(common, commonTest, core, bootstrapCli)
lazy val common: Project = (project in file("common"))
.settings(
libraryDependencies := ...
lazy val commonTest: Project = (project in file("commonTest"))
.dependsOn(common % "compile -> test")
.settings(
libraryDependencies := ...
)
lazy val core: Project = (project in file ("core"))
.dependsOn(common, commonTest % "test -> test")
.settings(
libraryDependencies := ...,
javacOptions in (Compile, compile) ++= Seq("-parameters"),
javacOptions in doc ++= Seq.empty,
)
lazy val bootstrapCli: Project = (project in file("bootstrapCli"))
.dependsOn(core % "compile -> compile;test -> test")
.enablePlugins(JDKPackagerPlugin)
.settings(
jdkPackagerType := "exe",
mainClass in Compile := Some("com._3esi.load.bootstrap.cli.Bootstrap")
)
Again, I'd greatly appreciate any insight.

Windows Compact Embedded - Include external native files

I have created a Sub project which just prints "Hello World". My goal is to create a C file inside the same subproject but within a folder named "src", also I want to create a H file within a folder named "include".
The H file contains only one function declaration "void printContent();" and the C file contains its definition which prints "Hello Buddy".
I added the C file inside the Source Files section of Sub project and added the H file inside the Header File Section, but when I compile the subproject and try to deploy it on to an emulator, I got an error.
BUILD: [01:0000000047:ERRORE] NMAKE : U1073: don't know how to make 'obj\ARMV4I\debug\content.obj'
I tried to configure the subproject by providing the below lines in the sources file of every Sub project.
INCLUDES= include/
But nothing changed and the problem still persists.
In wince subproject, sub folders are treated differently in the source file layout.
Rule No.1 You can't have both source and dirs files in the same folder.
So you either use one folder, or use several sub folders, then the root folder is clean and have one dirs file and several folders, no source file.
Rule No. 2 Each sub folder should have both source and makefile
You can copy and then edit the source file, the makefile will always be the same.
Ok, if you are going to use subfolder just to make the folder structure cleaner, my suggestion is that you create 2 subprojects, one is the main subproject; the other includes all your src files and its type is set to be static library. Then you can link to the static .lib file just as you are including them as in a subfolder. Of cource you need to set the additional include folder and input library.

Resources