sbt runmain does not find class - sbt

I have a function that I'm running with sbt runMain. I was able to get this working previously, but some changes in the project means it's no longer working, but I can't quite understand it.
When I run
sbt "runMain com.example.projects.data.CallMe" I get:
[error] (Compile / runMain) java.lang.NoSuchMethodException:
com.example.projects.data.CallMe.main([Ljava.lang.String;)
But in the SBT console, this works:
import com.example.projects.data.*
CallMe.main(List())
This succeeds. How would I be able to debug this?
Versions:
Scala 3.1.2
Sbt: 1.6.2

Related

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0 in android studio

I am trying to run my emulator after adding the firebase and google sign in plug ins/dependencies to my gradle.build files and now I am receiving the error
"Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0"
anyone know if I am doing something wrong this is a react native firebase app.
I am not sure what to try. This is my first app I am doing for a project at school and I do not really know what I am doing. I have just been following tutorials online
Solve this issue by deleting the .gradle folder from <NameOfProject>/android and again run npm run android
I think I just had this same problem. I don't have any idea what your error logs are though so I am not certain however this is my error log right here:
`> Task :react-native-gradle-plugin:compileKotlin FAILED
'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm targeta version. 1 actionable task: 1 executed`
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':react-native-gradle-plugin:compileKotlin'. Failed to query the value of task ':react-native-gradle-plugin:compileKotlin' property 'compilerRun Kotlin could not find the required JDK tools in the Java installation. Make sure Kotlin compilat
This error however I fixed by editing the gradle-wrapper.properties file's distributionUrl variable. I changed the distributionUrls gradle version to 7.4.2 the file is in Project-Name\android\gradle\wrapper\gradle-wrapper.properties
My error log is saying that gradle's version of JVM want's to be version 11 and is not but you can check gradle's jvm version by using cd android in the project root directory and after that run ./gradlew --version Change JVM's version from the version it is showing to the version that it says is required like in my case v 11. The way I changed gradle's JVM version required chocolatey which is a package manager. This is where you can require it https://chocolatey.org/install and after you have setup chocolatey open a new terminal that has administrative privileges and run this choco install -y nodejs-lts openjdk11 with the JVM version it is asking for inside your error logs
and finally run npm start and after that npm run android inside a refreshed and new terminal and gradle's JVM version and gradle's version will be updated to the specified versions
We could better help if you could you show us your android/build.gradle and android/app/build.gradle files, but here are more specific instructions than you find in the docs:
In android/build.gradle, dependencies should look something like this:
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.3.10'
classpath("com.android.tools.build:gradle:<version>")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:<version>")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
see: https://github.com/gyani-sunkara/rn-firebase-login-starter/blob/main/android/build.gradle
It is known this works with the classpaths at the beginning.
--
Also in android/app/build.gradle, it is known that the google-services dep works at the end of the file.
apply plugin: 'com.google.gms.google-services'
and make this the last "implementation" under dependencies (around line 272)
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0' // <-- add this; newer versions should work too
see: https://github.com/gyani-sunkara/rn-firebase-login-starter/blob/main/android/app/build.gradle
Then, delete android/.gradle and run npx react-native run-android in the root directory.

sbt supress ignoring option MaxPermSize=256m

PS D:\Users\erick\repos\leaderboard> sbt about
The Java Development Kit (JDK) installation you have is not up to date.
sbt requires at least version 6+, you have
version 0
Please go to http://www.oracle.com/technetwork/java/javase/downloads/ and download
a valid JDK and install before running sbt.
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from D:\Users\erick\repos\leaderboard\project
[info] Loading settings from build.sbt ...
[info] Set current project to leaderboard (in build file:/D:/Users/erick/repos/leaderboard/)
[info] This is sbt 1.1.4
[info] The current project is ProjectRef(uri("file:/D:/Users/erick/repos/leaderboard/"), "leaderboard") 0.0.0
[info] The current project is built against Scala 2.12.5
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, sbt.plugins.Giter8TemplatePlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.12.4
Been searching for almost an hour for some way to suppress
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
in SBT, but it seems impossible. Is there some way to do this?
As usual, I seem to find the solutions shortly after posting the problem:
Go to SBT installation directory
edit conf/sbtconfig.txt
remove -XX:MaxPermSize=256m
Sadly, Google provides many sbt hits that are either wrong or out of date, so it takes a while to find valid solutions.
This Solution worked for me
Go to project directory
Open directory sbt-dist\conf
Open sbtconfig.txt file and comment below property by putting # prior the line
#-XX:MaxPermSize=256m
There are many solution which show downgrade to java version. You don't need to do just follow above steps . It will work.

Error when trying to package native image with javapackager in java 9-ea?

I'm trying out java 9-ea (jdk-9+180) and the new javapackager to create a native image from a simple module but I get a nullpointer exception. Anyone know if I'm just too early or if I'm not using the right command switches in order to get it to work? The jlink command works fine but the javapackager does not. I'm using the latest jdk-9+180 at the time of writing. I have tried both with the -native exe and -native image switches but the same type of error occurs. I have also tried this on my Mac creating a native dmg with the -native dmg switch, but the same error occurs on that platform. I'm really after using the javapackager here to be able to bundle the build in exe/dmg.
Edit 1:
I have filed a bug report regarding this issue and it can now be visible at the following url: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8186661
My module-info.java:
module my.module {
requires javafx.graphics;
requires javafx.fxml;
exports sample;
}
First I'm creating a jar with javapackager which works fine:
C:\Java9Test\target>javapackager -createjar -appclass sample.Main -srcdir classes -outdir . -outfile myjar -v
I have verified the resulting jar structure looks okay with the correct compiled module-info.class and the other two classes in it.
The following jlink command works and produces a runnable reduced runtime image:
C:\Java9Test\target>jlink --output release\MyTestApp --compress=2 --module-path "myjar.jar;C:\Program Files\Java\jdk-9\jmods" --add-modules my.module
However, when trying the following command in order to create the native image using javapackager fails:
C:\Java9Test\target>javapackager -deploy -v -outdir packages -name MyTestApp -native image --module-path "myjar.jar;C:\Program Files\Java\jdk-9\jmods" --add-modules my.module --module my.module/sample.Main
outputs:
Running [C:\Program Files\Java\jdk-9\bin\java.exe, -version] Creating app bundle: MyTestApp in C:\Java9Test\target\packages Exception: java.lang.NullPointerException Exception in thread "main" com.sun.javafx.tools.packager.PackagerException: Error: Bundler "Windows Application Image" (windows.app) failed to produce a bundle. at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:374) at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:348) at jdk.packager/com.sun.javafx.tools.packager.Main.main(Main.java:496)
Edit 2:
Output from -native exe flag (on Windows)
Running [C:\Program Files\Java\jdk-9\bin\java.exe, -version]
Running [C:\Program Files (x86)\Inno Setup 5\iscc.exe, /?]
Detected [C:\Program Files (x86)\Inno Setup 5\iscc.exe] version [5]
At least one type of shortcut is required. Enabling menu shortcut.
Exception: java.lang.NullPointerException
Config files are saved to C:\Users\Username\AppData\Local\Temp\fxbundler17330843784617821035\windows. Use them to customize package.
Exception in thread "main" com.sun.javafx.tools.packager.PackagerException: Error: Bundler "EXE Installer" (exe) failed to produce a bundle.
at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:374)
at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:348)
at jdk.packager/com.sun.javafx.tools.packager.Main.main(Main.java:496)
Edit 3:
Output from -native dmg flag (on MacOSX)
Building DMG package for MyTestApp
Exception: java.lang.NullPointerException
Config files are saved to /var/folders/qs/nk3vxsx90q9_pbjs0ypg74r40000gn/T/fxbundler3765252041328710759/macosx. Use them to customize package.
Exception in thread "main" com.sun.javafx.tools.packager.PackagerException: Error: Bundler "DMG Installer" (dmg) failed to produce a bundle.
at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:374)
at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:348)
at jdk.packager/com.sun.javafx.tools.packager.Main.main(Main.java:496)
Output from -native deb flag (on Linux Mint)
Running [dpkg-deb, --version]
Debian packages should specify a license. The absence of a license will cause some linux distributions to complain about the quality of the application.
Exception: java.lang.NullPointerException
Config files are saved to /tmp/fxbundler2941553392593775128/linux. Use them to customize package.
Exception in thread "main" com.sun.javafx.tools.packager.PackagerException: Error: Bundler "DEB Installer" (deb) failed to produce a bundle.
at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:374)
at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:348)
at jdk.packager/com.sun.javafx.tools.packager.Main.main(Main.java:496)
Output from -native rpm flag (on Linux Mint)
Running [rpmbuild, --version]
At least one type of shortcut is required. Enabling menu shortcut.
Exception: java.lang.NullPointerException
Config files are saved to /tmp/fxbundler2278571164448075269/linux. Use them to customize package.
Exception in thread "main" com.sun.javafx.tools.packager.PackagerException: Error: Bundler "RPM Bundle" (rpm) failed to produce a bundle.
at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:374)
at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:348)
at jdk.packager/com.sun.javafx.tools.packager.Main.main(Main.java:496)
Answering my own question here (after having received a reply on the bug-report):
It turns out that the module-path must contain only directory names, not file names, hence you can not specify the jar in the path as you can with the jlink command. The javapackager works with the module-path if set to the compiled module-classes like below, also you don't need to put in the module-path to the jmods directory because it is picked up automatically.
C:\Java9Test\target>javapackager -deploy -v -outdir packages -name MyTestApp -native image --module-path C:\Java9Test\target\classes --module my.module/sample.Main
However, the resulting build's executable MyTestApp.exe did not work for me, nothing happened when invoked (double-clicked). Also the build is quite bulky and it seems you can not use the --compress=2 and --strip-debug flags yet as you can with jlink. However, I discovered that you can actually replace the content of the runtime folder produced with the javapackager with the output from the jlink command giving the build a much smaller footprint and the MyTestApp.exe works when invoked! I could also delete the java.exe and javaw.exe from the replaced runtime\bin folder as well as the msvcp120.dll and msvcr120.dll from the main MyTestApp-folder since those dll:s are already in the MyTestApp\runtime\bin folder.
MyTestApp-folder structure:
.

