This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 152960
Collapse All | Expand All

(-)a/apisupport.harness/nbproject/project.properties (+2 lines)
Lines 70-75 Link Here
70
    org/netbeans/nbbuild/Branding*.class,\
70
    org/netbeans/nbbuild/Branding*.class,\
71
    org/netbeans/nbbuild/CreateModuleXML*.class,\
71
    org/netbeans/nbbuild/CreateModuleXML*.class,\
72
    org/netbeans/nbbuild/CustomJavac*.class,\
72
    org/netbeans/nbbuild/CustomJavac*.class,\
73
    org/netbeans/nbbuild/ConvertClusterPath*.class,\
73
    org/netbeans/nbbuild/FixDependencies*.class,\
74
    org/netbeans/nbbuild/FixDependencies*.class,\
74
    org/netbeans/nbbuild/FixTestDependencies*.class,\
75
    org/netbeans/nbbuild/FixTestDependencies*.class,\
75
    org/netbeans/nbbuild/JHIndexer*.class,\
76
    org/netbeans/nbbuild/JHIndexer*.class,\
Lines 86-91 Link Here
86
    org/netbeans/nbbuild/ModuleSelector*.class,\
87
    org/netbeans/nbbuild/ModuleSelector*.class,\
87
    org/netbeans/nbbuild/ModuleTracking*.class,\
88
    org/netbeans/nbbuild/ModuleTracking*.class,\
88
    org/netbeans/nbbuild/ParseProjectXml*.class,\
89
    org/netbeans/nbbuild/ParseProjectXml*.class,\
90
    org/netbeans/nbbuild/PathFileSet*.class,\
89
    org/netbeans/nbbuild/ShorterPaths*.class,\
91
    org/netbeans/nbbuild/ShorterPaths*.class,\
90
    org/netbeans/nbbuild/SortSuiteModules*.class,\
92
    org/netbeans/nbbuild/SortSuiteModules*.class,\
91
    org/netbeans/nbbuild/UpdateTracking*.class,\
93
    org/netbeans/nbbuild/UpdateTracking*.class,\
(-)a/apisupport.harness/release/build.xml (-7 / +61 lines)
Lines 48-58 Link Here
48
    <target name="taskdefs" unless="harness.taskdefs.done">
48
    <target name="taskdefs" unless="harness.taskdefs.done">
49
        <dirname property="harness.dir" file="${harness.file}"/>
49
        <dirname property="harness.dir" file="${harness.file}"/>
50
        <taskdef classpath="${harness.dir}/tasks.jar" resource="org/netbeans/nbbuild/taskdefs.properties"/>
50
        <taskdef classpath="${harness.dir}/tasks.jar" resource="org/netbeans/nbbuild/taskdefs.properties"/>
51
        <typedef name="pathfileset" classname="org.netbeans.nbbuild.PathFileSet"
52
                 classpath="${harness.dir}/tasks.jar"/>
51
        <property name="harness.taskdefs.done" value="true"/>
53
        <property name="harness.taskdefs.done" value="true"/>
52
    </target>
54
    </target>
53
55
54
    <target name="common-init" depends="taskdefs">
56
    <target name="-convert-old-project" unless="cluster.path.evaluated">
57
        <fail unless="netbeans.dest.dir" message="Either 'cluster.path.evaluated' or 'netbeans.dest.dir' property must be set."/>
58
59
        <pathconvert property="old.project.update.tracking">
60
            <fileset dir="${netbeans.dest.dir}" includes="**/update_tracking/*.xml"/>
61
        </pathconvert>
62
63
        <selector id="old.project.included.files">
64
            <custom classpath="${harness.dir}/tasks.jar" classname="org.netbeans.nbbuild.ModuleSelector">
65
                <param name="excludeModules" value="${disabled.modules}"/>
66
                <!-- XXX inc/exc clusters -->
67
                <param name="includeClusters" value="${enabled.clusters}"/>
68
                <param name="excludeClusters" value="${disabled.clusters}"/>
69
                <param name="updateTrackingFiles" value="${old.project.update.tracking}"/>
70
            </custom>
71
        </selector>
72
73
        <pathconvert property="old.project.clusters.duplicates" pathsep="&#10;">
74
            <fileset dir="${netbeans.dest.dir}">
75
                <selector refid="old.project.included.files"/>
76
            </fileset>
77
            <chainedmapper>
78
                <mapper type="regexp" from="(^.+)[/\\]config[/\\]Modules[/\\]" to="\1"/> <!-- #71849 -->
79
                <filtermapper>
80
                    <linecontainsregexp negate="true">
81
                        <regexp pattern="update[/\\]backup[/\\]netbeans[/\\]?$"/>
82
                    </linecontainsregexp>
83
                </filtermapper>
84
            </chainedmapper>
85
        </pathconvert>
86
        <tempfile property="old.project.clusters.duplicates.file" destdir="${basedir}/build" deleteonexit="true"/>
87
        <mkdir dir="${basedir}/build"/>
88
        <echo file="${old.project.clusters.duplicates.file}" message="${old.project.clusters.duplicates}"/>
89
90
        <pathconvert property="cluster.path.evaluated">
91
            <union id="old.project.clusters"> <!-- union removes duplicates -->
92
                <files includesfile="${old.project.clusters.duplicates.file}"/>
93
            </union>
94
        </pathconvert>
95
    </target>
96
97
    <target name="common-init" depends="taskdefs,-convert-old-project">
55
        <property name="netbeans.javadoc.dir" location="build/javadoc"/>
98
        <property name="netbeans.javadoc.dir" location="build/javadoc"/>
99
        <condition property="cluster.path.basedir" value="${suite.dir}" else="${basedir}">
100
            <isset property="suite.dir"/>
101
        </condition>
102
        <convertclusterpath from="${cluster.path.evaluated}" to="cluster.path" id="cluster.path.id" basedir="${cluster.path.basedir}"/>
56
    </target>
103
    </target>
57
104
58
    <target name="basic-init" depends="projectized-common.basic-init">
105
    <target name="basic-init" depends="projectized-common.basic-init">
Lines 152-160 Link Here
152
        <path id="test.unit.lib.cp">
199
        <path id="test.unit.lib.cp">
153
            <pathelement path="${test.unit.lib.cp}"/> <!-- for manual override -->
200
            <pathelement path="${test.unit.lib.cp}"/> <!-- for manual override -->
154
            <!-- As a fallback for old platforms which do not include the right modules: -->
201
            <!-- As a fallback for old platforms which do not include the right modules: -->
155
            <fileset dir="${netbeans.dest.dir}">
202
            <pathfileset include="modules/ext/junit-*.jar">
156
                <include name="*/modules/ext/junit-*.jar"/>
203
                <path refid="cluster.path.id"/>
157
            </fileset>
204
            </pathfileset>
158
            <fileset dir="${netbeans.home}/..">
205
            <fileset dir="${netbeans.home}/..">
159
                <include name="*/modules/ext/junit-*.jar"/>
206
                <include name="*/modules/ext/junit-*.jar"/>
160
            </fileset>
207
            </fileset>
Lines 201-220 Link Here
201
    </target>
248
    </target>
202
249
203
    <target name="run" depends="netbeans">
250
    <target name="run" depends="netbeans">
204
        <ant antfile="${harness.dir}/run.xml" target="run"/>
251
        <ant antfile="${harness.dir}/run.xml" target="run">
252
            <reference refid="cluster.path.id"/>
253
        </ant>
205
    </target>
254
    </target>
206
255
207
    <target name="profile" depends="netbeans,-jdk-presetdef-nbprofiledirect">
256
    <target name="profile" depends="netbeans,-jdk-presetdef-nbprofiledirect">
208
        <ant antfile="${harness.dir}/run.xml" target="profile"/>
257
        <ant antfile="${harness.dir}/run.xml" target="profile">
258
            <reference refid="cluster.path.id"/>
259
        </ant>
209
    </target>
260
    </target>
210
261
211
    <target name="debug" depends="netbeans,-jdk-presetdef-nbjpdastart">
262
    <target name="debug" depends="netbeans,-jdk-presetdef-nbjpdastart">
212
        <ant antfile="${harness.dir}/run.xml" target="debug"/>
263
        <ant antfile="${harness.dir}/run.xml" target="debug">
264
            <reference refid="cluster.path.id"/>
265
        </ant>
213
    </target>
266
    </target>
214
267
215
    <target name="reload" depends="netbeans">
268
    <target name="reload" depends="netbeans">
216
        <ant antfile="${harness.dir}/run.xml" target="run">
269
        <ant antfile="${harness.dir}/run.xml" target="run">
217
            <property name="run.args" value='--reload "${cluster}/${module.jar}"'/>
270
            <property name="run.args" value='--reload "${cluster}/${module.jar}"'/>
271
            <reference refid="cluster.path.id"/>
218
        </ant>
272
        </ant>
219
    </target>
273
    </target>
220
274
(-)a/apisupport.harness/release/jnlp.xml (-11 / +14 lines)
Lines 110-121 Link Here
110
        <property name="enabled.clusters" value=""/>
110
        <property name="enabled.clusters" value=""/>
111
        <property name="disabled.clusters" value=""/>
111
        <property name="disabled.clusters" value=""/>
112
        
112
        
113
        <fileset id="jnlp.included.modules" dir="${netbeans.dest.dir}">
113
        <pathfileset id="jnlp.included.modules" >
114
            <path refid="cluster.path.id"/>
114
            <and>
115
            <and>
115
                <or>
116
                <or>
116
                    <filename name="*/modules/**/*.jar"/>
117
                    <filename name="modules/**/*.jar"/>
117
                    <filename name="*/lib/**/*.jar"/>
118
                    <filename name="lib/**/*.jar"/>
118
                    <filename name="*/core/**/*.jar"/>
119
                    <filename name="core/**/*.jar"/>
119
                </or>
120
                </or>
120
                <not>
121
                <not>
121
                    <filename name="**/update/**/*.jar"/>
122
                    <filename name="**/update/**/*.jar"/>
Lines 126-132 Link Here
126
                    <param name="excludeClusters" value="${disabled.clusters}"/>
127
                    <param name="excludeClusters" value="${disabled.clusters}"/>
127
                </custom>
128
                </custom>
128
            </and>
129
            </and>
129
        </fileset>
130
        </pathfileset>
130
        <property name="jnlp.sign.jars" value="true"/>
131
        <property name="jnlp.sign.jars" value="true"/>
131
        <property name="jnlp.signjar.keystore" location="build/default.keystore"/>
132
        <property name="jnlp.signjar.keystore" location="build/default.keystore"/>
132
        <property name="jnlp.signjar.alias" value="jnlp"/>
133
        <property name="jnlp.signjar.alias" value="jnlp"/>
Lines 167-177 Link Here
167
            dir="${jnlp.dest.dir}/netbeans/"
168
            dir="${jnlp.dest.dir}/netbeans/"
168
            codebase="${jnlp.platform.codebase.own}"
169
            codebase="${jnlp.platform.codebase.own}"
169
            verify="true"
170
            verify="true"
170
            verifyexcludes="lib/nbexec.cmd,lib/nbexec,lib/nbexec.exe,core/ide.ks,LICENSE.txt,DISTRIBUTION.txt,THIRDPARTYLICENSEREADME.txt,docs/swing-layout-1.0-doc.zip,docs/swing-layout-1.0.1-doc.zip,docs/html40.zip,core/org-netbeans-modules-utilities-cli.jar,docs/org/netbeans/modules/usersguide/ide.css,docs/swing-layout-1.0.2-doc.zip,docs/swing-layout-1.0.2-src.zip,docs/swing-layout-1.0.3-doc.zip,docs/swing-layout-1.0.3-src.zip"
171
            verifyexcludes="lib/nbexec.cmd,lib/nbexec,lib/nbexec.exe,lib/nbexec.dll,core/ide.ks,LICENSE.txt,DISTRIBUTION.txt,THIRDPARTYLICENSEREADME.txt,docs/swing-layout-1.0-doc.zip,docs/swing-layout-1.0.1-doc.zip,docs/html40.zip,core/org-netbeans-modules-utilities-cli.jar,docs/org/netbeans/modules/usersguide/ide.css,docs/swing-layout-1.0.2-doc.zip,docs/swing-layout-1.0.2-src.zip,docs/swing-layout-1.0.3-doc.zip,docs/swing-layout-1.0.3-src.zip"
171
            permissions="${jnlp.permissions}"
172
            permissions="${jnlp.permissions}"
172
            signjars="${jnlp.sign.jars}"
173
            signjars="${jnlp.sign.jars}"
173
        >
174
        >
174
            <modules refid="jnlp.included.modules"/>
175
            <resources refid="jnlp.included.modules"/>
175
        </makejnlp>
176
        </makejnlp>
176
    </target>
177
    </target>
177
178
Lines 193-199 Link Here
193
            dir="${jnlp.master.dir}"
194
            dir="${jnlp.master.dir}"
194
            codebase="${jnlp.platform.codebase}"
195
            codebase="${jnlp.platform.codebase}"
195
        >
196
        >
196
            <modules refid="jnlp.included.modules"/>
197
            <resources refid="jnlp.included.modules"/>
197
        </makemasterjnlp>
198
        </makemasterjnlp>
198
    </target>
199
    </target>
199
    
200
    
Lines 413-421 Link Here
413
        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
414
        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
414
        <nbjpdastart name="NetBeans" addressproperty="debug.port" transport="dt_socket">
415
        <nbjpdastart name="NetBeans" addressproperty="debug.port" transport="dt_socket">
415
            <classpath>
416
            <classpath>
416
                <fileset dir="${netbeans.dest.dir}">
417
                <pathfileset>
417
                    <include name="**/*.jar"/>
418
                    <path refid="cluster.path.id"/>
418
                </fileset>
419
                    <filename name="**/*.jar"/>
420
                </pathfileset>
419
                <fileset dir="${cluster}">
421
                <fileset dir="${cluster}">
420
                    <include name="**/*.jar"/>
422
                    <include name="**/*.jar"/>
421
                </fileset>
423
                </fileset>
Lines 425-430 Link Here
425
        <property name="debug.args" value="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,suspend=${debug.pause},server=n,address=${debug.port}"/>
427
        <property name="debug.args" value="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,suspend=${debug.pause},server=n,address=${debug.port}"/>
426
        <antcall target="run">
428
        <antcall target="run">
427
            <param name="run.args" value="${debug.args}"/>
429
            <param name="run.args" value="${debug.args}"/>
430
            <reference refid="cluster.path.id"/>
428
        </antcall>
431
        </antcall>
429
    </target>
432
    </target>
430
433
(-)a/apisupport.harness/release/run.xml (-38 / +24 lines)
Lines 44-58 Link Here
44
44
45
    <target name="-init">
