Hi I'm trying to reference my external java project in my play framework project. Lets say my structure is:
/workspace
-playProject
-javaProject
I want to be able to call classes of javaProject in my playProject. I did some research and people were suggesting to add this line to my build.sbt:
lazy val javaProject = RootProject(file("../rolosRepo"))
lazy val root = (project in file(".")).dependsOn(javaProject).enablePlugins(PlayJava)
But still it tells me that the package com.xxx.xxxx does not exist.
Note: I have included the javaProject in my playProject build path
Related
I have a gradle based project where I needed to make a few tweaks to some library classes. I made a package with the same path as the library to override the class. It ends up working fine in my IDE, but when I export it via packr, the application refers to the original library code, not my overridden package code, so I get errors like this.
class com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NoSuchFieldError: soundCom
com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.(Lwjgl3Application.java:172)
Sorry if there is terminology I am missing, I'm not too familiar with this process.
Found a solution!
Basically you add
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
to your dist task in desktop build.gradle
I'm new to Java and am currently trying to build a cucumber / selenium project in IntelliJ that contains two modules: A library project containing page definitions, and a test project that contains the cucumber features and step definitions that talk to those page definitions. The idea is that the page definitions are a shared resource, and the tests are specific to different projects / groups. Both modules are at the same level underneath the parent project. The build is using Gradle, and the settings.gradle file for the parent looks as follows:
rootProject.name = 'composite-builds'
includeBuild 'libraryproject'
includeBuild 'testproject'
Using Gradle includeBuild on the parent project works fine and the whole project imports. However I am having no luck using the library project in my import statements in the test project. It consistently returns me these kinds of error: java: package libraryproject.pageFactory.examplePages does not exist and is clearly not seeing the library module.
What do I need to do / add in order for the test project to recognise the library project? I did try to also add the includeBuild statement in the settings.gradle for the test project but this made no difference.
The library can be found here
Update: the real reason that I cannot see the modules from the library project is that they were held in the test folder, not main.
Go to your build.gradle file
Instead of includeBuild use dependencies{compile{project(':libraryproject')}}
Inside the Root Project of libraryproject which is in your case the composite-builds. Change includeBuild to include in the settings.gradle
rootProject.name = 'composite-builds'
include ':libraryproject'
include ':testproject'
If it is in the same root:
dependencies {
compile(
project(':libraryproject')
)
}
Subfolder:
dependencies {
compile(
project(':myFolder1:myFolder2:libraryproject')
)
}
We have a very productive and robust SPL (software production line) for .NET platform to create web applications and HTTP services.
Now we want to import that knowledge into Android.
This is the scenario:
Developer A gets our android framework, and project A into the following paths:
D:\Android\Framework
D:\Android\ProjectA
And of course, project A should reuse code and stuff in Framework (layouts, java utilities, etc.)
Developer B's setup is:
C:\Users\Jack\AndroidStudioProjects\Framework
C:\Users\Jack\AndroidStudioProjects\ProjectB
Again, project B reuses Framework libraries.
Both developer A and developer B have AndroidProjectsRoot environment variables defined in their systems. For developer A it refers to D:\Android and for developer B the path is C:\Users\Jack\AndroidStudioProjects.
It's a team-convention that we all have one root folder and get each project in a direct child directory of that root folder.
We use Android Studio and gradle, and here's the place where we're stuck. We can't make project A or B build using Framework libraries. Framework has these libraries:
--jzp.framework
--validation
--http
-- more libraries here
Inside project A/B's settings.gradle we have:
include ':app', ':http', ':validation' //, more includes here
project(':http').projectDir = new File('$System.getenv("")/Framework/http/libs')
project(':validation').projectDir = new File('$System.getenv("")/Framework/validation/libs')
// more directory configurations here
Then in the app's gradle we have:
dependencies {
// other dependencies here
compile project(':http')
compile project(':validation')
// more compile statements here
}
However, project A/B won't build and we can't see our libraries packages inside our projects A/B etc.
What might be wrong? How to add dependencies to other modules on the hard drive, via environment variables?
This is somehow a follow-up of this question.
When I'm creating a Scala package with sbt, I am able to run it using one of these ways:
simply by typing run in the sbt console
or by creating a jar file (using either one-jar or assembly), and the running this jar in the system console by typing java -jar myjar.jar
But I don't know how to
run my package from the scala program ? (not the sbt scala console, in which everything works fine by typing import mypackage._)
use my Scala package in another project ? for example by importing myjar in another project ?
EDIT : you can forget my questions below about sbt-start-script because now I'm using sbt-native-packager (I have tried it just now and it works, but my previous questions remain open).
I have tried to use sbt-start-script but unsucessfully. The target/start script is well created but I get such errors:
$ sh target/start
target/start: 2: target/start: Bad substitution
Exception in thread "main" java.lang.NoClassDefFoundError: Hi
Caused by: java.lang.ClassNotFoundException: Hi
...
Here I simply have a main.scala file in the src/main/scala folder and it is:
object Hi { def main(args: Array[String]) = println("Hi!") }
I'm using these settings in build.sbt :
import com.typesafe.sbt.SbtStartScript
seq(SbtStartScript.startScriptForClassesSettings: _*)
There are several ways how you can use your project in another project. I will not discus the publishing to remote repository, as that's probably something you don't want to do anyway (at least at this point in time).
Lets assume you have a project called projectA - the build.sbt is just this:
name := "project-a"
organization := "com.acme"
version := "0.1.0"
And you have another project called projectB, where you want to use classes defined in projectA.
Unmanaged Dependency
One of the simplest ways is to use it as a unmanaged dependency. You can do that by putting the jar file produced by package, assembly or any other command producing an artefact.
Local Repository
Another way to use your dependency is to publish it to your local repository. Given the projectA as defined above, to the build.sbt of a projectB, add a dependency
libraryDependencies += "com.acme" %% "project-a" % "0.1.0"
Now you can publish projectA to your local repository by executing publishLocal in the projectA. The advantage of this approach is that if your projectA declares any dependencies, they will be added as transitive dependencies to projectB.
Project Dependency
Last way that comes to my mind is to declare dependency directly on the projectA. You can do that by creating a build.sbt file in the projectB, which looks more or less like this
lazy val projectA = file("/home/lpiepiora/q-23607291/projectA")
lazy val projectB = project in file(".") dependsOn projectA
Now classes declared in projectA should be visible in projectB.
I'm trying to add a subproject to my Play Framework project, and find the docs generally lacking there.
I've created a play project, let's call it my-web, and it's in directory /my-cool-project/web. I also have another project I would like my-web to depend on, let's call it my-model. my-model a git submodule for my-cool-project, and when I pull it, my directory structure is
/my-cool-project
/my-web
/app
/conf
build.sbt
/my-model
/main
/java
/src
Now, how do I add my-model as a subproject for my-web? I've tried
lazy val myModel = project.in(file("../my-model"))
but all I get is that my-model is not contained within the build root of my-web... Anything else I can try in build.sbt?
project is used to define the project model and sub-projects. For sibling project, you can use RootProject or ProjectRef. In your case, I would use RootProject.
lazy val myModel = RootProject(file("../my-model"))
When you compile a project, compilation on all RootProjects and ProjectRefs will triggered as well. You will define your project setting for my-model inside the build file in my-model project. This reduce the duplication for the project definition.
Think about RootProject and ProjectRef like project reference in Eclipse.
Let me know if this is what you are looking for.
change lazy val myModel = project.in(file("../my-model"))
to
lazy val myModel = project.in(file("my-model"))
Path it refers is from root of the project. So, you can give this path accordingly.