question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run script in execution doesn't work

See original GitHub issue

I just read in the Maven Handbook (http://www.sonatype.com/books/mcookbook/reference/sect-scala-script-inline.html) that it’s possible to run a scala script inside the Maven Scala Plugin. I tried the example in the book, which doesn’t work. Altering the script to a hello world also doesn’t work. Tried different versions of Scala (Scala 2.7.0, Scala 2.7.3, Scala 2.8.RC2) and different versions of the Maven Scala Plugin. But i always get the following error to run any script inside the MSP: java.lang.NoClassDefFoundError: scala/ScalaObject

Steps to reproduce: create scala maven project from archetype 1.2, add the following execution to the executions-tag of the maven scala plugin:

<execution>
  <id>prepare-package</id>
  <phase>prepare-package</phase>
  <goals>
    <goal>script</goal>
  </goals>
  <configuration>
    <scalaVersion>${scala.version}</scalaVersion>
    <keepGeneratedScript>true</keepGeneratedScript>
    <script>
    <![CDATA[
      println("hello from scala script")
    ]]>
    </script>
  </configuration>
</execution>

Then, run “mvn prepare-package” from command line.

Issue Analytics

  • State:closed
  • Created 13 years ago
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
lefoucommented, Jun 13, 2018

For the record, we use the script goal extensively and it works. Can this issue be closed?

0reactions
davidBcommented, Mar 30, 2014

Hi,

I introduce a bug in the last version. I wrapped every script external and inline like if it was part of the build. But in the original goals, inline script are part of the build and external are for test, run,…

It’s clearer when I read the comments on the includeScopes configuration :

There is a workaround, I change your pom.xml and I’d SUCCESS : for externalV3_1_6 add

<configuration>
  ...
  <includeScopes>plugin</includeScopes>
</configuration>

output :

➜  scalamavenexample git:(master) ✗ mvn clean -PexternalV3_1_6                                                       
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building scalamavenexample 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- scala-maven-plugin:3.1.6:script (ex1) @ scalamavenexample ---
hello
========================>MavenProject: com.jam:scalamavenexample:1.0-SNAPSHOT @ /home3/dwayne/tmp/scalamavenexample/pom.xml
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ scalamavenexample ---
[INFO] Deleting /home3/dwayne/tmp/scalamavenexample/target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.066s
[INFO] Finished at: Sun Mar 30 22:02:53 CEST 2014
[INFO] Final Memory: 10M/331M
[INFO] ------------------------------------------------------------------------

for inlineV3_1_6 : replace

&lt;![CDATA[ .... ]]&gt;

by

<![CDATA[ .... ]]>

output :

➜  scalamavenexample git:(master) ✗ mvn clean -PinlineV3_1_6  
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building scalamavenexample 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- scala-maven-plugin:3.1.6:script (in1) @ scalamavenexample ---
hello
========================>MavenProject: com.jam:scalamavenexample:1.0-SNAPSHOT @ /home3/dwayne/tmp/scalamavenexample/pom.xml
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ scalamavenexample ---
[INFO] Deleting /home3/dwayne/tmp/scalamavenexample/target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.085s
[INFO] Finished at: Sun Mar 30 22:03:05 CEST 2014
[INFO] Final Memory: 10M/331M
[INFO] ------------------------------------------------------------------------
Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Why didn't the script execute?
The big problem with this is that this open the door to code injection (in ... Always make sure you ONLY execute static...
Read more >
Why won't my script execute?
The problem is due to the missing env variables. That's why it works from terminal. If I supply the full path for everything...
Read more >
Troubleshooting | Apps Script
To authorize the script, open the Script Editor and run any function. The authorization prompt appears so you can authorize the script ...
Read more >
Function doesn't execute in script
Function doesn't execute in script ... However, on the command line, when I type "./ShellScript.sh help", nothing happens. I've been trying to ...
Read more >
Bash-script as linux-service won't run, but executed from ...
The problem is that, when the script runs as a service, it does not run as "you": it does not have your environment....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found