45
    <target name="-init">
46
        <property name="run.jdkhome" location="${nbjdk.home}"/>
46
        <property name="run.jdkhome" location="${nbjdk.home}"/>
47
        <condition property="test.user.dir" value="${suite.dir}/build/testuserdir">
47
        <condition property="test.user.dir" value="${suite.dir}/build/testuserdir" else="build/testuserdir">
48
            <isset property="suite.dir"/>
48
            <isset property="suite.dir"/>
49
        </condition>
49
        </condition>
50
        <property name="test.user.dir" location="build/testuserdir"/>
50
        <property name="suite.dir" location="${basedir}"/>
51
        <property name="install" location="${netbeans.dest.dir}"/>
52
        <property name="run.args.common" value='--userdir "${test.user.dir}" -J-Dnetbeans.logger.console=true -J-ea'/>
51
        <property name="run.args.common" value='--userdir "${test.user.dir}" -J-Dnetbeans.logger.console=true -J-ea'/>
53
        <!-- In case run from a suite module, to get app.name and/or branding.token: -->
52
        <!-- In case run from a suite module, to get app.name and/or branding.token: -->
53
        <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
54
        <property file="${suite.dir}/nbproject/platform.properties"/>
54
        <property file="${suite.dir}/nbproject/private/private.properties"/>
55
        <property file="${suite.dir}/nbproject/private/private.properties"/>
55
        <property file="${suite.dir}/nbproject/project.properties"/>
56
        <property file="${suite.dir}/nbproject/project.properties"/>
57
        <!-- CP with id="cluster.path.id" is expected to be passed as parameter to run.xml -->
58
        <pathconvert property="install">
59
            <path refid="cluster.path.id"/>
60
            <regexpmapper from="(.*)platform[0-9]*$$" to="\1"/>
61
        </pathconvert>
56
        <!-- use nb.exe if exists (old platform), netbeans.exe otherwise -->
62
        <!-- use nb.exe if exists (old platform), netbeans.exe otherwise -->
57
        <condition property="run.app.exe" value="bin\nb.exe" else="bin\netbeans.exe">
63
        <condition property="run.app.exe" value="bin\nb.exe" else="bin\netbeans.exe">
58
            <available file="${install}\bin\nb.exe"/>
64
            <available file="${install}\bin\nb.exe"/>
Lines 91-135 Link Here
91
        <property name="run.sh" location="${run.sh.candidate}"/>
97
        <property name="run.sh" location="${run.sh.candidate}"/>
92
        <mkdir dir="${test.user.dir}/etc"/>
98
        <mkdir dir="${test.user.dir}/etc"/>
93
        <echo file="${test.user.dir}/etc/netbeans.conf">netbeans_extraclusters="${cluster}"</echo>
99
        <echo file="${test.user.dir}/etc/netbeans.conf">netbeans_extraclusters="${cluster}"</echo>
94
        <property name="run.args.prepared" value=""/>
100
        <property name="run.args.prepared" value=''/>
95
    </target>
101
    </target>
96
102
97
    <target name="-prepare-as-platform" depends="-init" if="app.name">
103
    <target name="-prepare-as-platform" depends="-init" if="app.name">
98
        <property name="disabled.modules" value=""/>
104
        <property name="disabled.modules" value=""/>
99
        <property name="enabled.clusters" value=""/>
105
        <fail message="Platform cluster is not present in cluster.path: '${cluster.path}'">
100
        <property name="disabled.clusters" value=""/>
101
        <pathconvert property="run.platform.update.tracking">
102
            <path>
103
                <fileset dir="${netbeans.dest.dir}">
104
                    <include name="**/update_tracking/*.xml"/>
105
                </fileset>
106
            </path>
107
        </pathconvert>
108
        <pathconvert property="run.platform.clusters.duplicates" pathsep=",">
109
            <path>
110
                <fileset dir="${netbeans.dest.dir}">
111
                    <selector>
112
                        <custom classpath="${harness.dir}/tasks.jar" classname="org.netbeans.nbbuild.ModuleSelector">
113
                            <param name="excludeModules" value="${disabled.modules}"/>
114
                            <param name="includeClusters" value="${enabled.clusters}"/>
115
                            <param name="excludeClusters" value="${disabled.clusters}"/>
116
                            <param name="updateTrackingFiles" value="${run.platform.update.tracking}"/>
117
                        </custom>
118
                    </selector>
119
                </fileset>
120
            </path>
121
            <mapper type="regexp" from="[/\\]([^/\\]+)[/\\](config[/\\]Modules|update_tracking)[/\\]" to="\1"/> <!-- #71849, #73494 -->
122
        </pathconvert>
123
        <fail message="Must have at least one cluster from the platform">
124
            <!-- Otherwise ${run.platform.clusters} gets filled with nonsense. -->
125
            <condition>
106
            <condition>
126
                <equals arg1="${run.platform.clusters.duplicates}" arg2=""/>
107
                <not>
108
                    <matches string="${cluster.path}" pattern="[\\/]platform[0-9]*([;:]|$)"/>
109
                </not>
127
            </condition>
110
            </condition>
128
        </fail>
111
        </fail>
129
        <pathconvert property="run.platform.clusters">
112
        <pathconvert property="run.platform.clusters">
130
            <path>
113
            <path>
131
                <pathelement location="${cluster}"/>
114
                <pathelement location="${cluster}"/>
132
                <dirset dir="${netbeans.dest.dir}" includes="${run.platform.clusters.duplicates}" excludes="platform*"/>
115
                <!-- Does not exclude clusters in which all modules are excluded, shouldn't be a problem -->
116
                <path refid="cluster.path.id"/>
133
            </path>
117
            </path>
134
        </pathconvert>
118
        </pathconvert>
135
        <pathconvert property="run.exe">
119
        <pathconvert property="run.exe">
Lines 186-194 Link Here
186
        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
170
        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
187
        <nbjpdastart name="NetBeans" addressproperty="debug.port" transport="dt_socket">
171
        <nbjpdastart name="NetBeans" addressproperty="debug.port" transport="dt_socket">
188
            <classpath>
172
            <classpath>
189
                <fileset dir="${netbeans.dest.dir}">
173
                <pathfileset include="**/*.jar">
190
                    <include name="**/*.jar"/>
174
                    <path refid="cluster.path.id"/>
191
                </fileset>
175
                </pathfileset>
192
                <fileset dir="${cluster}">
176
                <fileset dir="${cluster}">
193
                    <include name="**/*.jar"/>
177
                    <include name="**/*.jar"/>
194
                </fileset>
178
                </fileset>
Lines 198-203 Link Here
198
        <property name="debug.args" value="-J-Xdebug -J-Xnoagent -J-Xrunjdwp:transport=dt_socket,suspend=${debug.pause},server=n,address=${debug.port}"/>
182
        <property name="debug.args" value="-J-Xdebug -J-Xnoagent -J-Xrunjdwp:transport=dt_socket,suspend=${debug.pause},server=n,address=${debug.port}"/>
199
        <antcall target="run">
183
        <antcall target="run">
200
            <param name="run.args" value="${debug.args}"/>
184
            <param name="run.args" value="${debug.args}"/>
185
            <reference refid="cluster.path.id"/>
201
        </antcall>
186
        </antcall>
202
    </target>
187
    </target>
203
    
188
    
Lines 209-217 Link Here
209
            mainclass="org.netbeans.Main"
194
            mainclass="org.netbeans.Main"
210
        >
195
        >
211
            <classpath>
196
            <classpath>
212
                <fileset dir="${netbeans.dest.dir}">
197
                <pathfileset include="**/*.jar">
213
                    <include name="**/*.jar"/>
198
                    <path refid="cluster.path.id"/>
214
                </fileset>
199
                </pathfileset>
215
                <fileset dir="${cluster}">
200
                <fileset dir="${cluster}">
216
                    <include name="**/*.jar"/>
201
                    <include name="**/*.jar"/>
217
                </fileset>
202
                </fileset>
Lines 225-230 Link Here
225
        
210
        
226
        <antcall target="run">
211
        <antcall target="run">
227
            <param name="run.args" value='"${profiler.jvmargs}"'/>
212
            <param name="run.args" value='"${profiler.jvmargs}"'/>
213
            <reference refid="cluster.path.id"/>
228
        </antcall>
214
        </antcall>
229
    </target>
215
    </target>
230
    
216
    
(-)a/apisupport.harness/release/suite.xml (-70 / +176 lines)
Lines 49-63 Link Here
49
        <dirname property="harness.dir" file="${suite.file}"/>
49
        <dirname property="harness.dir" file="${suite.file}"/>
50
        <echo level="verbose">Using build harness in ${harness.dir}</echo>
50
        <echo level="verbose">Using build harness in ${harness.dir}</echo>
51
        <taskdef classpath="${harness.dir}/tasks.jar" resource="org/netbeans/nbbuild/taskdefs.properties"/>
51
        <taskdef classpath="${harness.dir}/tasks.jar" resource="org/netbeans/nbbuild/taskdefs.properties"/>
52
        <typedef name="pathfileset" classname="org.netbeans.nbbuild.PathFileSet"
53
                 classpath="${harness.dir}/tasks.jar"/>
52
        <property name="harness.taskdefs.done" value="true"/>
54
        <property name="harness.taskdefs.done" value="true"/>
53
    </target>
55
    </target>
54
56
55
    <target name="-init" depends="-taskdefs">
57
    <target name="-convert-old-project" unless="cluster.path.evaluated">
58
        <!-- netbeans.dest.dir -> cluster.path.id translation for pre-7.0 modules -->
59
        <fail unless="netbeans.dest.dir" message="Either 'cluster.path.evaluated' or 'netbeans.dest.dir' property must be set."/>
60
61
        <pathconvert property="old.project.update.tracking">
62
            <fileset dir="${netbeans.dest.dir}" includes="**/update_tracking/*.xml"/>
63
        </pathconvert>
64
65
        <selector id="old.project.included.files">
66
            <custom classpath="${harness.dir}/tasks.jar" classname="org.netbeans.nbbuild.ModuleSelector">
67
                <param name="excludeModules" value="${disabled.modules}"/>
68
                <!-- XXX inc/exc clusters -->
69
                <param name="includeClusters" value="${enabled.clusters}"/>
70
                <param name="excludeClusters" value="${disabled.clusters}"/>
71
                <param name="updateTrackingFiles" value="${old.project.update.tracking}"/>
72
            </custom>
73
        </selector>
74
75
        <pathconvert property="old.project.clusters.duplicates" pathsep="&#10;">
76
            <fileset dir="${netbeans.dest.dir}">
77
                <selector refid="old.project.included.files"/>
78
            </fileset>
79
            <chainedmapper>
80
                <mapper type="regexp" from="(^.+)[/\\]config[/\\]Modules[/\\]" to="\1"/> <!-- #71849 -->
81
                <filtermapper>
82
                    <linecontainsregexp negate="true">
83
                        <regexp pattern="update[/\\]backup[/\\]netbeans[/\\]?$"/>
84
                    </linecontainsregexp>
85
                </filtermapper>
86
            </chainedmapper>
87
        </pathconvert>
88
        <tempfile property="old.project.clusters.duplicates.file" destdir="${basedir}/build" deleteonexit="true"/>
89
        <mkdir dir="${basedir}/build"/>
90
        <echo file="${old.project.clusters.duplicates.file}" message="${old.project.clusters.duplicates}"/>
91
92
        <pathconvert property="cluster.path.evaluated">
93
            <union> <!-- union removes duplicates -->
94
                <files includesfile="${old.project.clusters.duplicates.file}"/>
95
            </union>
96
        </pathconvert>
97
    </target>
98
99
    <target name="-init" depends="-taskdefs,-convert-old-project">
100
        <convertclusterpath from="${cluster.path.evaluated}" to="cluster.path" id="cluster.path.id"/>
56
        <property file="nbproject/private/private.properties"/>
101
        <property file="nbproject/private/private.properties"/>
57
        <property file="nbproject/project.properties"/>
102
        <property file="nbproject/project.properties"/>
58
        <sortsuitemodules unsortedmodules="${modules}" sortedmodulesproperty="modules.sorted"/>
103
        <sortsuitemodules unsortedmodules="${modules}" sortedmodulesproperty="modules.sorted"/>
59
        <property name="cluster" location="build/cluster"/>
104
        <property name="cluster" location="build/cluster"/>
60
        <echo level="verbose">Suite in ${basedir} with target platform ${netbeans.dest.dir}, build cluster ${cluster}, and sorted modules ${modules.sorted}</echo>
105
        <echo level="verbose">Suite in ${basedir} with clusters ${cluster.path}, build cluster ${cluster}, and sorted modules ${modules.sorted}</echo>
61
        <!-- synchronize with SuiteProject -->
106
        <!-- synchronize with SuiteProject -->
62
        <property name="disabled.modules" value=""/>
107
        <property name="disabled.modules" value=""/>
63
        <property name="enabled.clusters" value=""/>
108
        <property name="enabled.clusters" value=""/>
Lines 103-118 Link Here
103
    
148
    
104
149
105
    <target name="build" depends="-init,branding,release" description="Build all modules in the suite.">
150
    <target name="build" depends="-init,branding,release" description="Build all modules in the suite.">
106
        <subant target="netbeans" buildpath="${modules.sorted}" inheritrefs="false" inheritall="false"/>
151
        <subant target="netbeans" buildpath="${modules.sorted}" inheritrefs="false" inheritall="false">
152
            <property name="cluster.path.evaluated" value="${cluster.path.evaluated}"/> <!-- Just for speed of pre-7.0 projects -->
153
        </subant>
107
        <mkdir dir="${cluster}/config/Modules"/>
154
        <mkdir dir="${cluster}/config/Modules"/>
108
        <createmodulexml xmldir="${cluster}/config/Modules">
155
        <pathconvert pathsep="," property="disabled.modules.paths.list">
109
            <hidden dir="${netbeans.dest.dir}">
156
            <pathfileset>
157
                <path refid="cluster.path.id"/>
110
                <custom classpath="${harness.dir}/tasks.jar" classname="org.netbeans.nbbuild.ModuleSelector">
158
                <custom classpath="${harness.dir}/tasks.jar" classname="org.netbeans.nbbuild.ModuleSelector">
111
                    <param name="excludeModules" value="${disabled.modules}"/>
159
                    <param name="excludeModules" value="${disabled.modules}"/>
112
                    <param name="excluded" value="true"/>
160
                    <param name="excluded" value="true"/>
113
                </custom>
161
                </custom>
114
            </hidden>
162
            </pathfileset>
115
        </createmodulexml>
163
        </pathconvert>
164
        <createmodulexml xmldir="${cluster}/config/Modules" hidden="${disabled.modules.paths.list}"/>
116
    </target>
