Setting up a Rascal example project - rascal

How do I setup a Rascal-MPL project to consume the DSL built with Rascal?
I don't seem to find any resource that details how to solve that particular problem

The documentation hasn't been written for that case but here goes:
Use newRascalProject from util::Reflective to create a basic setup. For both the DSL project and the consuming project that makes sense.
mvn install in the DSL project, if you won't have the DSL project folder open in Eclipse or VScode or if you are working bare bones Unix/Maven.
In RASCAL.MF of the client project add Require-Libraries: |lib://dsl-project|
In pom.xml of the client project add a dependency on the DSL jar.
Restart the console or terminal for a file of the client project.
In the terminal the active version of the path configuration for the interpreter will be printed. It should have the DSL project in the list of srcs.
In VScode log for the Rascal LSP you can see the path configuration printed when compiling/checking source files in the client project. There the DSL project should be in the libs path.
If the DSL project isn't compiled to .tpl files that appear in the target folder and eventually in the jar, you will get spurious error messages in the client code. In that case trigger the compiler in the DSL project by saving the top module, or run mvn install again. Revisit the pom file for the settings of the rascal-maven-plugin

For those landing at this page and trying to find an example of calling newRascalProject with working parameters...
The first parameter is a 'location'. While it is documented how to use this parameter (https://www.rascal-mpl.org/docs/Rascal/Expressions/Values/Location/), it still took my some time to figure out that a location is not a regular string, and not using double quotes " but |.
So if you try:
newRascalProject ("home:///Projects/rascal_playground", "hello2")
You get the following error:
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/UndeclaredVariable/UndeclaredVariable.html|
Including the variable name for the 2nd parameter...
newRascalProject ("home:///Projects/rascal_playground", name="hello")
... gives the same error.
This is the correct example:
newRascalProject (|home:///Projects/rascal_playground|, name="hello")

Related

F# Ionide - FAKE build "The system cannot find the path specified"

I am working with F# on Windows with the Ionide plug-in. I can create a new F# project and load one of the example templates, e.g. "fslabjournal" or a class library.
Working in the script files seems fine, and everything in the default scripts works as expected. However, I cannot work out how to build anything. I would have thought that trying "FAKE: build" and choosing the "Clean" option would get me started, but all I get is a "The system cannot find the path specified." message.
Is this what I should expect to see when building default templates? Is there more setup to be done to these before a build can happen?

Why is org-netbeans-modules-java-j2seproject-copylibstask.jar required failed ant build

When doing an ant build (thought jenkins) for a test project, I get the below error. As this test project will be deployed in tomcat why does the build require a netbeans specific module
Obviously I can add the jar file to a path in jenkins and then continue the build, but want to know why it needs a netbeans specific jar?
Is it because the project setup in Netbeans is wrong?
Thanks in advance.
Tony
======Error below here =========
var/lib/jenkins/workspace/DeployTest2/nbproject/build-impl.xml:797: The libs.CopyLibs.classpath property is not set up.
This property must point to
org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part
of NetBeans IDE installation and is usually located at
/java/ant/extra folder.
Either open the project in the IDE and make sure CopyLibs library
exists or setup the property manually. For example like this:
ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar

is sonar multi-module broken?

trying to make a multi module project I dowloaded the samples in github: I use this folder
https://github.com/SonarSource/sonar-examples/tree/master/projects/multi-module/sonar-runner/java-sonar-runner-modules-own-configuration-file as a project base dir
In a command line in this folder, I type /opt/sonar-runner/bin/sonnar-runner
First thing I find is that sonar-project.properties has a property named sonar.sources=src, but executing throws
Exception in thread "main" org.sonar.runner.RunnerException: You must define mandatory properties: sources
Then I correct this property with sources=src and runner execution finish, adds the project to my sonar server, but no code, modules or file is detected. It is like if all project is empty.
It is exactly the same with other examples and with my own project. No matter if is java, python...
Any help is welcome
You are using an old version of Sonar Runner and/or Sonar. Please update to the latest versions (Sonar Runner 2.2 and Sonar 3.5.1).

Blackberry 5.0 - Add reference to a Java Library Project

It seems to me that what I'm trying to achieve is incredibly simple, yet is becoming incredibly painful.
I have ProjectA which is a BlackBerry Application project. I have ProjectB which is a Java library project. I want to refer to ProjectB from ProjectA. I can add a reference but when I run ProjectA, it doesn't work. I have source code for both the projects and both are compiled using Java compiler 1.4
I have tried multiple things but everything fails for some reason:
1. pre-verify.exe on ProjectB
It fails with an error "JAR file creation failed with error -1" I can see that the cod and jar files have been created but when add the jar file to ProjectA and run it, it doesn't work. Not sure if I need to add the .cod file.
2. Create new BlackBerry Library Project and reference it in ProjectA
I create a new project ProjectC and then add the jar of ProjectB to it. Then I add a reference to ProjectC in ProjectA. But I cant import classes from ProjectB
Pls suggest a way out.
I'm using Eclipse Plug-in and relying on Eclipse's build capabilities
Figured out answer myself. Publishing here in case someone stumbles upon this. Here are the steps:
Create your library and export as JAR (or download the 3rd party JAR)
Run preverify.exe on the JAR
preverify.exe -verbose -classpath "C:/Program Files/Research In Motion/BlackBerry JDE 5.0.0/lib/net_rim_api.jar" jarname.jar
If you are lucky, you won't run into any issues and you will be done. But I wasn't lucky enough. I got the below error
Error: No such file or directory. JAR file creation failed with error -1
There are two possible causes of this:
jar.exe is not added to your PATH. If so, add it (found in your JAVA
installation directory) to PATH
cvfm or -cfm option on jar.exe fails to execute. I'm not aware of the reason but the way to fix this is to use -cf option, point to the .class files but don't use the manifest file. here is an
example:
"C:\Program Files\Java\jdk1.6.0_26\bin\jar.exe" -cf "output\json-1.0.jar" tmp12996/
tmp12996 contains the preverified .class files.
You may run into different issues other than the one I've listed above.
Once jar is created from above step, make sure that it's structure is as you anticipate. One way to check is to rename the .jar to .zip, unzip it and then check it. If it is not as you need, you can change the structure and then repack it (I wouldn't do any major changes though)
Then add this newly built jar to your BlackBerry application as a reference i.e. add to Java Build Path in your eclipse and Check it in Order and Export window.
That's it! You are good to go! Run you app!
You may face error indicating that the module contains verification errors when you try to run in the simulator. One possible cause of this issue is that your library (the original JAR) contains APIs that are not compatible with J2ME or BB JRE. You may not get a compiler error when you build your library independently as it is compiled against Java 1.4 (or whatever your version is). Best to figure the issue out is to move all your code into your BB App project and then build it. That will tell you all the issues upfront. You make the changes as required and then move the code back to the library. If you don't have source code for the library you are using (like a 3rd party library), you may be out of luck! Also remember that there could be other issues than what I've hit upon and solved.
I'm documenting this at length as it has taken an awful amount of time for me to figure all this out; and to say the least, was most frustrating!
I found another solution. If you get error -1 while preverifying your JAR file, just run your library application once. Because if you don't run the application, the deliverables folder will be empty. Make sure this folder is not empty.

Problem with dependencies using Ant from the shell

I'm having problems building my project, using an Ant script, from the command prompt using Ant itself. It can't find a certain import for a particular Java file in my project (which has nearly 5,000 source files as it is). The import is included in a .jar package whose location I have set in the Ant file itself. (As a pathelement, along with other needed JARs that either are fine, or haven't tried to been used when the crash occurs). The crash happens with javac, with the simple message of "import etc.ect.* cannot be found at line etc" Oddly enough, I can build the project just fine from the Ant file using an IDE like Eclipse. Any ideas what could be wrong? Thanks!
Wow, the solution was completely unrelated. It was a dumb fault in the java code where the class was trying to import .* from a directory that only had folders in it. For some reason, Eclipse didn't seem to mind, but javac did!
Eclipse's root classloader contains a lot of classes, when you run ant from console there's much less.
Just tell javac task to use the required .jar, and you'll be fine.
You should post the stack trace, does it say "import required by ..."? ( I forget the exact text). Likely there's a jar that's available in your eclipse environment that is not included in your ant script. Look in the stack trace for the missing class to identify the jar that's not being included in your build.

Resources