Proguard Plugin for SBT Not Working? - scala

[info] [SUCCESSFUL ] org.scala-sbt#xsbt-proguard-plugin;0.1.3!xsbt-proguard-plugin.jar (425ms)
[info] downloading http://repo1.maven.org/maven2/net/sf/proguard/proguard-base/4.8/proguard-base-4.8.jar ...
[info] [SUCCESSFUL ] net.sf.proguard#proguard-base;4.8!proguard-base.jar (1346ms)
[info] Done updating.
I got these messages after adding
resolvers += Resolver.url("sbt-plugin-releases-scalasbt", url("http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)
addSbtPlugin("org.scala-sbt" % "xsbt-proguard-plugin" % "0.1.3")
to my .sbt/plugins/build.sbt file, which makes me think proguard and it's library are installed just fine. But trying to use proguard or checking min-jar-path just gives me an error
[error] Not a valid command: proguard (similar: reload)
or
[error] Not a valid key: min-jar-path (similar: ivy-paths)
I've also tried putting the same thing into the (proj-directory)/project/build.sbt and still no luck. Also tried putting it at ~/.sbt/plugins/plugins.sbt with the same result. If I try about at the SBT prompt it tells me
[info] Available Plugins: ProguardPlugin
And yet I can't seem to run it at all. What am I doing wrong?

The step "Injecting the Plugin into desired project" is missing: https://github.com/adamw/xsbt-proguard-plugin#injecting-the-plugin-into-desired-project

Related

scala "console" command gives error "Missing scala-library.jar"

Under sbt, if I give "console" to start a REPL shell, I get the following error.
[error] stack trace is suppressed; run 'last scalaInstance' for the full output
[error] (scalaInstance) Missing scala-library.jar
[error] Total time: 1 s, completed Oct 7, 2019 12:45:07 PM
$ sbt scalaVersion
[info] Loading global plugins from C:..\plugins
[info] Loading settings for project test from plugins.sbt ...
[info] Loading project definition from C:xx\test\project
[info] Loading settings for project root from build.sbt ...
[info] scalaVersion
[info] 2.11.12
$ sbt sbtVersion
[info] sbtVersion
[info] 1.3.0
Try
assemblyOption in set: = (assemblyOption in set) .value.copy (includeScala = true)
Source: https://github.com/sbt/sbt-assembly
if this doesn't solve the issue, it could be a compatibility issue with a plugin which you might have installed, it means that you would have to delete the plugin directory in %HOME%. and %HOME%.ivy2 because it caches some artifacts locally.
If you are not able to find the plugin try deleting %HOME%.ivy2 and running the console again, as it will remove the cached artifacts.
You might want to refer
https://pt.coredump.biz/questions/50313823/why-does-running-tests-through-jenkins-user-on-build-slave-fail-with-missing-scalalibraryjar
I hope it helps.
Somewhat unrelated but I ran into this error on one of my projects and deleting all caches (.m2, .ivy2, coursier) was not enough to fix this. I also had to clear out my .sbt folder (I assume emptying the boot directory). Be sure to backup any settings you still might need.
can you try updating scala version in your sbt build?
for example,
scalaVersion := "2.13.0"

sbt doesn't find class of managed dependency

I try to include the build of jep (https://mvnrepository.com/artifact/jep/jep/2.24) into this scala project using sbt: https://github.com/shadaj/scalapy
So, instead of building jep manually via an unmanaged dependency, I want to include it as a managed dependency. Therefore I just included:
resolvers += "jep" at "https://mvnrepository.com/artifact/"
libraryDependencies += "jep" % "jep" % "2.24"
in the build.sbt
The .jar is getting downloaded and included in my .ivy2 folder but when compiling, sbt seems not to find it:
> compile
[info] Updating {file:/C:/scalapy_indp/scalapy/}scalapy...
[info] Resolving org.sonatype.oss#oss-parent;9 ...
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.1/scala-library-2.12.1.jar ...
[info] [SUCCESSFUL ] org.scala-lang#scala-library;2.12.1!scala-library.jar (1406ms)
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.12.1/scala-reflect-2.12.1.jar ...
[info] [SUCCESSFUL ] org.scala-lang#scala-reflect;2.12.1!scala-reflect.jar (1156ms)
[info] downloading https://repo1.maven.org/maven2/jep/jep/2.24/jep-2.24.jar ...
[info] [SUCCESSFUL ] jep#jep;2.24!jep.jar (188ms)
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.12.1/scala-compiler-2.12.1.jar ...
[info] [SUCCESSFUL ] org.scala-lang#scala-compiler;2.12.1!scala-compiler.jar (2469ms)
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/modules/scala-xml_2.12/1.0.6/scala-xml_2.12-1.0.6.jar ...
[info] [SUCCESSFUL ] org.scala-lang.modules#scala-xml_2.12;1.0.6!scala-xml_2.12.jar(bundle) (360ms)
[info] downloading https://repo1.maven.org/maven2/jline/jline/2.14.1/jline-2.14.1.jar ...
[info] [SUCCESSFUL ] jline#jline;2.14.1!jline.jar (250ms)
[info] Done updating.
[info] Compiling 16 Scala sources to C:\scalapy_indp\scalapy\target\scala-2.12\classes...
[info] 'compiler-interface' not yet compiled for Scala 2.12.1. Compiling...
[info] Compilation completed in 15.285 s
[error] C:\scalapy_indp\scalapy\src\gen\scala\me\shadaj\scalapy\py\ObjectTupleReaders.scala:2: not found: object jep
[error] import jep.Jep
[error] ^
The errors of course keep coming for every Jep appearance in the code.
I'm absolutely not familiar with scala or sbt, I'm just trying to get this running without having to use unmanaged dependencies i.e. having it platform independent. Building jep manually seems to be platform dependent regarding the files which are being create:
If the build succeeds it will create a directory jep/build which will
contain a jep.jar and the compiled C library of Jep, typically named
jep.so or jep.dll depending on your platform.
see https://github.com/mrj0/jep/wiki/Getting-Started
The dependency is correctly setup, but the import is wrong.
Try
import org.nfunk.jep.JEP
instead.
--
Actually, I just realized those may be two different projects. The dependencies you included is this one: http://sens.cse.msu.edu/Software/jep-2.23/doc/website/doc/doc_usage.htm

Warning message running Play - activator eclipse

I downloaded play framework from here:
https://www.playframework.com/download
And I chose the Offline Distribution download.
I set the path environment variable and added this:
C:\Framework\activator-dist-1.3.10\bin
While trying to create a new project I wrote in the cmd "activator new" and it worked.
Than I wrote activator eclipse but I got this errors:
C:\Users\***\Desktop\***\FirstPlayProject>activator eclipse
ACTIVATOR_HOME=C:\Framework\activator-dist-1.3.10
The system cannot find the file BIN_DIRECTORY\..\conf\sbtconfig.txt.
[info] Loading project definition from C:\Users\***\Desktop\·δ≡σ·\FirstPlayPro
ject\project
[info] Updating {file:/C:/Users/***/Desktop/%D7%AA%D7%9B%D7%A0%D7%95%D7%AA/Fir
stPlayProject/project/}firstplayproject-build...
[info] Resolving com.typesafe.akka#akka-persistence-experimental_2.10;2.3.11 ...
[info] Resolving com.fasterxml.jackson.datatype#jackson-datatype-jsr310;2.5.4 ..
[info] Resolving org.scala-sbt.ivy#ivy;2.3.0-sbt-2cc8d2761242b072cedb0a04cb39435
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to FirstPlayProject (in build file:/C:/Users/***/De
sktop/%D7%AA%D7%9B%D7%A0%D7%95%D7%AA/FirstPlayProject/)
[error] Not a valid command: eclipse (similar: help, alias)
[error] Not a valid project ID: eclipse
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: eclipse (similar: deliver, licenses, clean)
[error] eclipse
[error]
Maybe it because of this error: The system cannot find the file BIN_DIRECTORY\..\conf\sbtconfig.txt.
You will need to add sbteclipse for that to work. In your project/plugins.sbt file, add the following:
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
Then compile your app first (compile in the activator shell). Then you can use the eclipse command in the activator shell.
More info: https://www.playframework.com/documentation/2.5.x/IDE#Eclipse

Why is Typesafe activator command `activator dependencies` not working?

I created a new project using Typesafe Activator. In the command prompt I execute the command activator dependencies. This results in:
E:\sample_app>activator dependencies
[info] Loading project definition from E:\sample_app\project
[info] Updating {file:/E:/sample_app/project/}sample_app-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to sample_app (in build file:/E:/sample_app/)
[error] Not a valid command: dependencies
[error] Not a valid project ID: dependencies
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: dependencies (similar: all-dependencies, rpm-dependencies, allDependencies)
[error] dependencies
[error] ^
Versions used:
Java version is 1.8.0_51,
Activator is 1.3.6,
OS is windows 8,
64 - bit OS.
Analysis
First, dependencies is not valid sbt commands. (All sbt commands can be used also in activator.)
Solution
Either you mean libraryDependencies (which is an sbt setting) so call
activator libraryDependencies
Or you want to see the classpath of the dependencies ( a sbt task, so you need to use show to see the output of the sbt task), e.g.
activator "show dependencyClasspath"
Edit as of 2015-09-30,3:50am
If calling from console, the combined command must be put into quotes. Here: "show dependencyClasspath"

Exclude test dependency resolution from `sbt compile`

When running sbt compile, dependencies marked as test are still resolved even though they are not later included later in compilation. It seems like this should only happen during the test:compile task. Is there a way to exclude test dependencies from being resolved and downloaded during the compile task?
Here is an example with the org.mockito#mockito-all dependency. I have it declared as test-only:
"org.mockito" % "mockito-all" % "1.9.0" % "test"
However, when (clearing it from my local Ivy cache and) running sbt compile, it gets needlessly downloaded:
$ sbt compile
[info] Loading global plugins from /Users/rbrainard/.sbt/plugins
[info] Loading project definition from /Users/rbrainard/Development/spitball/project
[info] Set current project to spitball (in build file:/Users/rbrainard/Development/spitball/)
[info] Updating {file:/Users/rbrainard/Development/spitball/}spitball...
[info] Resolving org.mockito#mockito-all;1.9.0 ...
[info] downloading http://repo1.maven.org/maven2/org/mockito/mockito-all/1.9.0/mockito-all-1.9.0.jar ...
[info] [SUCCESSFUL ] org.mockito#mockito-all;1.9.0!mockito-all.jar (2075ms)
[info] Done updating.
[success] Total time: 7 s, completed May 28, 2014 4:51:20 PM
In sbt the update task resolves all dependencies for all configurations. Sbt makes use of Ivy, which promotes a very interesting "configuration" aspect to be able to separately resolve disparate classpaths at the same time.
Sbt is not only resolving your test classpath, but also runtime, the scala-tools (compiler, scaladoc, repl) and more.
Please read: https://ant.apache.org/ivy/history/latest-milestone/terminology.html for more information on the design of Ivy, which is why sbt attempts to do all resolution at once for all configurations.