165
    </target>
117
166
118
    <target name="nbms" depends="build" description="Build NBMs and an Auto Update site descriptor for all modules in the suite.">
167
    <target name="nbms" depends="build" description="Build NBMs and an Auto Update site descriptor for all modules in the suite.">
Lines 122-136 Link Here
122
            <isset property="nbm.target.cluster"/>
171
            <isset property="nbm.target.cluster"/>
123
        </condition>
172
        </condition>
124
        <!-- reads app.name if exists -->
173
        <!-- reads app.name if exists -->
174
        <pathfileset id="updater.jar">
175
            <path refid="cluster.path.id"/>
176
            <filename name="modules/ext/updater.jar"/>
177
        </pathfileset>
125
        <condition property="help.target.cluster" value="${app.name}" >
178
        <condition property="help.target.cluster" value="${app.name}" >
126
            <and>
179
            <and>
127
                <isset property="app.name"/>
180
                <isset property="app.name"/>
128
                <!-- #74866: only works for 6.0+ platforms. -->
181
                <!-- #74866: only works for 6.0+ platforms. -->
129
                <available resource="org/netbeans/updater/resources/autoupdate-info-2_4.dtd">
182
                <available resource="org/netbeans/updater/resources/autoupdate-info-2_4.dtd">
130
                    <classpath>
183
                    <classpath>
131
                        <fileset dir="${netbeans.dest.dir}">
184
                        <resources refid="updater.jar"/>
132
                            <include name="platform*/modules/ext/updater.jar"/>
133
                        </fileset>
134
                    </classpath>
185
                    </classpath>
135
                </available>
186
                </available>
136
            </and>
187
            </and>
Lines 144-156 Link Here
144
        <subant target="nbm" buildpath="${modules.sorted}" inheritrefs="false" inheritall="false">
195
        <subant target="nbm" buildpath="${modules.sorted}" inheritrefs="false" inheritall="false">
145
            <property name="nbm.target.dir" location="${build.updates.dir}"/>
196
            <property name="nbm.target.dir" location="${build.updates.dir}"/>
146
            <property name="${nbm.target.cluster.name}" value="${help.target.cluster}" />
197
            <property name="${nbm.target.cluster.name}" value="${help.target.cluster}" />
198
            <property name="cluster.path.evaluated" value="${cluster.path.evaluated}"/> <!-- Just for speed of pre-7.0 projects -->
147
        </subant>
199
        </subant>
148
        <makeupdatedesc desc="${build.updates.dir}/updates.xml" distbase="." automaticgrouping="true">
200
        <makeupdatedesc desc="${build.updates.dir}/updates.xml" distbase="." automaticgrouping="true">
149
            <fileset dir="${build.updates.dir}">
201
            <fileset dir="${build.updates.dir}">
150
                <include name="*.nbm"/>
202
                <include name="*.nbm"/>
151
            </fileset>
203
            </fileset>
152
            <updaterjar>
204
            <updaterjar>
153
                <fileset dir="${netbeans.dest.dir}" includes="platform*/modules/ext/updater.jar"/>
205
                <resources refid="updater.jar"/>
154
            </updaterjar>
206
            </updaterjar>
155
        </makeupdatedesc>
207
        </makeupdatedesc>
156
    </target>
208
    </target>
Lines 159-196 Link Here
159
        <fail unless="app.name">Must have set at least an application name ('app.name')</fail>
211
        <fail unless="app.name">Must have set at least an application name ('app.name')</fail>
160
        
212
        
161
        <pathconvert property="zip.platform.update.tracking">
213
        <pathconvert property="zip.platform.update.tracking">
162
            <path>
214
            <pathfileset>
163
                <fileset dir="${netbeans.dest.dir}">
215
                <path refid="cluster.path.id"/>
164
                    <include name="**/update_tracking/*.xml"/>
216
                <filename name="**/update_tracking/*.xml"/>
165
                </fileset>
217
            </pathfileset>
166
            </path>
167
        </pathconvert>
218
        </pathconvert>
168
219
169
        <selector id="zip.platform.included.files">
220
        <selector id="zip.platform.included.files">
170
            <custom classpath="${harness.dir}/tasks.jar" classname="org.netbeans.nbbuild.ModuleSelector">
221
            <custom classpath="${harness.dir}/tasks.jar" classname="org.netbeans.nbbuild.ModuleSelector">
171
                <param name="excludeModules" value="${disabled.modules}"/>
222
                <param name="excludeModules" value="${disabled.modules}"/>
223
                <!-- XXX inc/exc clusters -->
172
                <param name="includeClusters" value="${enabled.clusters}"/>
224
                <param name="includeClusters" value="${enabled.clusters}"/>
173
                <param name="excludeClusters" value="${disabled.clusters}"/>
225
                <param name="excludeClusters" value="${disabled.clusters}"/>
174
                <param name="updateTrackingFiles" value="${zip.platform.update.tracking}"/>
226
                <param name="updateTrackingFiles" value="${zip.platform.update.tracking}"/>
175
            </custom>
227
            </custom>
176
        </selector>
228
        </selector>
177
229
178
        <pathconvert property="zip.platform.clusters.duplicates" pathsep=",">
230
        <pathconvert property="zip.platform.clusters.duplicates" pathsep="&#10;">
179
            <path>
231
            <pathfileset>
180
                <fileset dir="${netbeans.dest.dir}">
232
                <path refid="cluster.path.id"/>
181
                    <selector refid="zip.platform.included.files"/>
233
                <selector refid="zip.platform.included.files"/>
182
                </fileset>
234
            </pathfileset>
183
            </path>
235
            <chainedmapper>
184
            <mapper type="regexp" from="[/\\]([^/\\]+)[/\\]config[/\\]Modules[/\\]" to="\1"/> <!-- #71849 -->
236
                <mapper type="regexp" from="(^.+)[/\\]config[/\\]Modules[/\\]" to="\1"/> <!-- #71849 -->
237
                <filtermapper>
238
                    <linecontainsregexp negate="true">
239
                        <regexp pattern="update[/\\]backup[/\\]netbeans[/\\]?$"/>
240
                    </linecontainsregexp>
241
                </filtermapper>
242
            </chainedmapper>
185
        </pathconvert>
243
        </pathconvert>
186
        
244
        <tempfile property="zip.platform.clusters.duplicates.file" destdir="${basedir}/build" deleteonexit="true"/>
187
        <dirset id="zip.platform.clusters" dir="${netbeans.dest.dir}" includes="${zip.platform.clusters.duplicates}" excludes="platform*"/>
245
        <echo file="${zip.platform.clusters.duplicates.file}" message="${zip.platform.clusters.duplicates}"/>
188
        
246
247
        <union id="zip.platform.clusters"> <!-- union removes duplicates -->
248
            <files includesfile="${zip.platform.clusters.duplicates.file}"/>
249
        </union>
189
        <pathconvert property="zip.platform.clusters.bare" pathsep="&#10;"> <!-- #71128: \n OK on Win but \r\n bad on Unix -->
250
        <pathconvert property="zip.platform.clusters.bare" pathsep="&#10;"> <!-- #71128: \n OK on Win but \r\n bad on Unix -->
190
            <path>
251
            <resources refid="zip.platform.clusters"/>
191
                <dirset refid="zip.platform.clusters"/>
252
            <chainedmapper>
192
            </path>
253
                <filtermapper>
193
            <mapper type="regexp" from="[/\\]([^/\\]+)[/\\]?$" to="\1"/> <!-- #71849 -->
254
                    <linecontainsregexp negate="true">
255
                        <regexp pattern="platform[0-9]*[/\\]?$"/>
256
                    </linecontainsregexp>
257
                </filtermapper>
258
                <mapper type="regexp" from="[/\\]([^/\\]+)[/\\]?$" to="\1"/> <!-- #71849 -->
259
            </chainedmapper>
194
        </pathconvert>
260
        </pathconvert>
195
261
196
        <property name="build.launcher.dir" location="build/launcher"/>
262
        <property name="build.launcher.dir" location="build/launcher"/>
Lines 201-212 Link Here
201
        <mkdir dir="${build.launcher.dir}/bin"/>
267
        <mkdir dir="${build.launcher.dir}/bin"/>
202
268
203
        <!-- make sure correct launchers are present - for pre7 platform use old app.exe launchers -->
269
        <!-- make sure correct launchers are present - for pre7 platform use old app.exe launchers -->
270
        <pathconvert property="nbexec.dll.found" setonempty="false">
271
            <pathfileset include="lib/nbexec.dll">
272
                <path refid="cluster.path.id"/>
273
            </pathfileset>
274
        </pathconvert>
204
        <condition property="app.exe.prefix" value="" else="pre7_">
275
        <condition property="app.exe.prefix" value="" else="pre7_">
205
            <available file="nbexec.dll">
276
            <isset property="nbexec.dll.found"/>
206
                <filepath>
207
                    <dirset dir="${netbeans.dest.dir}" includes="platform*/lib"/>
208
                </filepath>
209
            </available>
210
        </condition>
277
        </condition>
211
        <copy file="${harness.dir}/launchers/${app.exe.prefix}app.exe" tofile="${build.launcher.dir}/bin/${app.name}.exe" overwrite="true"/>
278
        <copy file="${harness.dir}/launchers/${app.exe.prefix}app.exe" tofile="${build.launcher.dir}/bin/${app.name}.exe" overwrite="true"/>
212
        <copy file="${harness.dir}/launchers/${app.exe.prefix}app_w.exe" tofile="${build.launcher.dir}/bin/${app.name}_w.exe" failonerror="false" overwrite="true"/>
279
        <copy file="${harness.dir}/launchers/${app.exe.prefix}app_w.exe" tofile="${build.launcher.dir}/bin/${app.name}_w.exe" failonerror="false" overwrite="true"/>
Lines 226-247 Link Here
226
    
293
    
227
    <target name="build-zip" depends="build,build-launchers" description="Builds a ZIP distribution of the suite, launchers, and selected modules from the platform.">
294
    <target name="build-zip" depends="build,build-launchers" description="Builds a ZIP distribution of the suite, launchers, and selected modules from the platform.">
228
        <mkdir dir="${dist.dir}"/>
295
        <mkdir dir="${dist.dir}"/>
296
        <!-- pathfileset does not support 'prefix' and 'filemode' parameters,
297
             we have to copy them to temp location -->
298
        <tempfile property="temp.dir.nbexec" destdir="${basedir}/build" deleteonexit="true"/>
299
        <tempfile property="temp.dir.rest" destdir="${basedir}/build" deleteonexit="delete"/>
300
        <subant genericantfile="${harness.dir}/suite.xml" target="copy-cluster" inheritrefs="true">
301
            <property name="dest.dir" value="${temp.dir.rest}"/>
302
            <property name="nbexec.dir" value="${temp.dir.nbexec}"/>
303
            <property name="build.dir" value="${basedir}/build"/>
304
            <resources refid="zip.platform.clusters"/>
305
        </subant>
229
        <zip destfile="${dist.dir}/${app.name}.zip">
306
        <zip destfile="${dist.dir}/${app.name}.zip">
230
            <zipfileset dir="${build.launcher.dir}/bin/" filemode="755" prefix="${app.name}/bin"/>
307
            <zipfileset dir="${build.launcher.dir}/bin/" filemode="755" prefix="${app.name}/bin"/>
231
            <zipfileset dir="${build.launcher.dir}/etc/" prefix="${app.name}/etc"/>
308
            <zipfileset dir="${build.launcher.dir}/etc/" prefix="${app.name}/etc"/>
232
            <zipfileset dir="${netbeans.dest.dir}" filemode="755" prefix="${app.name}">
309
            <zipfileset dir="${temp.dir.nbexec}" filemode="755" prefix="${app.name}"/>
233
                <include name="**/lib/nbexec*"/>
310
            <zipfileset dir="${temp.dir.rest}" prefix="${app.name}"/>
234
            </zipfileset>
311
235
                
236
            <zipfileset dir="${netbeans.dest.dir}" prefix="${app.name}">
237
                <and>
238
                    <not>
239
                        <filename name="**/lib/nbexec*"/>
240
                    </not>
241
                    <selector refid="zip.platform.included.files"/>
242
                </and>
243
            </zipfileset>
244
            
245
            <!-- Yes, the doubled app.name is a bit ugly, but better than the alternative; cf. #66441: -->
312
            <!-- Yes, the doubled app.name is a bit ugly, but better than the alternative; cf. #66441: -->
246
            <zipfileset dir="${cluster}" prefix="${app.name}/${app.name}">
313
            <zipfileset dir="${cluster}" prefix="${app.name}/${app.name}">
247
                <exclude name="config/Modules/*.xml_hidden"/>
314
                <exclude name="config/Modules/*.xml_hidden"/>
Lines 249-254 Link Here
249
            
316
            
250
        </zip>
317
        </zip>
251
    </target>
318
    </target>
319
320
    <target name="copy-cluster" description="Copies cluster specified by basedir to dir ${dest.dir}">
321
        <pathconvert property="cluster.name">
322
            <path path="${basedir}"/>
323
            <mapper type="regexp" from="[/\\]([^/\\]+)[/\\]?$" to="\1"/>
324
        </pathconvert>
325
        <copy todir="${dest.dir}/${cluster.name}">
326
            <fileset dir="${basedir}">
327
                <and>
328
                    <not>
329
                        <filename name="**/lib/nbexec*"/>
330
                    </not>
331
                    <selector refid="zip.platform.included.files"/>
332
                </and>
333
            </fileset>
334
        </copy>
335
        <condition property="copy.nbexec" value="true">
336
            <matches pattern="^platform[0-9]*$" string="${cluster.name}"/>
337
        </condition>
338
        <antcall target="copy-nbexec"/>
339
    </target>
340
341
    <target name="copy-nbexec" if="copy.nbexec" description="Copies nbexec from given cluster to specified location">
342
        <copy todir="${nbexec.dir}/${cluster.name}">
343
            <fileset dir="${basedir}">
344
                <filename name="**/lib/nbexec*"/>
345
            </fileset>
346
        </copy>
347
    </target>
348
252
    <target name="create-platform" depends="build-zip" description="Creates an unzipped platform from the suite, launchers, and selected modules from the platform.">
349
    <target name="create-platform" depends="build-zip" description="Creates an unzipped platform from the suite, launchers, and selected modules from the platform.">
253
        <mkdir dir="${dist.dir}/${app.name}"/>
350
        <mkdir dir="${dist.dir}/${app.name}"/>
254
        <unzip src="${dist.dir}/${app.name}.zip" dest="${dist.dir}/${app.name}">
351
        <unzip src="${dist.dir}/${app.name}.zip" dest="${dist.dir}/${app.name}">