Remove "No main class detected" warning in SBT

I have a multi-module SBT project. Some of the modules produce JARs with main classes and can be started with java -jar but most don't.
However when I run (or compile, or anything else) one of the modules (sbt foo/run) I get a warning per library module.
[warn] No main class detected
How can I remove those warnings?
This warning is considered a bug in sbt 0.13.7 and it will be removed in sbt 0.13.8.

"release" command from sbt-release plugin is not recognized

I can't get the sbt-release plugin to work at all. The "sbt release" command is not recognized.
As per plugin's documentation, I have this entry added to my ./project/plugins.sbt file in my play application:
addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.8.5")
And I'm running the latest to-date 0.13.6 version of sbt launcher. Here's the error that I get when I execute "sbt release" from my project directory:
[info] Loading project definition from /Users/Projects/project
[info] Loading [pom.xml]
[info] Use auto-generated Build object
[success] POM definition loaded
[info] Set current project to integration (in build file:/Users/Projects/project/)
[error] Not a valid command: release (similar: reload, eclipse, last)
[error] Not a valid project ID: release
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: release (similar: rpmRelease, rpm-release, resolvers)
[error] release
[error] ^
And just to make sure, that sbt-release plugin does get loaded into the project, I execute "sbt about", and it does show that sbt-release is in the list of Available Plugins. But again, for some reason, "sbt release" command is not recognized.
> sbt about
...
[info] Available Plugins: ... sbtrelease.ReleasePlugin, ...
As per sbt-release plugin documentation, added this line into my build.sbt file, and it did it! "sbt release" command is now being recognized.
releaseSettings
For some reason, it did not work for me the first time I tried it earlier. Something must have been going on in my environment or earlier version of my build.sbt file.

Resources