Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 353975

Summary: Create workspacestate.properties also when target folder does not exist
Product: z_Archived Reporter: Karsten Thoms <karsten.thoms>
Component: m2eAssignee: Project Inbox <m2e.core-inbox>
Status: CLOSED INVALID QA Contact:
Severity: enhancement    
Priority: P3 CC: igor
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Karsten Thoms CLA 2011-08-05 04:17:02 EDT
We are using the “Resolve Workspace Artifacts” run configuration option in our code generation process, in order to process the workspacestate.properties file.
We need this because we want to generate the classes only for open projects (We cannot use the workbench state file from Eclipse, because this is updated only at closing of the workbench and not at opening/closing of a project).
Because we are using this information at generation time, it can happen  that the target folder doesn’t exist yet. This is where we had to patch the m2e plugin, because the output location is verified that it is not null and it exists.
 
WorkspaceStateWriter:
 
======================================================================
Old code (outputLocation is null if the target folder does not exist):
======================================================================
IResource outputLocation = root.findMember(projectFacade.getOutputLocation());
          if (!"pom".equals(artifact.getType()) && outputLocation != null && outputLocation.exists()) {
            String key = artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getType() + ":" + artifact.getBaseVersion();
            state.put(key, outputLocation.getLocation().toFile().getCanonicalPath());
          }
 
======================================================================
New code:
======================================================================
IPath outputLocation = projectFacade.getOutputLocation();
          if (outputLocation != null) {
            if (!"pom".equals(artifact.getType())) {
              String key = artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getType() + ":" + artifact.getBaseVersion();
              String outputFile = new File(root.getLocation().toFile().getCanonicalPath() + outputLocation).getCanonicalPath();
              state.put(key, outputFile);
            }
 
Could this be added as a feature in m2e?
Comment 1 Igor Fedorenko CLA 2011-08-05 06:15:42 EDT
To make sure I understand the usecase correctly, you launch your code generation code in a separate jvm and from that jvm you want to use workspacestate.properties to find opened workspace projects. Did I get this right? 

Also, does your code generation run in Maven runtime and use maven artifact resolution logic?
Comment 2 Igor Fedorenko CLA 2012-05-21 10:59:06 EDT
Closing old/stale bugreports.
Comment 3 Denis Roy CLA 2021-04-19 13:24:42 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/