How do I use multiple source paths with dokka's fatjar? - kotlin-dokka

I'm using dokka to generate some code for a multi-module project. I have successfully been able to generate documentation for a single module with their cli fatjar, but the module is dependent on another one.
Let me note that the only difference between the processes' commands I kick off are the sources argument (though I have redacted things like the classpath for ease and NDA purposes):
Single module
(working)
java -jar <path_to_jar>/dokka-fatjar-0.9.17.jar /<absolute_path1>/src -output docs -classpath <class_path>
Multiple sources
(not even analyzing and produces 0 results in output directory)
java -jar <path_to_jar>/dokka-fatjar-0.9.17.jar /<absolute_path1>/src:/<absolute_path2>/src -output docs -classpath <class_path>
The classpaths end up being the exact same (after aggregating them in the project build code).

Separate source directories with space, not with :
java -jar <path_to_jar>/dokka-fatjar-0.9.17.jar /<absolute_path1>/src /<absolute_path2>/src -output docs -classpath <class_path>
This will produce single documentation with mixed sources from both directories.
To produce separated documentation for each of module, use
java -jar <path_to_jar>/dokka-fatjar-0.9.17.jar /<absolute_path1>/src -output docs -classpath <class_path_for_module1> -module module1
And then for module2, which depends on module1:
java -jar <path_to_jar>/dokka-fatjar-0.9.17.jar /<absolute_path2>/src -output docs -classpath <class_path_for_module2> -module module2 -links <deploy_url>^file://./docs/module1/package-list
Assume that <class_path_for_module2> contains compile output of module1 + <class_path_for_module1>

What ended up working for me was
java -jar <path_to_jar>/dokka-fatjar-0.9.17.jar -src /<absolute_path1>/src:/<absolute_path2>/src -output docs -classpath <class_path>'=
That is, using -src with the native path separator. Provided by #Semoro at dokka's gh issues. Thank you!

Related

Cannot run tests with org.scalatest.tools.Runner from command line

I have my test compiled in a directory: samplesuite
It works when running one Suite using org.scalatest.run.
Nothing happens when I try to run the directory that contains several suites.
scala -cp "..\mytestframework\target\scala-2.12\mytestframework-assembly-0.1.jar;../../Downloads/scalactic_2.12-3.0.5.jar;..\..\Downloads\scalatest_2.12-3.0.5.jar" org.scalatest.run samplesuite.SomeSpec
But it won't run when trying:
scala -cp "..\mytestframework\target\scala-2.12\mytestframework-assembly-0.1.jar;../../Downloads/scalactic_2.12-3.0.5.jar;..\..\Downloads\scalatest_2.12-3.0.5.jar" org.scalatest.tools.Runner -R samplesuite
Assuming tests are defined in package samplesuite, for example
package samplesuite
class SomeSpec extends FlatSpec with Matchers
and current working directory . is one level above samplesuite, then discover and run all suites with
scala -cp "..\mytestframework\target\scala-2.12\mytestframework-assembly-0.1.jar;../../Downloads/scalactic_2.12-3.0.5.jar;..\..\Downloads\scalatest_2.12-3.0.5.jar" org.scalatest.tools.Runner -R .
In general, when specifying runpath from which tests will be discovered with -R point to the root directory where your packages start, or to the .jar file generated with sbt test:package:
scala -cp target/scala-2.12/classes:scalatest_2.12-3.0.5.jar:scalactic_2.12-3.0.5.jar org.scalatest.tools.Runner -R target/scala-2.12/test-classes
scala -cp target/scala-2.12/classes:scalatest_2.12-3.0.5.jar:scalactic_2.12-3.0.5.jar org.scalatest.tools.Runner -R target/scala-2.12/how-can-i-perform-an-or-with-scalatest_2.12-0.1.0-SNAPSHOT-tests.jar

How BTrace's -classpath param support many jar files?

Sometimes we need to depend third part jar file when using BTrace.
Maybe i need import a.jar and b.jar to support BTrace script.How could i spell the -classpath param?
I have fixed this problem.
The -classpath param can be multi path of jar file.
In windows like -classpath ./a.jar;./b.jar
And in linux like -classpath ./a.jar:./b.jar

Run junit4 test from cmd

I tried to run junit4 test case from command line using:
java -cp junit-4.8.1.jar;test\Dijkstra;test\Dijkstra\bin org.junit.runner.JUnitCore Data0PathTest00
but I got the following error:
java.lang.NoClassDefFoundError: graph/shortestgraphpath;
while the test case is working without any problems in eclipse.
Hint: in eclipse, shortestgraphpath was added in Referenced Libraries.
You need to the jar file containing shortestgraphpath to java class path.
java -cp junit-4.8.1.jar;test\Dijkstra; test\Dijkstra\bin org.junit.runner.JUnitCore Data0PathTest00
The class path is the value that you pass to java with -cp so in your question you just supply junitand your compiled classes.
Try updating it with the jar file with the missing class.
java -cp junit-4.8.1.jar;<path to jar file>;test\Dijkstra;test\Dijkstra\bin org.junit.runner.JUnitCore Data0PathTest00
You might have to add additional jar files as well. I recommend that you take a look at some build tool to help you build and run your java applications for example Maven, Gradle, Buildr.