Lines 269-288 Link Here
269
        <copy todir="${dist.dir}/${app.name}.app/Contents/Resources/${app.name}/etc">
366
        <copy todir="${dist.dir}/${app.name}.app/Contents/Resources/${app.name}/etc">
270
            <fileset dir="${build.launcher.dir}/etc/" />
367
            <fileset dir="${build.launcher.dir}/etc/" />
271
        </copy>
368
        </copy>
272
        <copy todir="${dist.dir}/${app.name}.app/Contents/Resources/${app.name}">
369
        <subant genericantfile="${harness.dir}/suite.xml" target="copy-cluster" inheritrefs="true">
273
            <fileset dir="${netbeans.dest.dir}">
370
            <property name="dest.dir" value="${dist.dir}/${app.name}.app/Contents/Resources/${app.name}"/>
274
                <include name="**/lib/nbexec*"/>
371
            <property name="nbexec.dir" value="${dist.dir}/${app.name}.app/Contents/Resources/${app.name}"/>
275
            </fileset>
372
            <property name="build.dir" value="${basedir}/build"/>
276
                
373
            <resources refid="zip.platform.clusters"/>
277
            <fileset dir="${netbeans.dest.dir}">
374
        </subant>
278
                <and>
375
279
                    <not>
280
                        <filename name="**/lib/nbexec*"/>
281
                    </not>
282
                    <selector refid="zip.platform.included.files"/>
283
                </and>
284
            </fileset>
285
        </copy>
286
        <copy todir="${dist.dir}/${app.name}.app/Contents/Resources/${app.name}/${app.name}">
376
        <copy todir="${dist.dir}/${app.name}.app/Contents/Resources/${app.name}/${app.name}">
287
            
377
            
288
            <fileset dir="${cluster}"/>
378
            <fileset dir="${cluster}"/>
Lines 336-342 Link Here
336
                <exclude name="testuserdir/"/>
426
                <exclude name="testuserdir/"/>
337
            </fileset>
427
            </fileset>
338
        </delete>
428
        </delete>
339
        <subant target="clean" buildpath="${modules.sorted}" inheritrefs="false" inheritall="false"/>
429
        <subant target="clean" buildpath="${modules.sorted}" inheritrefs="false" inheritall="false">
430
            <property name="cluster.path.evaluated" value="${cluster.path.evaluated}"/> <!-- Just for speed of pre-7.0 projects -->
431
        </subant>
340
        <delete dir="${dist.dir}"/>
432
        <delete dir="${dist.dir}"/>
341
    </target>
433
    </target>
342
434
Lines 346-377 Link Here
346
    </target>
438
    </target>
347
439
348
    <target name="run" depends="build,-jdk-init" description="Runs this suite in place.">
440
    <target name="run" depends="build,-jdk-init" description="Runs this suite in place.">
349
        <ant antfile="${harness.dir}/run.xml" target="run"/>
441
        <ant antfile="${harness.dir}/run.xml" target="run">
442
            <reference refid="cluster.path.id"/>
443
        </ant>
350
    </target>
444
    </target>
351
        
445
        
352
    <target name="debug" depends="build,-jdk-init,-jdk-presetdef-nbjpdastart" description="Runs this suite in place in the debugger.">
446
    <target name="debug" depends="build,-jdk-init,-jdk-presetdef-nbjpdastart" description="Runs this suite in place in the debugger.">
353
        <ant antfile="${harness.dir}/run.xml" target="debug"/>
447
        <ant antfile="${harness.dir}/run.xml" target="debug">
448
            <reference refid="cluster.path.id"/>
449
        </ant>
354
    </target>
450
    </target>
355
451
356
    <target name="profile" depends="build,-jdk-init,-jdk-presetdef-nbprofiledirect" description="Runs this suite in place in the profiler.">
452
    <target name="profile" depends="build,-jdk-init,-jdk-presetdef-nbprofiledirect" description="Runs this suite in place in the profiler.">
357
        <ant antfile="${harness.dir}/run.xml" target="profile"/>
453
        <ant antfile="${harness.dir}/run.xml" target="profile">
454
            <reference refid="cluster.path.id"/>
455
        </ant>
358
    </target>
456
    </target>
359
    
457
    
360
    <target name="build-jnlp" depends="build,-jdk-init" description="Packages this suite as a JNLP application.">
458
    <target name="build-jnlp" depends="build,-jdk-init" description="Packages this suite as a JNLP application.">
361
        <ant antfile="${harness.dir}/jnlp.xml" target="build"/>
459
        <ant antfile="${harness.dir}/jnlp.xml" target="build">
460
            <reference refid="cluster.path.id"/>
461
        </ant>
362
    </target>
462
    </target>
363
    
463
    
364
    <target name="run-jnlp" depends="build,-jdk-init" description="Runs this suite as a JNLP application.">
464
    <target name="run-jnlp" depends="build,-jdk-init" description="Runs this suite as a JNLP application.">
365
        <ant antfile="${harness.dir}/jnlp.xml" target="run"/>
465
        <ant antfile="${harness.dir}/jnlp.xml" target="run">
466
            <reference refid="cluster.path.id"/>
467
        </ant>
366
    </target>
468
    </target>
367
    
469
    
368
    <target name="debug-jnlp" depends="build,-jdk-init,-jdk-presetdef-nbjpdastart" description="Runs this suite as a JNLP application in the debugger.">
470
    <target name="debug-jnlp" depends="build,-jdk-init,-jdk-presetdef-nbjpdastart" description="Runs this suite as a JNLP application in the debugger.">
369
        <ant antfile="${harness.dir}/jnlp.xml" target="debug"/>
471
        <ant antfile="${harness.dir}/jnlp.xml" target="debug">
472
            <reference refid="cluster.path.id"/>
473
        </ant>
370
    </target>
474
    </target>
371
    
475
    
372
    <target name="test" depends="build" description="Runs tests for all modules in the suite.">
476
    <target name="test" depends="build" description="Runs tests for all modules in the suite.">
373
        <sortsuitemodules unsortedmodules="${modules}" sortedmodulesproperty="modules.test.sorted" sorttests="true"/>
477
        <sortsuitemodules unsortedmodules="${modules}" sortedmodulesproperty="modules.test.sorted" sorttests="true"/>
374
        <subant target="test" buildpath="${modules.test.sorted}" inheritrefs="false" inheritall="false"/>
478
        <subant target="test" buildpath="${modules.test.sorted}" inheritrefs="false" inheritall="false">
479
            <property name="cluster.path.evaluated" value="${cluster.path.evaluated}"/> <!-- Just for speed of pre-7.0 projects -->
480
        </subant>
375
    </target>
481
    </target>
376
    
482
    
