Bug 386579 - [Java-Kdm] IllegalArgumentException when discovering from multiple projects in "ELEMENTS_TO_ANALYZE"
Summary: [Java-Kdm] IllegalArgumentException when discovering from multiple projects i...
Status: NEW
Alias: None
Product: MoDisco
Classification: Modeling
Component: Technologies (show other bugs)
Version: 0.10.0   Edit
Hardware: PC Windows XP
: P5 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-03 10:56 EDT by Fabien Giquel CLA
Modified: 2015-01-15 08:19 EST (History)
4 users (show)

See Also:


Attachments
stack trace (2.25 KB, text/plain)
2012-08-03 10:57 EDT, Fabien Giquel CLA
gdupe: iplog-
Details
Patch make the Java and SourceModel Discoverer working for multiple projects (11.40 KB, patch)
2013-08-16 04:34 EDT, Benjamin Klatt CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fabien Giquel CLA 2012-08-03 10:56:46 EDT
The issue is always reproducible, both with Juno and Indigo releases, with any Java projet A which references one Java project B in workspace.

Choose "Discovery....->Discover Java and Inventory Model..."
Choose in ELEMENTS_TO_ANALYZE, the prject A and also the project B.

--> IAE "No Null constraint violated".

I join the stacktrace
Comment 1 Fabien Giquel CLA 2012-08-03 10:57:40 EDT
Created attachment 219537 [details]
stack trace
Comment 2 Fabien Giquel CLA 2012-08-06 03:49:30 EDT
Looking at code reveal that the "kdm inventory model" discovery works on java project selection but does not create elements for referenced java projects selected in ELEMENTS_TO_ANALYZE. The generic "AbstractComposedKDMSourceDiscoverer2.discoverKDMSourceModel" method may be specialized.
Comment 3 Benjamin Klatt CLA 2012-12-19 11:34:43 EST
Hi Gregoire,

I noticed that your have reduced the priority for this issue. Is there a reason for this? 

Cheers
Benjamin
Comment 4 Gregoire Dupe CLA 2012-12-20 06:47:57 EST
(In reply to comment #3)

Yes, that means that we may not have enough time to solve this bug before the release of Kepler.

Regards,
Grégoire
Comment 5 Benjamin Klatt CLA 2013-08-16 04:34:32 EDT
Created attachment 234474 [details]
Patch make the Java and SourceModel Discoverer working for multiple projects

I have investigated into this issue and found a solution to make this working.

The patch includes the required modification. 

# The source of the issues was: 
Only the main JavaProject is discovered not any configured additional "elements to analyze".
As a result only InventoryContainer (Project) exists in the InventoryModel (SourceModel)
An the weaving process combining Java and Source Model assumed only one InventoryContainer and was not able to handle multiple.

# The solution:
## Plugin: org.eclipse.modisco.kdm.source.extension

- AbstractComposedKDMSourceDiscoverer2
new method handleDiscoveredSourceModel() to save a new SourceModel or merge the newly discovered with an existing one

## Plugin: org.eclipse.modisco.java.composition.discoverer

- DiscoverKDMSourceAndJavaModelFromJavaProject & DiscoverKDMSourceAndJavaModelFromProject
finishBuildingModel() overridden to first discover the KDM SourceModel for the additional elements to analyze 
before calling the super.finishBuildingModel() of the AbstractDiscoverKDMSourceAndJavaModel<T>
This has to be done in the type specific discoverers and can not be implemented on the abstract type T due to required type checks (instanceof IProject / instanceof IJavaProject).

- AbstractDiscoverKDMSourceAndJavaModel<T>
switched class member container from single InventoryContainer to Set<InventoryContainer>
modified getKDMProjectForWeaving to return a Set<InventoryContainer> and to fill all InventoryContainers from the Inventory model into it.
Also the invocations of this method (in weaveCompilationUnit(), weaveArchiveFile(), and manageJava2DirectoryCreation()) have been adapted to process all returned InventoryContainers
Comment 6 Niels Brouwers CLA 2015-01-15 08:19:03 EST
I am running into the same problem. Unfortunately, the code has meanwhile changed that much that I am not able within the time I have to figure out how to apply the provided patch manually.

Any idea if this bug will be fixed? Tested on Eclipse Luna SR1 (installed using install Modeling components wizard).