scala: Error occurred during initialization of VM on Ubuntu 12.04

I tried to work with easy example of scala language.
I installed sbt successfully. When run sbt -h I see help message from sbt:
Usage: sbt [options]
-h | -help print this message
-v | -verbose this runner is chattier
-d | -debug set sbt log level to debug
-no-colors disable ANSI color codes
-sbt-create start sbt even if current directory contains no sbt project
-sbt-dir <path> path to global settings/plugins directory (default: ~/.sbt)
-sbt-boot <path> path to shared boot directory (default: ~/.sbt/boot in 0.11 series)
-ivy <path> path to local Ivy repository (default: ~/.ivy2)
-mem <integer> set memory options (default: 1536, which is -Xms1536m -Xmx1536m -XX:MaxPermSize=384m -XX:ReservedCodeCacheSize=192m) ....
but when I tried to run in the directory with scala assignments (it's Coursera course) I caught error:
nazar_art#nazar-desctop:~/scala/example$ sbt
Detected sbt version 0.12.1
Starting sbt: invoke with -help for other options
Error occurred during initialization of VM
Could not reserve enough space for object heap
but it should open the sbt command prompt. Smt like this:
shell$ cd /path/to/progfun-project-directory # This is the shell of the operating system
shell$ sbt
> _ # This is the sbt shell
UPDATE:
After I add this following line
java -Xms64M -Xmx256M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=64M -jardirname $0/sbt-launch.jar "$#"
at /usr/bin I see next output:
nazar_art#nazar-desctop:/usr/bin$ sbt
bash: /usr/bin/sbt: Permission denied
nazar_art#nazar-desctop:/usr/bin$ sudo sbt
sudo: sbt: command not found
- Why this happen?
- How to solve this issue?
First of all, The example folder name (and the folder name that you have installed sbt) cannot include "!". this probably applies to other special characters as well. Even, I recommend to install SBT in a folder that has no space on its path (and the same thing for examples folder).
For example, if you have installed SBT (or examples folder) on a path like:
/Users/dashti/My Programs/sbt-0.12.1
You can re-install it a path like:
/Users/dashti/MyPrograms/sbt-0.12.1
By applying this naming change, if the error is gone, please ignore the rest of this post.
Otherwise, to fix the mentioned error, first find sbt executable script, then edit it and correct any problem in it:
If you are using a UNIX-based operating system, please follow these steps:
1- Find SBT: Open a terminal and type this command:
which sbt
and you will receive a path like:
/Users/dashti/Documents/scala-2.10.0/bin/sbt
and in this file, there is a command for executing a java program, like:
java -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=128M -jar `dirname $0`/sbt-launch.jar "$#"
2- Edit sbt script: by entering this command in terminal:
vim /Users/dashti/Documents/scala-2.10.0/bin/sbt
you will be able to edit this file and maybe you should change the memory usage arguments to a lower specification ( You should think about whether you have enough RAM to be running the sbt). For example, this one will be a better choice:
java -Xms64M -Xmx256M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=64M -jar `dirname $0`/sbt-launch.jar "$#"
SBT needs more memory allocated to the JVM.
This can be done in build.sbt:
javaOptions ++= Seq(
"-Xms64m",
"-Xmx256M",
"-XX:+CMSClassUnloadingEnabled",
"-XX:MaxPermSize=64M"
);
Creating an sbt file(no extentions) and running ./sbt is better, but with the code below(#MohammadDashti's suggestion), sbt-launch.jar needs to be in the project folder.
java -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled \
-XX:MaxPermSize=128M -jar `dirname $0`/sbt-launch.jar "$#"
Later you could add javaagent:/path/to/jrebel -Drebel.remoting_plugin=true and re-deploy changes on save with a free JRebel for Scala license.

How o run a NetBeans-built Scala application jar from command line outside IDE?

A program of mine (written in Scala 2.8) works fine when launched by means of NetBeans IDE. But when I try to run it from outside, with "java- jar", it says "Exception in thread "main" java.lang.NoClassDefFoundError: scala/ScalaObject...". Putting all the libraries, incl. Scala runtime inside the same dir as the jar to be run doesn't help. If i try to run the jar with scala itself, it complains that it can't decode it as utf-8 (it expects a scala source rather than a jar, I suppose). So how do I run a Scala application at all?
UPDATE: For those who come here later having the same question I'd recommend to read comments under barjak's answer (including those latest ones hidden), the answer is there. VonC also gives some interesting links on the subject.
The -jar and -classpath of the java command are mutually exclusive : you can't do java -jar YourScalaProg.jar -classpath scala-library.jar
If you want to run your application with java -jar, then the full classpath must be specified in the Class-Path section of the jar's manifest.
You can run your application using only -classpath, like that : java -classpath YourScalaProg.jar:scala-library.jar your.package.MainClass.
Are you using scala-library.jar as described in Adventures with Scala blog post?
java -classpath scala-library.jar:. YourClass
or:
java -classpath scala-library.jar:yourApp.jar YourClass
Where YourClass is was your scalac compiled Scala code.
You will find the same scala-library.jar used in the SO question "Creating a jar file from a Scala file" (or in the blog post "the not so elegant way of creating an executable jar from scala code").