-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathsetup-ws.xml
More file actions
158 lines (127 loc) · 5.85 KB
/
setup-ws.xml
File metadata and controls
158 lines (127 loc) · 5.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="default">
<property environment="env"/>
<path id="jython.classpath">
<fileset dir="${env.JYTHON_JAR_FOLDER_PATH}">
<include name="jython-standalone-2.7.4.jar" />
</fileset>
</path>
<target name="default">
<script language="jython" classpathref="jython.classpath">
<![CDATA[
import os
from java.io import File
from java.util import Hashtable
from java.time import LocalDateTime
# Eclipse imports
from org.eclipse.core.runtime import Platform, Path, IProgressMonitor, IStatus
from org.eclipse.core.resources import IResource, ResourcesPlugin
from org.eclipse.jdt.core import JavaCore
# Define a custom progress monitor that implements IProgressMonitor
class CustomProgressMonitor(IProgressMonitor):
def __init__(self):
self.estimatedTotal = 0
self.workedTotal = 0
self.blockedReason = None # This would be an IStatus object
def beginTask(self, name, totalWork):
print name
self.estimatedTotal = totalWork
self.workedTotal = 0
def setBlocked(self, reason): # reason is an IStatus
self.blockedReason = reason
if reason:
print "Blocked: {}".format(reason.toString()) # Or reason.getMessage() for just the message
else:
print "Blocked: (null reason)"
def clearBlocked(self):
if self.blockedReason is not None:
print "Clear Block: {}".format(self.blockedReason.toString()) # Or self.blockedReason.getMessage()
self.blockedReason = None
def done(self):
print "done"
def internalWorked(self, work):
# print "Internal worked: {}".format(work) # Original was just "..."
print "..."
def isCanceled(self):
return False
def setCanceled(self, value):
print "setCanceled: {}".format(value)
def setTaskName(self, name):
print "Task: {}".format(name)
def subTask(self, name):
print "Sub task: {}".format(name)
def worked(self, work):
self.workedTotal += work
print "Progress: {} of {}".format(self.workedTotal, self.estimatedTotal)
# --- Main script logic ---
# Accessing the workspace
try:
workspace = ResourcesPlugin.getWorkspace()
except Exception, e:
print "Fatal Error: Could not get workspace. Ensure Eclipse libraries are on classpath."
print str(e)
# Consider exiting if sys is imported: import sys; sys.exit(1)
raise # Re-raise to stop Ant script
print "" # Jython 2.x: print statement adds a newline
print "*** {} Import projects into workspace ***".format(LocalDateTime.now().toString())
print ""
# Get the idempiere source directory path from Ant project properties
idempiere_path_property = project.getProperty("idempiere")
if idempiere_path_property is None:
print "Warning: Ant property 'idempiere' is not set. Skipping project import."
else:
idempiereSrcDir = File(idempiere_path_property)
if idempiereSrcDir.exists() and idempiereSrcDir.isDirectory():
for item_name in os.listdir(idempiereSrcDir.getAbsolutePath()):
it_file = File(idempiereSrcDir, item_name) # File object for the item in idempiereSrcDir
if not it_file.isDirectory(): # We are looking for project directories
continue
fullPath = it_file.getAbsolutePath()
excluded_suffixes = [
"org.idempiere.javadoc", "ztl", "selenese", "doc", "fitnesse",
"migration", "event.test", "org.adempiere.report.jasper.fragment.test",
"utils_dev", "db", "org.adempiere.ui.zk.example"
]
if any(fullPath.endswith(suffix) for suffix in excluded_suffixes):
continue
projectFile = File(it_file, ".project") # .project file within the item directory
if not projectFile.exists():
continue
try:
projectDescription = workspace.loadProjectDescription(Path(projectFile.getAbsolutePath()))
project_name = projectDescription.getName()
print project_name # Print the name of the project being processed
eclipse_project = workspace.getRoot().getProject(project_name)
if not eclipse_project.isOpen():
# Last argument is IProgressMonitor, None is equivalent to null
eclipse_project.create(projectDescription, None)
eclipse_project.open(None)
else:
eclipse_project.refreshLocal(IResource.DEPTH_INFINITE, None)
except Exception, e:
print "Error processing project {}: {}".format(fullPath, str(e))
elif idempiere_path_property : # Only print if property was set but path is invalid
print "Source directory '{}' does not exist or is not a directory.".format(idempiere_path_property)
# Configure JavaCore options
try:
options = JavaCore.getOptions()
# Using JavaCore constants for versions is preferred if available and correct for your JDT version
# If JavaCore.VERSION_17 is not found, use the string "17"
options.put(JavaCore.COMPILER_COMPLIANCE, getattr(JavaCore, "VERSION_17", "17"))
options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, getattr(JavaCore, "VERSION_17", "17"))
options.put(JavaCore.COMPILER_SOURCE, getattr(JavaCore, "VERSION_17", "17"))
JavaCore.setOptions(options)
except Exception, e:
print "Error setting JavaCore options: {}".format(str(e))
print ""
print "*** {} Saving workspace after import ***".format(LocalDateTime.now().toString())
print ""
monitor_instance = CustomProgressMonitor()
try:
workspace.save(True, monitor_instance) # True for full save (wait for completion), monitor_instance for progress
except Exception, e:
print "Error saving workspace: {}".format(str(e))
]]>
</script>
</target>
</project>