377
</project>
483
</project>
(-)a/apisupport.harness/taskdefs.properties (+1 lines)
Lines 54-56 Link Here
54
fixtestdeps=org.netbeans.nbbuild.FixTestDependencies
54
fixtestdeps=org.netbeans.nbbuild.FixTestDependencies
55
shorterpaths=org.netbeans.nbbuild.ShorterPaths
55
shorterpaths=org.netbeans.nbbuild.ShorterPaths
56
custom-javac=org.netbeans.nbbuild.CustomJavac
56
custom-javac=org.netbeans.nbbuild.CustomJavac
57
convertclusterpath=org.netbeans.nbbuild.ConvertClusterPath
(-)a/nbbuild/antsrc/org/netbeans/nbbuild/ConvertClusterPath.java (+172 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.nbbuild;
41
42
import java.io.File;
43
import java.io.FilenameFilter;
44
import java.util.Iterator;
45
import java.util.regex.Matcher;
46
import java.util.regex.Pattern;
47
import org.apache.tools.ant.BuildException;
48
import org.apache.tools.ant.Project;
49
import org.apache.tools.ant.Task;
50
import org.apache.tools.ant.types.Path;
51
import org.apache.tools.ant.types.resources.FileResource;
52
import org.apache.tools.ant.util.FileUtils;
53
54
/**
55
 * Converts cluster.path from value specified in platform.properties
56
 * to value usable by harness.
57
 *
58
 * TODO - describe actual changes
59
 *
60
 * @author Richard Michalsky
61
 */
62
public class ConvertClusterPath extends Task {
63
    private String from;
64
    private String id;
65
    private String basedir;
66
    private String to;
67
68
    /**
69
     * Name of property to which stores
70
     * @param to
71
     */
72
    public void setTo(String to) {
73
        this.to = to;
74
    }
75
76
    public void setBasedir(String basedir) {
77
        this.basedir = basedir;
78
    }
79
80
    public void setFrom(String from) {
81
        this.from = from;
82
    }
83
84
    public void setId(String id) {
85
        this.id = id;
86
    }
87
88
    public ConvertClusterPath() {
89
90
    }
91
92
    @Override
93
    public void execute() throws BuildException {
94
        try {
95
            if (from == null || from.length() == 0)
96
                throw new BuildException("From parameter not specified.", getLocation());
97
            if ((id == null || id.length() == 0)
98
                    && (to == null && to.length() == 0))
99
                throw new BuildException("Either 'to' or 'id' parameter for converted path must be specified.", getLocation());
100
            if (basedir == null || basedir.length() == 0)
101
                basedir = getProject().getBaseDir().getAbsolutePath();
102
103
            log("Converting cluster.path from '" + from + "' relative to '" + basedir + "'.", Project.MSG_VERBOSE);
104
            FileUtils fu = FileUtils.getFileUtils();
105
            Project fakeproj = new Project();
106
            fakeproj.setBasedir(basedir);
107
            Path absPath = new Path(fakeproj, from);
108
            log("Converted path: '" + absPath.toString() + "'.", Project.MSG_VERBOSE);
109
110
            // When cluster does not exist, it is either bare name or one with different number
111
            final Pattern pat = Pattern.compile("(?:.*[\\\\/])?([^/\\\\]*?)([0-9]+)?[/\\\\]?$");
112
            Path convPath = new Path(fakeproj);
113
114
            for (Iterator it = absPath.iterator(); it.hasNext();) {
115
                FileResource element = (FileResource) it.next();
116
                File f = element.getFile();
117
                String fPath = f.getAbsolutePath();
118
                final Matcher cm = pat.matcher(fPath);
119
                if (f.exists()) {
120
                    if (! f.isDirectory())
121
                        throw new BuildException("Only directories can be elements of cluster.path. Got '" + fPath + "'", getLocation());
122
                    convPath.createPathElement().setLocation(f);
123
                    continue;
124
                }
125
                if (cm.matches()) {
126
                    // search for corresponding numbered cluster
127
                    File parent = f.getParentFile();
128
129
                    if (parent != null) {
130
                        File[] alternate = parent.listFiles(new FilenameFilter() {
131
                            public boolean accept(File dir, String name) {
132
                                Matcher am = pat.matcher(name);
133
                                return am.matches() && cm.group(1).equalsIgnoreCase(am.group(1));
134
                            }
135
                        });
136
                        if (alternate == null) {
137
                            Matcher matcher = Pattern.compile("^\\$\\{nbplatform\\.(.*)\\.netbeans\\.dest\\.dir\\}$").matcher(parent.getName());
138
                            if (matcher.matches()) {
139
                                throw new BuildException("Unknown platform name '" + matcher.group(1) + "'.", getLocation());
140
                            } else {
141
                                // cannot throw BuildException here, targets like 'clean' must run with nonexistent clusters as well
142
                                log("Warning: parent dir '" + parent.getAbsolutePath()
143
                                        + "' does not exist.", Project.MSG_WARN);
144
                                continue;
145
                            }
146
                        }
147
                        if (alternate.length > 0 && alternate[0].isDirectory()) {
148
                            if (cm.group(2) != null) // numbered cluster in cluster.path, found one with different number, warning
149
                                log("Warning: cluster '" + fPath + "' not found, using '" + alternate[0].getAbsolutePath() + "' instead.", Project.MSG_WARN);
150
                            else // bare name used
151
                                log("Cluster '" + alternate[0].getAbsolutePath() + "' found matching bare name '" + fPath + "'.", Project.MSG_VERBOSE);
152
153
                            convPath.createPathElement().setLocation(alternate[0]);
154
                            continue;
155
                        }
156
                    }
157
                }
158
                // no alternate cluster found
159
                log("Warning: no numbered cluster matching bare name '" + fPath + "' found.", Project.MSG_WARN);
160
            }
161
162
            if (id != null && id.length() > 0)
163
                getProject().addReference(id, convPath);
164
            if (to != null && to.length() > 0)
165
                getProject().setProperty(to, convPath.toString());
166
        } catch (Exception e) {
167
            throw new BuildException(e, getLocation());
168
        }
169
    }
170
171
172
}
(-)a/nbbuild/antsrc/org/netbeans/nbbuild/CreateModuleXML.java (-105 / +139 lines)
Lines 105-117 Link Here
105
    private List<String> autoloadNames = new ArrayList<String>(10);
105
    private List<String> autoloadNames = new ArrayList<String>(10);
106
    private List<String> eagerNames = new ArrayList<String>(10);
106
    private List<String> eagerNames = new ArrayList<String>(10);
107
    private List<String> hiddenNames = new ArrayList<String>(10);
107
    private List<String> hiddenNames = new ArrayList<String>(10);
108
    
108
    private String hiddenList;
109
110
    /**
111
     * In addition to &gt;hidden&lt; nested fileset, list of hidden modules can
112
     * be specified as comma-separated list in attribute 'hidden'.
113
     * @param hiddenList
114
     */
115
    public void setHidden(String hiddenList) {
116
        // Only hidden parameters can be specified as list of absolute file paths,
117
        // enabled, eager and autoload modules need relative path to create proper module xml
118
        this.hiddenList = hiddenList;
119
    }
120
109
    public void execute() throws BuildException {
121
    public void execute() throws BuildException {
110
        if (xmldir == null) throw new BuildException("Must set xmldir attribute", getLocation());
122
        if (xmldir == null) throw new BuildException("Must set xmldir attribute", getLocation());
111
        if (!xmldir.exists ()) {
123
        if (!xmldir.exists ()) {
112
            if (!xmldir.mkdirs()) throw new BuildException("Cannot create directory " + xmldir, getLocation());
124
            if (!xmldir.mkdirs()) throw new BuildException("Cannot create directory " + xmldir, getLocation());
113
        }
125
        }
114
        if (enabled.isEmpty() && disabled.isEmpty() && autoload.isEmpty() && eager.isEmpty() && hidden.isEmpty()) {
126
        if (enabled.isEmpty() && disabled.isEmpty() && autoload.isEmpty() && eager.isEmpty() && hidden.isEmpty()
127
                && hiddenList == null) {
115
            log("Warning: <createmodulexml> with no modules listed", Project.MSG_WARN);
128
            log("Warning: <createmodulexml> with no modules listed", Project.MSG_WARN);
116
        }
129
        }
117
        for (FileSet fs : enabled) {
130
        for (FileSet fs : enabled) {
Lines 129-134 Link Here
129
        for (FileSet fs : hidden) {
142
        for (FileSet fs : hidden) {
130
            scanModules(fs, false, false, false, true, hiddenNames);
143
            scanModules(fs, false, false, false, true, hiddenNames);
131
        }
144
        }
145
        if (hiddenList != null && hiddenList.length() > 0)
146
            scanModulesInList(hiddenList, false, false, false, true, hiddenNames);
132
        Collections.sort(enabledNames);
147
        Collections.sort(enabledNames);
133
        Collections.sort(disabledNames);
148
        Collections.sort(disabledNames);
134
        Collections.sort(autoloadNames);
149
        Collections.sort(autoloadNames);
Lines 156-272 Link Here
156
        File dir = scan.getBasedir();
171
        File dir = scan.getBasedir();
157
        for (String kid : scan.getIncludedFiles()) {
172
        for (String kid : scan.getIncludedFiles()) {
158
            File module = new File(dir, kid);
173
            File module = new File(dir, kid);
159
            if (!module.exists()) throw new BuildException("Module file does not exist: " + module, getLocation());
174
            scanOneModule(module, kid, isEnabled, isAutoload, isEager, isHidden, names);
160
            if (!module.getName().endsWith(".jar")) throw new BuildException("Only *.jar may be listed, check the fileset: " + module, getLocation());
175
        }
176
    }
177
178
    private void scanModulesInList(String modulesList, boolean isEnabled, boolean isAutoload,
179
            boolean isEager, boolean isHidden, List<String> names) throws BuildException {
180
        String[] modules = modulesList.split(",");
181
        for (String modulePath : modules) {
182
            File module = new File(modulePath);
183
            scanOneModule(module, null, isEnabled, isAutoload, isEager, isHidden, names);
184
        }
185
    }
186
187
    private void scanOneModule(File module, String kid, boolean isEnabled,boolean isAutoload, boolean isEager, boolean isHidden, List<String> names) throws BuildException {
188
        if (!module.exists()) {
189
            throw new BuildException("Module file does not exist: " + module, getLocation());
190
        }
191
        if (!module.getName().endsWith(".jar")) {
192
            throw new BuildException("Only *.jar may be listed, check the fileset: " + module, getLocation());
193
        }
194
        try {
195
            JarFile jar = new JarFile(module);
161
            try {
196
            try {
162
                JarFile jar = new JarFile(module);
197
                Manifest m = jar.getManifest();
163
                try {
198
                Attributes attr = m.getMainAttributes();
164
                    Manifest m = jar.getManifest();
199
                String codename = attr.getValue("OpenIDE-Module");
165
                    Attributes attr = m.getMainAttributes();
200
                if (codename == null) {
166
                    String codename = attr.getValue("OpenIDE-Module");
201
                    throw new BuildException("Missing manifest tag OpenIDE-Module; " + module + " is not a module", getLocation());
167
                    if (codename == null) {
202
                }
168
                        throw new BuildException("Missing manifest tag OpenIDE-Module; " + module + " is not a module", getLocation());
203
                if (codename.endsWith(" ") || codename.endsWith("\t")) {
204
                    // #62887
205
                    throw new BuildException("Illegal trailing space in OpenIDE-Module value from " + module, getLocation());
206
                }
207
                int idx = codename.lastIndexOf('/');
208
                String codenamebase;
209
                int rel;
210
                if (idx == -1) {
211
                    codenamebase = codename;
212
                    rel = -1;
213
                } else {
214
                    codenamebase = codename.substring(0, idx);
215
                    try {
216
                        rel = Integer.parseInt(codename.substring(idx + 1));
217
                    } catch (NumberFormatException e) {
218
                        throw new BuildException("Invalid OpenIDE-Module '" + codename + "' in " + module, getLocation());
169
                    }
219
                    }
170
                    if (codename.endsWith(" ") || codename.endsWith("\t")) { // #62887
220
                }
171
                        throw new BuildException("Illegal trailing space in OpenIDE-Module value from " + module, getLocation());
221
                File xml = new File(xmldir, codenamebase.replace('.', '-') + ".xml");
172
                    }
222
                if (xml.exists()) {
173
                    int idx = codename.lastIndexOf('/');
223
                    // XXX should check that the old file actually matches what we would have written
174
                    String codenamebase;
224
                    log("Will not overwrite " + xml + "; skipping...", Project.MSG_VERBOSE);
175
                    int rel;
225
                    return;
176
                    if (idx == -1) {
226
                }
177
                        codenamebase = codename;
227
                String displayname = attr.getValue("OpenIDE-Module-Name");
178
                        rel = -1;
228
                if (displayname == null) {
179
                    } else {
229
                    String bundle = attr.getValue("OpenIDE-Module-Localizing-Bundle");
180
                        codenamebase = codename.substring(0, idx);
230
                    if (bundle != null) {
231
                        // Display name actually found in a bundle, not manifest.
232
                        ZipEntry entry = jar.getEntry(bundle);
233
                        InputStream is;
234
                        if (entry != null) {
235
                            is = jar.getInputStream(entry);
236
                        } else {
237
                            File moduleloc = new File(new File(module.getParentFile(), "locale"), module.getName());
238
                            if (!moduleloc.isFile()) {
239
                                throw new BuildException("Expecting localizing bundle: " + bundle + " in: " + module);
240
                            }
241
                            JarFile jarloc = new JarFile(moduleloc);
242
                            try {
243
                                ZipEntry entry2 = jarloc.getEntry(bundle);
244
                                if (entry2 == null) {
245
                                    throw new BuildException("Expecting localizing bundle: " + bundle + " in: " + module);
246
                                }
247
                                is = jarloc.getInputStream(entry2);
248
                            } finally {
249
                                jarloc.close();
250
                            }
251
                        }
181
                        try {
252
                        try {
182
                            rel = Integer.parseInt(codename.substring(idx + 1));
253
                            Properties p = new Properties();
183
                        } catch (NumberFormatException e) {
254
                            p.load(is);
184
                            throw new BuildException("Invalid OpenIDE-Module '" + codename + "' in " + module, getLocation());
255
                            displayname = p.getProperty("OpenIDE-Module-Name");
256
                        } finally {
257
                            is.close();
185
                        }
258
                        }
186
                    }
259
                    }
187
                    File xml = new File(xmldir, codenamebase.replace('.', '-') + ".xml");
260
                }
188
                    if (xml.exists()) {
261
                if (displayname == null) {
189
                        // XXX should check that the old file actually matches what we would have written
262
                    displayname = codename;
190
                        log("Will not overwrite " + xml + "; skipping...", Project.MSG_VERBOSE);
263
                }
191
                        continue;
264
                names.add(displayname);
265
                String spec = attr.getValue("OpenIDE-Module-Specification-Version");
266
                if (isHidden) {
267
                    File h = new File(xml.getParentFile(), xml.getName() + "_hidden");
268
                    h.createNewFile();
269
                } else {
270
                    OutputStream os = new FileOutputStream(xml);
271
                    try {
272
                        PrintWriter pw = new PrintWriter(new OutputStreamWriter(os, "UTF-8"));
273
                        // Please make sure formatting matches what the IDE actually spits
274
                        // out; it could matter.
275
                        pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
276
                        pw.println("<!DOCTYPE module PUBLIC \"-//NetBeans//DTD Module Status 1.0//EN\"");
277
                        pw.println("                        \"http://www.netbeans.org/dtds/module-status-1_0.dtd\">");
278
                        pw.println("<module name=\"" + codenamebase + "\">");
279
                        pw.println("    <param name=\"autoload\">" + isAutoload + "</param>");
280
                        pw.println("    <param name=\"eager\">" + isEager + "</param>");
281
                        if (!isAutoload && !isEager) {
282
                            pw.println("    <param name=\"enabled\">" + isEnabled + "</param>");
283
                        }
284
                        pw.println("    <param name=\"jar\">" + kid.replace(File.separatorChar, '/') + "</param>");
285
                        if (rel != -1) {
286
                            pw.println("    <param name=\"release\">" + rel + "</param>");
287
                        }
288
                        pw.println("    <param name=\"reloadable\">false</param>");
289
                        if (spec != null) {
290
                            pw.println("    <param name=\"specversion\">" + spec + "</param>");
291
                        }
292
                        pw.println("</module>");
293
                        pw.flush();
294
                        pw.close();
295
                    } finally {
296
                        os.close();
192
                    }
297
                    }
193
                    String displayname = attr.getValue("OpenIDE-Module-Name");
194
                    if (displayname == null) {
195
                        String bundle = attr.getValue("OpenIDE-Module-Localizing-Bundle");
196
                        if (bundle != null) {
197
                            // Display name actually found in a bundle, not manifest.
198
                            ZipEntry entry = jar.getEntry(bundle);
199
                            InputStream is;
200
                            if (entry != null) {
201
                                is = jar.getInputStream(entry);
202
                            } else {
203
                                File moduleloc = new File(new File(module.getParentFile(), "locale"), module.getName());
204
                                if (! moduleloc.isFile()) {
205
                                    throw new BuildException("Expecting localizing bundle: " + bundle + " in: " + module);
206
                                }
207
                                JarFile jarloc = new JarFile(moduleloc);
208
                                try {
209
                                    ZipEntry entry2 = jarloc.getEntry(bundle);
210
                                    if (entry2 == null) {
211
                                        throw new BuildException("Expecting localizing bundle: " + bundle + " in: " + module);
212
                                    }
213
                                    is = jarloc.getInputStream(entry2);
214
                                } finally {
215
                                    jarloc.close();
216
                                }
217
                            }
218
                            try {
219
                                Properties p = new Properties();
220
                                p.load(is);
221
                                displayname = p.getProperty("OpenIDE-Module-Name");
222
                            } finally {
223
                                is.close();
224
                            }
225
                        }
226
                    }
227
                    if (displayname == null) displayname = codename;
228
                    names.add(displayname);
229
                    String spec = attr.getValue("OpenIDE-Module-Specification-Version");
230
                    
231
                    if (isHidden) {
232
                        File h = new File(xml.getParentFile(), xml.getName() + "_hidden");
233
                        h.createNewFile();
234
                    } else {
235
                        OutputStream os = new FileOutputStream(xml);
236
                        try {
237
                            PrintWriter pw = new PrintWriter(new OutputStreamWriter(os, "UTF-8"));
238
                            // Please make sure formatting matches what the IDE actually spits
239
                            // out; it could matter.
240
                            pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
241
                            pw.println("<!DOCTYPE module PUBLIC \"-//NetBeans//DTD Module Status 1.0//EN\"");
242
                            pw.println("                        \"http://www.netbeans.org/dtds/module-status-1_0.dtd\">");
243
                            pw.println("<module name=\"" + codenamebase + "\">");
244
                            pw.println("    <param name=\"autoload\">" + isAutoload + "</param>");
245
                            pw.println("    <param name=\"eager\">" + isEager + "</param>");
246
                            if (!isAutoload && !isEager) {
247
                                pw.println("    <param name=\"enabled\">" + isEnabled + "</param>");
248
                            }
249
                            pw.println("    <param name=\"jar\">" + kid.replace(File.separatorChar, '/') + "</param>");
250
                            if (rel != -1) {
251
                                pw.println("    <param name=\"release\">" + rel + "</param>");
252
                            }
253
                            pw.println("    <param name=\"reloadable\">false</param>");
254
                            if (spec != null) {
255
                                pw.println("    <param name=\"specversion\">" + spec + "</param>");
256
                            }
257
                            pw.println("</module>");
258
                            pw.flush();
259
                            pw.close();
260
                        } finally {
261
                            os.close();
262
                        }
263
                    }
264
                } finally {
265
                    jar.close();
266
                }
298
                }
267
            } catch (IOException ioe) {
299
            } finally {
268
                throw new BuildException("Caught while processing " + module + ": " + ioe, ioe, getLocation());
300
                jar.close();
269
            }
301
            }
302
        } catch (IOException ioe) {
303
            throw new BuildException("Caught while processing " + module + ": " + ioe, ioe, getLocation());
270
        }
304
        }
271
    }
305
    }
272
    
306
    
(-)a/nbbuild/antsrc/org/netbeans/nbbuild/MakeJNLP.java (-9 / +15 lines)
Lines 73-79 Link Here
73
import org.apache.tools.ant.taskdefs.SignJar;
73
import org.apache.tools.ant.taskdefs.SignJar;
74
import org.apache.tools.ant.taskdefs.Zip;
74
import org.apache.tools.ant.taskdefs.Zip;
75
import org.apache.tools.ant.types.FileSet;
75
import org.apache.tools.ant.types.FileSet;
76
import org.apache.tools.ant.types.ResourceCollection;
76
import org.apache.tools.ant.types.ZipFileSet;
77
import org.apache.tools.ant.types.ZipFileSet;
78
import org.apache.tools.ant.types.resources.FileResource;
77
import org.xml.sax.SAXException;
79
import org.xml.sax.SAXException;
78
80
79
/** Generates JNLP files for signed versions of the module JAR files.
81
/** Generates JNLP files for signed versions of the module JAR files.
Lines 82-97 Link Here
82
 */
84
 */
83
public class MakeJNLP extends Task {
85
public class MakeJNLP extends Task {
84
    /** the files to work on */
86
    /** the files to work on */
85
    private FileSet files;
87
    private ResourceCollection files;
86
    private SignJar signTask;
88
    private SignJar signTask;
87
    
89
    
88
    public FileSet createModules() 
90
    public FileSet createModules() 
89
    throws BuildException {
91
    throws BuildException {
90
        if (files != null) throw new BuildException("modules can be created just once");
92
        addConfigured(new FileSet());
91
        files = new FileSet();
93
        return (FileSet) files;
92
        return files;
93
    }
94
    }
94
    
95
96
    public void addConfigured(ResourceCollection rc) throws BuildException {
97
        if (files != null) throw new BuildException("modules can be specified just once");
98
        files = rc;
99
    }
100
95
    private SignJar getSignTask() {
101
    private SignJar getSignTask() {
96
        if (signTask == null) {
102
        if (signTask == null) {
97
            signTask = (SignJar)getProject().createTask("signjar");
103
            signTask = (SignJar)getProject().createTask("signjar");
Lines 226-235 Link Here
226
            }
232
            }
227
        }
233
        }
228
234
229
        DirectoryScanner scan = files.getDirectoryScanner(getProject());
235
        for (Iterator fileIt = files.iterator(); fileIt.hasNext();) {
230
        for (String f : scan.getIncludedFiles()) {
236
            FileResource fr = (FileResource) fileIt.next();
231
            File jar = new File (files.getDir(getProject()), f);
237
            File jar = fr.getFile();
232
            
238
233
            if (!jar.canRead()) {
239
            if (!jar.canRead()) {
234
                throw new BuildException("Cannot read file: " + jar);
240
                throw new BuildException("Cannot read file: " + jar);
235
            }
241
            }
(-)a/nbbuild/antsrc/org/netbeans/nbbuild/MakeMasterJNLP.java (-7 / +15 lines)
Lines 44-53 Link Here
44
import java.io.File;
44
import java.io.File;
45
import java.io.FileWriter;
45
import java.io.FileWriter;
46
import java.io.IOException;
46
import java.io.IOException;
47
import java.util.Iterator;
47
import java.util.jar.JarFile;
48
import java.util.jar.JarFile;
48
import org.apache.tools.ant.BuildException;
49
import org.apache.tools.ant.BuildException;
49
import org.apache.tools.ant.Task;
50
import org.apache.tools.ant.Task;
50
import org.apache.tools.ant.types.FileSet;
51
import org.apache.tools.ant.types.FileSet;
52
import org.apache.tools.ant.types.ResourceCollection;
53
import org.apache.tools.ant.types.resources.FileResource;
51
54
52
/** Generates JNLP files for signed versions of the module JAR files.
55
/** Generates JNLP files for signed versions of the module JAR files.
53
 *
56
 *
Lines 55-67 Link Here
55
 */
58
 */
56
public class MakeMasterJNLP extends Task {
59
public class MakeMasterJNLP extends Task {
57
    /** the files to work on */
60
    /** the files to work on */
58
    private FileSet files;
61
    private ResourceCollection files;
59
    
62
    
60
    public FileSet createModules() 
63
    public FileSet createModules() 
61
    throws BuildException {
64
    throws BuildException {
62
        if (files != null) throw new BuildException("modules can be created just once");
65
        addConfigured(new FileSet());
63
        files = new FileSet();
66
        return (FileSet) files;
64
        return files;
67
    }
68
69
    public void addConfigured(ResourceCollection rc) throws BuildException {
70
        if (files != null) throw new BuildException("modules can be specified just once");
71
        files = rc;
65
    }
72
    }
66
    
73
    
67
    private File target;
74
    private File target;
Lines 86-94 Link Here
86
    }
93
    }
87
    
94
    
88
    private void generateFiles() throws IOException, BuildException {
95
    private void generateFiles() throws IOException, BuildException {
89
        for (String nm : files.getDirectoryScanner(getProject()).getIncludedFiles()) {
96
        for (Iterator fileIt = files.iterator(); fileIt.hasNext();) {
90
            File jar = new File (files.getDir(getProject()), nm);
97
            FileResource fr = (FileResource) fileIt.next();
91
            
98
            File jar = fr.getFile();
99
92
            if (!jar.canRead()) {
100
            if (!jar.canRead()) {
93
                throw new BuildException("Cannot read file: " + jar);
101
                throw new BuildException("Cannot read file: " + jar);
94
            }
102
            }
(-)a/nbbuild/antsrc/org/netbeans/nbbuild/ModuleListParser.java (-34 / +74 lines)
Lines 500-519 Link Here
500
    /**
500
    /**
501
     * Find all modules in a binary build, possibly from cache.
501
     * Find all modules in a binary build, possibly from cache.
502
     */
502
     */
503
    private static Map<String,Entry> scanBinaries(Project project, File build) throws IOException {
503
    private static Map<String,Entry> scanBinaries(Project project, File[] clusters) throws IOException {
504
        Map<String,Entry> entries = BINARY_SCAN_CACHE.get(build);
504
        Map<String,Entry> allEntries = new HashMap<String,Entry>();
505
        if (entries == null) {
505
506
            if (project != null) {
506
        for (File cluster : clusters) {
507
                project.log("Scanning for modules in " + build);
507
            Map<String, Entry> entries = BINARY_SCAN_CACHE.get(cluster);
508
            if (entries == null) {
509
                if (project != null) {
510
                    project.log("Scanning for modules in " + cluster);
511
                }
512
                entries = new HashMap<String, Entry>();
513
                doScanBinaries(cluster, entries);
514
                if (project != null) {
515
                    project.log("Found modules: " + entries.keySet(), Project.MSG_VERBOSE);
516
                }
517
                BINARY_SCAN_CACHE.put(cluster, entries);
508
            }
518
            }
509
            entries = new HashMap<String,Entry>();
519
            allEntries.putAll(entries);
510
            doScanBinaries(build, entries);
511
            if (project != null) {
512
                project.log("Found modules: " + entries.keySet(), Project.MSG_VERBOSE);
513
            }
514
            BINARY_SCAN_CACHE.put(build, entries);
515
        }
520
        }
516
        return entries;
521
        return allEntries;
517
    }
522
    }
518
    
523
    
519
    private static final String[] MODULE_DIRS = {
524
    private static final String[] MODULE_DIRS = {
Lines 528-541 Link Here
528
     * Checks modules/{,autoload/,eager/}*.jar as well as well-known core/*.jar and lib/boot.jar in each cluster.
533
     * Checks modules/{,autoload/,eager/}*.jar as well as well-known core/*.jar and lib/boot.jar in each cluster.
529
     * XXX would be slightly more precise to check config/Modules/*.xml rather than scan for module JARs.
534
     * XXX would be slightly more precise to check config/Modules/*.xml rather than scan for module JARs.
530
     */
535
     */
531
    private static void doScanBinaries(File build, Map<String,Entry> entries) throws IOException {
536
    private static void doScanBinaries(File cluster, Map<String,Entry> entries) throws IOException {
532
        File[] clusters = build.listFiles();
533
        if (clusters == null) {
534
            throw new IOException("Cannot examine dir " + build);
535
        }
536
        for (int i = 0; i < clusters.length; i++) {
537
            for (int j = 0; j < MODULE_DIRS.length; j++) {
537
            for (int j = 0; j < MODULE_DIRS.length; j++) {
538
                File dir = new File(clusters[i], MODULE_DIRS[j].replace('/', File.separatorChar));
538
                File dir = new File(cluster, MODULE_DIRS[j].replace('/', File.separatorChar));
539
                if (!dir.isDirectory()) {
539
                if (!dir.isDirectory()) {
540
                    continue;
540
                    continue;
541
                }
541
                }
Lines 577-583 Link Here
577
                        String moduleDependencies = attr.getValue("OpenIDE-Module-Module-Dependencies");
577
                        String moduleDependencies = attr.getValue("OpenIDE-Module-Module-Dependencies");
578
                        
578
                        
579
                        
579
                        
580
                        Entry entry = new Entry(codenamebase, m, exts,dir, null, null, clusters[i].getName(),
580
                        Entry entry = new Entry(codenamebase, m, exts,dir, null, null, cluster.getName(),
581
                                parseRuntimeDependencies(moduleDependencies), Collections.<String,String[]>emptyMap());
581
                                parseRuntimeDependencies(moduleDependencies), Collections.<String,String[]>emptyMap());
582
                        if (entries.containsKey(codenamebase)) {
582
                        if (entries.containsKey(codenamebase)) {
583
                            throw new IOException("Duplicated module " + codenamebase + ": found in " + entries.get(codenamebase) + " and " + entry);
583
                            throw new IOException("Duplicated module " + codenamebase + ": found in " + entries.get(codenamebase) + " and " + entry);
Lines 589-595 Link Here
589
                    }
589
                    }
590
                }
590
                }
591
            }
591
            }
592
        }
593
    }
592
    }
594
    
593
    
595
    private static Map<String,Entry> scanSuiteSources(Map<String,String> properties, Project project) throws IOException {
594
    private static Map<String,Entry> scanSuiteSources(Map<String,String> properties, Project project) throws IOException {
Lines 666-672 Link Here
666
     * Properties interpreted:
665
     * Properties interpreted:
667
     * <ol>
666
     * <ol>
668
     * <li> ${nb_all} - location of NB sources (used only for netbeans.org modules)
667
     * <li> ${nb_all} - location of NB sources (used only for netbeans.org modules)
669
     * <li> ${netbeans.dest.dir} - location of NB build
668
     * <li> ${netbeans.dest.dir} - location of NB build (used only for NB.org modules)
669
     * <li> ${cluster.path} - location of clusters to build against (used only for suite and standalone modules)
670
     * <li> ${basedir} - directory of the project initiating the scan (most significant for standalone modules)
670
     * <li> ${basedir} - directory of the project initiating the scan (most significant for standalone modules)
671
     * <li> ${suite.dir} - directory of the suite (used only for suite modules)
671
     * <li> ${suite.dir} - directory of the suite (used only for suite modules)
672
     * <li> ${nb.cluster.TOKEN} - list of module paths included in cluster TOKEN (comma-separated) (used only for netbeans.org modules)
672
     * <li> ${nb.cluster.TOKEN} - list of module paths included in cluster TOKEN (comma-separated) (used only for netbeans.org modules)
Lines 679-701 Link Here
679
     */
679
     */
680
    public ModuleListParser(Map<String,String> properties, int type, Project project) throws IOException {
680
    public ModuleListParser(Map<String,String> properties, int type, Project project) throws IOException {
681
        String nball = properties.get("nb_all");
681
        String nball = properties.get("nb_all");
682
        String buildS = properties.get("netbeans.dest.dir");
683
        File basedir = new File(properties.get("basedir"));
682
        File basedir = new File(properties.get("basedir"));
684
        if (buildS == null) {
683
        final FileUtils fu = FileUtils.getFileUtils();
685
            throw new IOException("No definition of netbeans.dest.dir in " + basedir);
684
686
        }
687
        // Resolve against basedir, and normalize ../ sequences and so on in case they are used.
688
        // Neither operation is likely to be needed, but just in case.
689
        File build = FileUtils.getFileUtils().normalize(FileUtils.getFileUtils().resolveFile(basedir, buildS).getAbsolutePath());
690
        if (!build.isDirectory()) {
691
            throw new IOException("No such netbeans.dest.dir: " + build);
692
        }
693
        if (type != ParseProjectXml.TYPE_NB_ORG) {
685
        if (type != ParseProjectXml.TYPE_NB_ORG) {
686
            // add extra clusters
687
            String suiteDirS = properties.get("suite.dir");
688
            boolean hasSuiteDir = suiteDirS != null && suiteDirS.length() > 0;
689
            String clusterPath = properties.get("cluster.path");
690
            File[] clusters = null;
691
692
            if (clusterPath != null) {
693
                String[] clustersS;
694
                if (hasSuiteDir) {
695
                    // resolve suite modules against fake suite project
696
                    Project fakeproj = new Project();
697
                    fakeproj.setBaseDir(new File(suiteDirS));
698
                    clustersS = Path.translatePath(fakeproj, clusterPath);
699
                } else {
700
                    clustersS = Path.translatePath(project, clusterPath);
701
                }
702
                clusters = new File[clustersS.length];
703
                if (clustersS != null && clustersS.length > 0) {
704
                    for (int j = 0; j < clustersS.length; j++) {
705
                        File cluster = new File(clustersS[j]);
706
                        if (! cluster.isDirectory()) {
707
                            throw new IOException("No such cluster " + cluster + " referred to from ${cluster.path}: " + clusterPath);
708
                        }
709
                        clusters[j] = cluster;
710
                    }
711
                }
712
            }
713
714
            if (clusters == null || clusters.length == 0)
715
                throw new IOException("Invalid ${cluster.path}: " + clusterPath);
716
694
            // External module.
717
            // External module.
695
            if (nball != null && project != null) {
718
            if (nball != null && project != null) {
696
                project.log("You must *not* declare <suite-component/> or <standalone/> for a netbeans.org module in " + basedir + "; fix project.xml to use the /2 schema", Project.MSG_WARN);
719
                project.log("You must *not* declare <suite-component/> or <standalone/> for a netbeans.org module in " + basedir + "; fix project.xml to use the /2 schema", Project.MSG_WARN);
697
            }
720
            }
698
            entries = scanBinaries(project, build);
721
            entries = scanBinaries(project, clusters);
699
            if (type == ParseProjectXml.TYPE_SUITE) {
722
            if (type == ParseProjectXml.TYPE_SUITE) {
700
                entries.putAll(scanSuiteSources(properties, project));
723
                entries.putAll(scanSuiteSources(properties, project));
701
            } else {
724
            } else {
Lines 705-716 Link Here
705
            }
728
            }
706
        } else {
729
        } else {
707
            // netbeans.org module.
730
            // netbeans.org module.
731
            String buildS = properties.get("netbeans.dest.dir");
732
            if (buildS == null) {
733
                throw new IOException("No definition of netbeans.dest.dir in " + basedir);
734
            }
735
            // Resolve against basedir, and normalize ../ sequences and so on in case they are used.
736
            // Neither operation is likely to be needed, but just in case.
737
            File build = fu.normalize(fu.resolveFile(basedir, buildS).getAbsolutePath());
738
            if (!build.isDirectory()) {
739
                throw new IOException("No such netbeans.dest.dir: " + build);
740
            }
741
742
            // expand clusters in build
743
            File[] clusters = build.listFiles();
744
            if (clusters == null) {
745
                throw new IOException("Cannot examine dir " + build);
746
            }
747
708
            if (nball == null) {
748
            if (nball == null) {
709
                throw new IOException("You must declare either <suite-component/> or <standalone/> for an external module in " + new File(properties.get("basedir")));
749
                throw new IOException("You must declare either <suite-component/> or <standalone/> for an external module in " + new File(properties.get("basedir")));
710
            }
750
            }
711
            if (!build.equals(new File(new File(nball, "nbbuild"), "netbeans"))) {
751
            if (!build.equals(new File(new File(nball, "nbbuild"), "netbeans"))) {
712
                // Potentially orphaned module to be built against specific binaries, plus perhaps other source deps.
752
                // Potentially orphaned module to be built against specific binaries, plus perhaps other source deps.
713
                entries = scanBinaries(project, build);
753
                entries = scanBinaries(project, clusters);
714
                // Add referenced module in case it does not appear otherwise.
754
                // Add referenced module in case it does not appear otherwise.
715
                Entry e = scanStandaloneSource(properties, project);
755
                Entry e = scanStandaloneSource(properties, project);
716
                if (e != null) {
756
                if (e != null) {
(-)a/nbbuild/antsrc/org/netbeans/nbbuild/ParseProjectXml.java (-29 / +34 lines)
Lines 54-62 Link Here
54
import java.io.UnsupportedEncodingException;
54
import java.io.UnsupportedEncodingException;
55
import java.util.ArrayList;
55
import java.util.ArrayList;
56
import java.util.Arrays;
56
import java.util.Arrays;
57
import java.util.Collections;
57
import java.util.HashMap;
58
import java.util.HashMap;
58
import java.util.HashSet;
59
import java.util.HashSet;
59
import java.util.Hashtable;
60
import java.util.Hashtable;
61
import java.util.Iterator;
60
import java.util.LinkedList;
62
import java.util.LinkedList;
61
import java.util.List;
63
import java.util.List;
62
import java.util.Map;
64
import java.util.Map;
Lines 73-78 Link Here
73
import org.apache.tools.ant.BuildException;
75
import org.apache.tools.ant.BuildException;
74
import org.apache.tools.ant.Project;
76
import org.apache.tools.ant.Project;
75
import org.apache.tools.ant.Task;
77
import org.apache.tools.ant.Task;
78
import org.apache.tools.ant.types.Path;
79
import org.apache.tools.ant.types.resources.FileResource;
80
import org.apache.tools.ant.util.CollectionUtils;
81
import org.apache.tools.ant.util.StringUtils;
76
import org.w3c.dom.Document;
82
import org.w3c.dom.Document;
77
import org.w3c.dom.Element;
83
import org.w3c.dom.Element;
78
import org.xml.sax.InputSource;
84
import org.xml.sax.InputSource;
Lines 621-627 Link Here
621
        }
627
        }
622
        
628
        
623
        private String implementationVersionOf(ModuleListParser modules, String cnb) throws BuildException {
629
        private String implementationVersionOf(ModuleListParser modules, String cnb) throws BuildException {
624
            File jar = computeClasspathModuleLocation(modules, cnb, null, null, null);
630
            File jar = computeClasspathModuleLocation(modules, cnb, null, null);
625
            if (!jar.isFile()) {
631
            if (!jar.isFile()) {
626
                throw new BuildException("No such classpath entry: " + jar, getLocation());
632
                throw new BuildException("No such classpath entry: " + jar, getLocation());
627
            }
633
            }
Lines 776-790 Link Here
776
    private String computeClasspath(Document pDoc, ModuleListParser modules, Dep[] deps, boolean runtime) throws BuildException, IOException, SAXException {
782
    private String computeClasspath(Document pDoc, ModuleListParser modules, Dep[] deps, boolean runtime) throws BuildException, IOException, SAXException {
777
        String myCnb = getCodeNameBase(pDoc);
783
        String myCnb = getCodeNameBase(pDoc);
778
        StringBuffer cp = new StringBuffer();
784
        StringBuffer cp = new StringBuffer();
779
        String includedClustersProp = getProject().getProperty("enabled.clusters");
785
        Path clusterPathS = (Path) getProject().getReference("cluster.path.id");
780
        Set<String> includedClusters = includedClustersProp != null ?
786
        Set<File> clusterPath = null;
781
            new HashSet<String>(Arrays.asList(includedClustersProp.split(" *, *"))) :
787
        if (clusterPathS != null) {
782
            null;
788
            clusterPath = new HashSet<File>();
783
        // Compatibility:
789
            for (Iterator it = clusterPathS.iterator(); it.hasNext();) {
784
        String excludedClustersProp = getProject().getProperty("disabled.clusters");
790
                File oneCluster = ((FileResource) it.next()).getFile();
785
        Set<String> excludedClusters = excludedClustersProp != null ?
791
                clusterPath.add(oneCluster);
786
            new HashSet<String>(Arrays.asList(excludedClustersProp.split(" *, *"))) :
792
            }
787
            null;
793
        }
788
        String excludedModulesProp = getProject().getProperty("disabled.modules");
794
        String excludedModulesProp = getProject().getProperty("disabled.modules");
789
        Set<String> excludedModules = excludedModulesProp != null ?
795
        Set<String> excludedModules = excludedModulesProp != null ?
790
            new HashSet<String>(Arrays.asList(excludedModulesProp.split(" *, *"))) :
796
            new HashSet<String>(Arrays.asList(excludedModulesProp.split(" *, *"))) :
Lines 794-800 Link Here
794
                continue;
800
                continue;
795
            }
801
            }
796
            String cnb = dep.codenamebase;
802
            String cnb = dep.codenamebase;
797
            File depJar = computeClasspathModuleLocation(modules, cnb, includedClusters, excludedClusters, excludedModules);
803
            File depJar = computeClasspathModuleLocation(modules, cnb, clusterPath, excludedModules);
798
            
804
            
799
            Attributes attr;
805
            Attributes attr;
800
            if (!depJar.isFile()) {
806
            if (!depJar.isFile()) {
Lines 819-825 Link Here
819
            additions.add(depJar);
825
            additions.add(depJar);
820
            if (runtime) {
826
            if (runtime) {
821
                Set<String> skipCnb = new HashSet<String>();
827
                Set<String> skipCnb = new HashSet<String>();
822
                addRecursiveDeps(additions, modules, cnb, includedClusters, excludedClusters, excludedModules, skipCnb);
828
                addRecursiveDeps(additions, modules, cnb, clusterPath, excludedModules, skipCnb);
823
            }
829
            }
824
            
830
            
825
            // #52354: look for <class-path-extension>s in dependent modules.
831
            // #52354: look for <class-path-extension>s in dependent modules.
Lines 862-877 Link Here
862
        return cp.toString();
868
        return cp.toString();
863
    }
869
    }
864
    
870
    
865
    private void addRecursiveDeps(List<File> additions, ModuleListParser modules, String cnb, Set<String> includedClusters, 
871
    private void addRecursiveDeps(List<File> additions, ModuleListParser modules, String cnb, 
866
        Set<String> excludedClusters, Set<String> excludedModules, Set<String> skipCnb
872
            Set<File> clusterPath, Set<String> excludedModules, Set<String> skipCnb) {
867
    ) {
868
        if (!skipCnb.add(cnb)) {
873
        if (!skipCnb.add(cnb)) {
869
            return;
874
            return;
870
        }
875
        }
871
        log("Processing for recursive deps: " + cnb, Project.MSG_VERBOSE); // NO18N
876
        log("Processing for recursive deps: " + cnb, Project.MSG_VERBOSE); // NO18N
872
        for (String nextModule : modules.findByCodeNameBase(cnb).getRuntimeDependencies()) {
877
        for (String nextModule : modules.findByCodeNameBase(cnb).getRuntimeDependencies()) {
873
            log("  Added dep: " + nextModule, Project.MSG_VERBOSE); // NO18N
878
            log("  Added dep: " + nextModule, Project.MSG_VERBOSE); // NO18N
874
            File depJar = computeClasspathModuleLocation(modules, nextModule, includedClusters, excludedClusters, excludedModules);
879
            File depJar = computeClasspathModuleLocation(modules, nextModule, clusterPath, excludedModules);
875
            
880
            
876
            if (!depJar.isFile()) {
881
            if (!depJar.isFile()) {
877
                log("No such classpath entry: " + depJar, Project.MSG_WARN);
882
                log("No such classpath entry: " + depJar, Project.MSG_WARN);
Lines 890-917 Link Here
890
                }
895
                }
891
            }
896
            }
892
            
897
            
893
            addRecursiveDeps(additions, modules, nextModule, includedClusters, excludedClusters, excludedModules, skipCnb);
898
            addRecursiveDeps(additions, modules, nextModule, clusterPath, excludedModules, skipCnb);
894
        }
899
        }
895
    }
900
    }
896
    
901
    
897
    private File computeClasspathModuleLocation(ModuleListParser modules, String cnb,
902
    private File computeClasspathModuleLocation(ModuleListParser modules, String cnb,
898
            Set<String> includedClusters, Set<String> excludedClusters, Set<String> excludedModules) throws BuildException {
903
            Set<File> clusterPath, Set<String> excludedModules) throws BuildException {
899
        ModuleListParser.Entry module = modules.findByCodeNameBase(cnb);
904
        ModuleListParser.Entry module = modules.findByCodeNameBase(cnb);
900
        if (module == null) {
905
        if (module == null) {
901
            throw new BuildException("No dependent module " + cnb, getLocation());
906
            throw new BuildException("No dependent module " + cnb, getLocation());
902
        }
907
        }
903
        String cluster = module.getClusterName();
908
        File jar = module.getJar();
904
        if (cluster != null) { // #68716
909
        if (jar == null) return null;
905
            if ((includedClusters != null && !includedClusters.isEmpty() && ! ModuleSelector.clusterMatch(includedClusters, cluster)) ||
910
906
                    ((includedClusters == null || includedClusters.isEmpty()) && excludedClusters != null && excludedClusters.contains(cluster))) {
911
        if (clusterPath != null) {
907
                throw new BuildException("The module " + cnb + " cannot be compiled against because it is part of the cluster " + cluster +
912
            File clusterF = jar.getParentFile().getParentFile();
908
                                         " which has been excluded from the target platform in your suite configuration", getLocation());
913
            if (! clusterPath.contains(clusterF))
909
            }
914
                throw new BuildException("The module " + cnb + " cannot be compiled against because it is part of the cluster "
910
            if (excludedModules != null && excludedModules.contains(cnb)) { // again #68716
915
                        + clusterF
911
                throw new BuildException("Module " + cnb + " excluded from the target platform", getLocation());
916
                        + " which is not part of cluster.path in your suite configuration.\n\n"
912
            }
917
                        + "Cluster.path is: " + clusterPath, getLocation());
913
        }
918
        }
914
        return module.getJar();
919
        return jar;
915
    }
920
    }
916
 
921
 
917
  final class TestDeps {
922
  final class TestDeps {
(-)a/nbbuild/antsrc/org/netbeans/nbbuild/PathFileSet.java (+269 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.nbbuild;
41
42
import java.util.ArrayList;
43
import java.util.Enumeration;
44
import java.util.Iterator;
45
import java.util.List;
46
import org.apache.tools.ant.BuildException;
47
import org.apache.tools.ant.DirectoryScanner;
48
import org.apache.tools.ant.Project;
49
import org.apache.tools.ant.types.DataType;
50
import org.apache.tools.ant.types.Path;
51
import org.apache.tools.ant.types.ResourceCollection;
52
import org.apache.tools.ant.types.resources.FileResource;
53
import org.apache.tools.ant.types.selectors.AbstractSelectorContainer;
54
import org.apache.tools.ant.types.selectors.AndSelector;
55
import org.apache.tools.ant.types.selectors.ContainsRegexpSelector;
56
import org.apache.tools.ant.types.selectors.ContainsSelector;
57
import org.apache.tools.ant.types.selectors.DateSelector;
58
import org.apache.tools.ant.types.selectors.DependSelector;
59
import org.apache.tools.ant.types.selectors.DepthSelector;
60
import org.apache.tools.ant.types.selectors.DifferentSelector;
61
import org.apache.tools.ant.types.selectors.ExtendSelector;
62
import org.apache.tools.ant.types.selectors.FileSelector;
63
import org.apache.tools.ant.types.selectors.FilenameSelector;
64
import org.apache.tools.ant.types.selectors.MajoritySelector;
65
import org.apache.tools.ant.types.selectors.NoneSelector;
66
import org.apache.tools.ant.types.selectors.NotSelector;
67
import org.apache.tools.ant.types.selectors.OrSelector;
68
import org.apache.tools.ant.types.selectors.PresentSelector;
69
import org.apache.tools.ant.types.selectors.SelectSelector;
70
import org.apache.tools.ant.types.selectors.SelectorContainer;
71
import org.apache.tools.ant.types.selectors.SizeSelector;
72
import org.apache.tools.ant.types.selectors.TypeSelector;
73
import org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector;
74
75
/**
76
 *
77
 * @author Richard Michalsky
78
 */
79
public class PathFileSet extends DataType implements ResourceCollection, SelectorContainer {
80
    private Path clusterPath;
81
    private String include;
82
    private AbstractSelectorContainer selectors = new AbstractSelectorContainer() {};
83
    private ArrayList<FileResource> files;
84
85
    /**
86
     * Optional include pattern for filtering files. The same as fileset's nested &gt;include&lt; tag.
87
     *
88
     * Note that pattern is matched against <b>relative</b> path starting at each pathelement.
89
     * E.g. when there is file <tt>/a/b/c/d.txt</tt>, it will be included in result
90
     * of:
91
     * <pre>&lt;pathfileset include="c/**.txt property="output"&gt;
92
     *      &lt;path path="/a/b"/&gt;
93
     * &lt;/pathfileset&gt;</pre>
94
     * and it won't be included in result of:
95
     * <pre>&lt;pathfileset include="b/**.txt property="output"&gt;
96
     *      &lt;path path="/a/b"/&gt;
97
     * &lt;/pathfileset&gt;</pre>
98
     * @param include
99
     */
100
    public void setInclude(String include) {
101
        this.include = include;
102
    }
103
104
    private List<Path> paths = new ArrayList<Path>();
105
106
    /**
107
     * Adds path in classpath notation. Searched in addition
108
     * to any nested paths.
109
     * @param stringPath
110
     */
111
    public void setPath(Path stringPath) {
112
        addPath(stringPath);
113
    }
114
115
    /**
116
     * Elements of nested paths are used as basedirs for fileset.
117
     * @param clusterPath
118
     */
119
    public void addPath(Path clusterPath) {
120
        paths.add(clusterPath);
121
    }
122
123
    // SelectorContainer impl.
124
125
    public Enumeration selectorElements() {
126
        return selectors.selectorElements();
127
    }
128
129
    public int selectorCount() {
130
        return selectors.selectorCount();
131
    }
132
133
    public boolean hasSelectors() {
134
        return selectors.hasSelectors();
135
    }
136
137
    public FileSelector[] getSelectors(Project p) {
138
        return selectors.getSelectors(p);
139
    }
140
141
    public void appendSelector(FileSelector selector) {
142
        selectors.appendSelector(selector);
143
    }
144
145
    public void addType(TypeSelector selector) {
146
        selectors.addType(selector);
147
    }
148
149
    public void addSize(SizeSelector selector) {
150
        selectors.addSize(selector);
151
    }
152
153
    public void addSelector(SelectSelector selector) {
154
        selectors.addSelector(selector);
155
    }
156
157
    public void addPresent(PresentSelector selector) {
158
        selectors.addPresent(selector);
159
    }
160
161
    public void addOr(OrSelector selector) {
162
        selectors.addOr(selector);
163
    }
164
165
    public void addNot(NotSelector selector) {
166
        selectors.addNot(selector);
167
    }
168
169
    public void addNone(NoneSelector selector) {
170
        selectors.addNone(selector);
171
    }
172
173
    public void addModified(ModifiedSelector selector) {
174
        selectors.addModified(selector);
175
    }
176
177
    public void addMajority(MajoritySelector selector) {
178
        selectors.addMajority(selector);
179
    }
180
181
    public void addFilename(FilenameSelector selector) {
182
        selectors.addFilename(selector);
183
    }
184
185
    public void addDifferent(DifferentSelector selector) {
186
        selectors.addDifferent(selector);
187
    }
188
189
    public void addDepth(DepthSelector selector) {
190
        selectors.addDepth(selector);
191
    }
192
193
    public void addDepend(DependSelector selector) {
194
        selectors.addDepend(selector);
195
    }
196
197
    public void addDate(DateSelector selector) {
198
        selectors.addDate(selector);
199
    }
200
201
    public void addCustom(ExtendSelector selector) {
202
        selectors.addCustom(selector);
203
    }
204
205
    public void addContainsRegexp(ContainsRegexpSelector selector) {
206
        selectors.addContainsRegexp(selector);
207
    }
208
209
    public void addContains(ContainsSelector selector) {
210
        selectors.addContains(selector);
211
    }
212
213
    public void addAnd(AndSelector selector) {
214
        selectors.addAnd(selector);
215
    }
216
217
    public void add(FileSelector selector) {
218
        selectors.add(selector);
219
    }
220
221
    // ResourceCollection impl.
222
223
    public Iterator iterator() {
224
        initFiles();
225
        return files.iterator();
226
    }
227
228
    public int size() {
229
        initFiles();
230
        return files.size();
231
    }
232
233
    public boolean isFilesystemOnly() {
234
        return true;
235
    }
236
237
    private void initFiles() throws BuildException {
238
        if (files != null) return;
239
        try {
240
            files = new ArrayList<FileResource>();
241
            log("ClusterPathSet: scanning " + paths.size() + " paths.", Project.MSG_VERBOSE);
242
            DirectoryScanner scanner = new DirectoryScanner();
243
            if (paths.size() == 0) {
244
                throw new BuildException("No path specified");
245
            }
246
            for (Path path : paths) {
247
                String[] includedClusters = path.list();
248
                for (String clusterName : includedClusters) {
249
                    log("ClusterPathSet: scanning pathelement '" + clusterName + "'.", Project.MSG_VERBOSE);
250
                    scanner.setBasedir(clusterName);
251
                    scanner.setSelectors(selectors.getSelectors(getProject()));
252
                    if (include != null) {
253
                        scanner.setIncludes(new String[]{include});
254
                    }
255
                    scanner.scan();
256
                    log("ClusterPathSet: " + scanner.getIncludedFilesCount() + " files found.", Project.MSG_VERBOSE);
257
                    for (String relFile : scanner.getIncludedFiles()) {
258
                        files.add(new FileResource(scanner.getBasedir(), relFile));
259
                    }
260
                }
261
            }
262
        } catch (BuildException ex) {
263
            throw ex;
264
        } catch (Exception ex) {
265
            throw new BuildException(ex);
266
        }
267
    }
268
269
}
(-)a/nbbuild/default.xml (+14 lines)
Lines 108-113 Link Here
108
    <taskdef name="convertimport"
108
    <taskdef name="convertimport"
109
         classname="org.netbeans.nbbuild.ConvertImport"
109
         classname="org.netbeans.nbbuild.ConvertImport"
110
         classpath="${nb_all}/nbbuild/nbantext.jar"/>
110
         classpath="${nb_all}/nbbuild/nbantext.jar"/>
111
    <taskdef name="convertclusterpath"
112
         classname="org.netbeans.nbbuild.ConvertClusterPath"
113
         classpath="${nb_all}/nbbuild/nbantext.jar"/>
114
    <typedef name="pathfileset" classname="org.netbeans.nbbuild.PathFileSet"
115
         classpath="${nb_all}/nbbuild/nbantext.jar"/>
111
    <property name="tasks-already-set" value="true"/>
116
    <property name="tasks-already-set" value="true"/>
112
  </target>
117
  </target>
113
  
118
  
Lines 128-133 Link Here
128
      <entry  key="${module.name}.dir" value="$${netbeans.dest.dir}/${cluster.dir}"/>
133
      <entry  key="${module.name}.dir" value="$${netbeans.dest.dir}/${cluster.dir}"/>
129
    </propertyfile>
134
    </propertyfile>
130
    <property name="${module.name}.dir" value="${netbeans.dest.dir}/${cluster.dir}"/>
135
    <property name="${module.name}.dir" value="${netbeans.dest.dir}/${cluster.dir}"/>
136
137
    <!-- netbeans.dest.dir -> cluster.path.id translation for NB.org modules -->
138
    <!-- XXX Does not preserve order of clusters specified in etc/netbeans.clusters -->
139
    <pathconvert property="cluster.path.evaluated">
140
        <path>
141
            <dirset dir="${netbeans.dest.dir}" includesfile="${netbeans.dest.dir}/etc/netbeans.clusters"/>
142
        </path>
143
    </pathconvert>
144
    <convertclusterpath from="${cluster.path.evaluated}" to="cluster.path" id="cluster.path.id"/>
131
  </target>
145
  </target>
132
  
146
  
133
</project>
147
</project>
(-)a/nbbuild/templates/common.xml (-2 / +5 lines)
Lines 340-346 Link Here
340
            <license file="${license.file.override}"/>
340
            <license file="${license.file.override}"/>
341
            <signature keystore="${keystore}" storepass="${storepass}" alias="${nbm_alias}"/>
341
            <signature keystore="${keystore}" storepass="${storepass}" alias="${nbm_alias}"/>
342
            <updaterjar>
342
            <updaterjar>
343
                <fileset dir="${netbeans.dest.dir}" includes="platform*/modules/ext/updater.jar"/>
343
                <pathfileset>
344
                    <path refid="cluster.path.id"/>
345
                    <filename name="modules/ext/updater.jar"/>
346
                </pathfileset>
344
            </updaterjar>
347
            </updaterjar>
345
        </makenbm>
348
        </makenbm>
346
    </target>
349
    </target>
Lines 486-492 Link Here
486
                          extralibs="extra.test.libs.short"
489
                          extralibs="extra.test.libs.short"
487
                          extralibsdir="${extra.test.libs.dir}"
490
                          extralibsdir="${extra.test.libs.dir}"
488
                          testproperties="${test.@{test.type}.out.folder}/test.properties">
491
                          testproperties="${test.@{test.type}.out.folder}/test.properties">
489
                <replacement dir="${netbeans.dest.dir}" name="netbeans.dest.dir"/>
492
                <replacement dir="${netbeans.dest.dir}" name="netbeans.dest.dir"/> <!-- for pre-7.0 and NB.org projects -->
490
                <replacement dir="${test.dist.dir}" name="test.dist.dir"/>
493
                <replacement dir="${test.dist.dir}" name="test.dist.dir"/>
491
                <!-- XXX this will not be right on Macs: -->
494
                <!-- XXX this will not be right on Macs: -->
492
                <replacement dir="${nbjdk.home}/jre" name="java.home"/>
495
                <replacement dir="${nbjdk.home}/jre" name="java.home"/>
(-)a/nbbuild/test/unit/src/org/netbeans/nbbuild/PathFileSetTest.java (+241 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.nbbuild;
41
42
import java.io.File;
43
import java.io.IOException;
44
import java.util.ArrayList;
45
import java.util.Arrays;
46
import java.util.Iterator;
47
import java.util.StringTokenizer;
48
import org.apache.tools.ant.BuildEvent;
49
import org.apache.tools.ant.BuildException;
50
import org.apache.tools.ant.BuildListener;
51
import org.apache.tools.ant.DirectoryScanner;
52
import org.apache.tools.ant.Project;
53
import org.apache.tools.ant.types.Path;
54
import org.apache.tools.ant.types.resources.FileResource;
55
import org.apache.tools.ant.types.selectors.FilenameSelector;
56
import org.junit.AfterClass;
57
import org.junit.BeforeClass;
58
import org.junit.Test;
59
import org.netbeans.junit.NbTestCase;
60
import static org.junit.Assert.*;
61
62
/**
63
 *
64
 * @author Richard Michalsky
65
 */
66
public class PathFileSetTest extends NbTestCase {
67
68
    private PathFileSet pfs;
69
    private Project fakeproj;
70
    private ClusterRecord cl1;
71
    private ClusterRecord cl2;
72
73
    public PathFileSetTest(String testName) {
74
        super(testName);
75
    }
76
77
    @BeforeClass
78
    public static void setUpClass() throws Exception {
79
    }
80
81
    @AfterClass
82
    public static void tearDownClass() throws Exception {
83
    }
84
85
//    @Before
86
    @Override
87
    protected void setUp() throws IOException {
88
        clearWorkDir();
89
        pfs = new PathFileSet();
90
        fakeproj = new Project();
91
        fakeproj.setBaseDir(getWorkDir());
92
        fakeproj.addBuildListener(new BuildListener() {
93
94
            public void messageLogged(BuildEvent buildEvent) {
95
                if (buildEvent.getPriority() <= Project.MSG_VERBOSE) {
96
                    System.err.println(buildEvent.getMessage());
97
                }
98
            }
99
100
            public void taskStarted(BuildEvent buildEvent) {
101
            }
102
103
            public void taskFinished(BuildEvent buildEvent) {
104
            }
105
106
            public void targetStarted(BuildEvent buildEvent) {
107
            }
108
109
            public void targetFinished(BuildEvent buildEvent) {
110
            }
111
112
            public void buildStarted(BuildEvent buildEvent) {
113
            }
114
115
            public void buildFinished(BuildEvent buildEvent) {
116
            }
117
        });
118
        pfs.setProject(fakeproj);
119
        cl1 = new ClusterRecord("cl1").create().addModule("org-m1", true, true, true);
120
        cl2 = new ClusterRecord("cl2").create().addModule("org-m2", true, false, false);
121
        pfs.addPath(new Path(fakeproj, "cl1" + File.pathSeparator + "cl2"));
122
    }
123
124
//    @After
125
    @Override
126
    protected void tearDown() {
127
    }
128
129
    private void executeAndCheckResults(String[] expected) throws BuildException, IOException {
130
        String[] output = new String[pfs.size()];
131
        int j = 0;
132
        for (Iterator it = pfs.iterator(); it.hasNext(); j++) {
133
            FileResource fileResource = (FileResource) it.next();
134
            String path = fileResource.getFile().getAbsolutePath().replace('\\', '/');
135
            output[j] = path;
136
        }
137
        Arrays.sort(output);
138
        String wd = getWorkDir().getPath().replace('\\', '/').concat("/");
139
        for (int i = 0; i < expected.length; i++) {
140
            expected[i] = wd + expected[i];
141
        }
142
        assertArrayEquals(expected, output);
143
    }
144
145
    private class ClusterRecord {
146
147
        File ut;
148
        File cm;
149
        File m;
150
        private String clusterName;
151
152
        public ClusterRecord(String clusterName) {
153
            this.clusterName = clusterName;
154
        }
155
156
        public ClusterRecord create() throws IOException {
157
            ut = new File(getWorkDir(), clusterName + "/update_tracking");
158
            ut.mkdirs();
159
            assertTrue(ut.isDirectory());
160
161
            cm = new File(getWorkDir(), clusterName + "/config/Modules");
162
            cm.mkdirs();
163
            assertTrue(cm.isDirectory());
164
165
            m = new File(getWorkDir(), clusterName + "/modules");
166
            m.mkdirs();
167
            assertTrue(m.isDirectory());
168
            return this;
169
        }
170
171
        public ClusterRecord addModule(String dashedCNB, boolean jar, boolean config, boolean updateTracking) throws IOException {
172
            if (updateTracking) {
173
                assertTrue(new File(ut, dashedCNB + ".xml").createNewFile());
174
            }
175
            if (jar) {
176
                assertTrue(new File(m, dashedCNB + ".jar").createNewFile());
177
            }
178
            if (config) {
179
                assertTrue(new File(cm, dashedCNB + ".xml").createNewFile());
180
            }
181
            return this;
182
        }
183
    }
184
185
    @Test
186
    public void testFindAllFiles() throws IOException {
187
        executeAndCheckResults(new String[]{"cl1/config/Modules/org-m1.xml",
188
                    "cl1/modules/org-m1.jar",
189
                    "cl1/update_tracking/org-m1.xml",
190
                    "cl2/modules/org-m2.jar"});
191
    }
192
193
    @Test
194
    public void testWildcardIncludes() throws IOException {
195
        pfs.setInclude("**/*.jar");
196
        executeAndCheckResults(new String[]{"cl1/modules/org-m1.jar", "cl2/modules/org-m2.jar"});
197
    }
198
199
    @Test
200
    public void testSimpleIncludes() throws IOException {
201
        pfs.setInclude("modules/org-m1.jar");
202
        executeAndCheckResults(new String[]{"cl1/modules/org-m1.jar"});
203
    }
204
205
    @Test
206
    /** Cluster name is part of the basedir and thus WON'T match. */
207
    public void testWrongRelativeIncludes() throws IOException {
208
        pfs.setInclude("cl1/modules/org-m1.jar");
209
        assertEquals(pfs.size(), 0);
210
    }
211
212
    @Test
213
    public void testEmptySet() throws IOException {
214
        pfs.setInclude("pattern not present");
215
        assertEquals(pfs.size(), 0);
216
    }
217
218
    @Test
219
    public void testFileNameSelector() throws IOException {
220
        FilenameSelector sel = new FilenameSelector();
221
        sel.setCasesensitive(false);
222
        sel.setName("**/config/**/*.xml");
223
        pfs.add(sel);
224
        executeAndCheckResults(new String[]{"cl1/config/Modules/org-m1.xml"});
225
    }
226
227
    @Test
228
    public void testPathAttribute() throws IOException {
229
        new ClusterRecord("cl3").create().addModule("org-m3", true, false, false);
230
        new ClusterRecord("cl4").create().addModule("org-m4", true, false, false);
231
        Path path = new Path(fakeproj, getWorkDir().getPath() + File.separator + "cl3"
232
                + File.pathSeparator
233
                + getWorkDir().getPath() + File.separator + "cl4");
234
        pfs.setPath(path);
235
        pfs.setInclude("**/*.jar");
236
        executeAndCheckResults(new String[] {
237
            "cl1/modules/org-m1.jar", "cl2/modules/org-m2.jar",
238
            "cl3/modules/org-m3.jar", "cl4/modules/org-m4.jar"
239
        });
240
    }
241
}
(-)a/o.n.bootstrap/nbproject/project.properties (+1 lines)
Lines 45-48 Link Here
45
45
46
javadoc.arch=${basedir}/arch.xml
46
javadoc.arch=${basedir}/arch.xml
47
47
48
# When changing this list, change 'verifyexcludes' param. of 'makejnlp' task in apisupport.harness/release/jnlp.xml as well
48
jnlp.verify.excludes=lib/nbexec, lib/nbexec.exe, lib/nbexec.dll
49
jnlp.verify.excludes=lib/nbexec, lib/nbexec.exe, lib/nbexec.dll

Return to bug 152960