Import module from different project in Overture - vdm++

When I import one module from another in Overture all is quite straightforward. However, I can't work out how to import a module from another project. What I do is:
create project P1
create module A in P1
create project P2
specify P1 as a reference in P2
create module B in P2
in module B import A
In module B the system flags the error 'No such module as A'.

I'm afraid there is no linking between projects in Overture currently, though you're right that this would be a sensible thing to have and would improve the modularity of specifications. So at the moment, all of your specification files have to live in the same project.

Related

Netbeans doesn't recognize imported package

I have 2 projects in netbeans, one of then import some classes of the other o should do it but when I try not get it to work.
Project 1 is called gprslibs and project 2 is called gprs, the project 2 import some some classes and packages of the projec 1. The problem is that netbeans doesn't reconize de package of the project 1.
I think that should be an easy problem but I don't find the answer.
Thanks for advance.
Seems like you want to import some packages and classes from Project1:gprslib into the project Project2:gprs
For this to work you will have to add the Project1:gprslib as a dependency in your Project2:gprs project
Step 1
Assuming you have two projects as mentioned above, gprslib and gprs. In your gprs project right click on the Libraries node and choose the Add Project.. option
Step 2
Select the gprslib project which you want to add as a dependency to your project
Step 3
After this step the packages and classes from gprslib project will become available to the gprs project even in the hints and help from NetBeans IDE.

MEF dependency questions

Simple example.
Application A has a class library C which is used through out.
Application A uses MEF to discover and load plug in modules P1 and P2 from a plug in directory. One assembly per plug in.
P1 and P2 both have a dependency on C (The class library).
The build process will ensure the version of C used by P1 is identical to the version referenced by A.
I assume that I won't end up with multiple copies of the same assembly loaded at once? By default I end up with a copy of C in the Plugin directory as well as A's application directory.
To ensure you don't end up with duplicate assemblies, you could change the Copy Local property to false of the contract (C) library in your plugin projects, that way on build, it won't be copied to the output directory.
You should be fine I think, as the CLR won't load the same assembly twice thanks to the Fusion loader rules - the first being to see if the target assembly is already loaded in the AppDomain. BUT, you have to be careful, because any code using Assembly.LoadFrom may result in exceptions occurring if it is actually finding that the assemblies have different locations on disk.

Netbeans RCP - duplicate third party jar in "clusters/modules/ext" folder

I have two Cluster in my Netbeans RCP project (Cluster A, and Cluster B).
Module M-A in Cluster A, has dependency to Module M-B in Cluster B. M-A ---> M-B
besides this, both modules (M-A and M-B) have dependency to a third party jar ( tp.jar ).
when i'm building my suite, I have tp.jar in 2 different places (two cluster) :
A/modules/ext/tp.jar and B/modules/ext/tp.jar
in consequence netbeans class loader finding 2 jar files in the class and is not able to load the any of them.
Any idea have to solve this issue ?
PS: I'm using Maven 2.X. and nbm plugin.
Regards,
Mohammad
You can create a wrapper module for your library (tp.jar) and let both modules depend on the wrapper module.
You can read more about it at http://wiki.netbeans.org/DevFaqWrapperModules

Importing from another project in pydev

I've been looking around for quite some time but I just can't find the answer. Similar questions relate to some tricky cases with third party libraries and all, but my situation seems to be textbook-simple. Nevertheless I can't figure out how this works.
I'm using Eclipse 3.5.2, Pydev 2.2.0, running on an Ubuntu 11.04 machine.
My case seems simple: I want to write a package as its own project, and then I want to write an application using this package in another project.
How should I setup pydev so that I can have this two projects "core" (the package) and "app" (which uses the core package), and from within "app" do:
import core
?
I have added core to the Project References of app but it doesn't do
anything.
I have added /core/ to the Source folders (I had to force for that because is was not
showing in the list), it didn't work (so I removed it).
I have added /full/path/to/core to the External Libraries, it still doesn't work.
By "doesn't work", I mean that I get an "unresolved import: core", always.
Ideas?
Provided you have 2 projects with the PYTHONPATH properly set (through source folders), it should work just adding a project reference.
Maybe an example can help...
E.g.:
project1
project1/src <-- this should be set as the source folder
project1/src/core
project1/src/core/__init__.py
project2
project2/src <-- this should be set as the source folder
project2/src/app
project2/src/app/__init__.py
and then edit the project2 properties > project references and select 'project1' to be able to access the project1 from the project2.
I had been in same problem for a while.
Now I figured it out how I can import class or function from module and package in other projects.
I found myself dumb from this because it is ever easy.
Conclusion!All you have to do is just to check the project name in 'Project References', File/Properties/Project References.
In terms of import usage, referencing other project is same as you put all files or modules in your current project directory.
I am using liclipse_1.0.0_win32.x86_64 on Windows 7.
Let's me show examples.
There are two project A and B and the project A has module a1.py and package 'M'.
You are working on B project and check reference A project in following project tree.
|-- A
| |-- M
| | |-- __init__.py
| | `-- m1.py
| `-- a1.py
`-- B
`-- b1.py
# a1.py
def say_a():
print "I'm A"
# m1.py
def say_m():
print "I'm M"
Now you can access project A like following.
#b1.py
import a1
from M import m1
a1.say_a()
m1.say_m()
In fact python import statement is little bit odd for me that you can find other way to do same thing.In addition, if you want to run b1.py from Linux command line see this.
~/tmp/pydemo/B$ PYTHONPATH=../A python b1.py
I did not get this working by adding a project reference. However, I got it working by first removing and then adding the pydev project nature to the project, and then, set the project reference.

Eclipse PDE: Package does not exist in this plug-in

We are developing an Eclipse plugin that is split into several Eclipse Projects. We want to export some of the classes that are defined in these external projects (via Export-Package in MANIFEST.MF). The problem is that Eclipse gives an error "Package xxx does not exist in this plug-in".
To give an example, let's assume that the plug-in is project P1 and this one uses some classes defined in a separate Eclipse project P2. We want to bundle P2 together with P1 and export some of the classes of P2 via the MANIFEST.MF of P1.
This works if I generate a jar file (P2.jar) and add this in the build path of P1, however it does not work if I simply add P2 as a dependency of P1.
Any suggestions what is the reason of the "Package xxx does not exist in this plug-in"?
Any suggestions how to get rid of it?
Adding the project P2 as dependency of P2 simply add the build classes of P2 (assuming P2 is a Java project) to the classpath of P1. This will allow P1 to compile but will result in wrong behavior at run-time.
Because your project P1 is a plugin project all its dependencies must be added ever through the dependencies tab of the manifest editor or through a jar file included as you mentioned.
So the only solution is to transform P2 project into plugin project and then let your P1 plugin depends on it. This kind of plugin only exporting code but not contributing anything to the ide are often referenced as library plugins. More and more java libraries are now delivered also in this way to let clients use them in Eclipse context (for example log4j).