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 207137
Collapse All | Expand All

(-)a/apisupport.ant/src/org/netbeans/modules/apisupport/project/suite/resources/platform.xsl (-1 / +1 lines)
Lines 31-37 Link Here
31
                <property name="tasks.jar" location="${{java.io.tmpdir}}/tasks.jar"/>
31
                <property name="tasks.jar" location="${{java.io.tmpdir}}/tasks.jar"/>
32
                <get src="${{bootstrap.url}}" dest="${{tasks.jar}}" usetimestamp="true" verbose="true"/>
32
                <get src="${{bootstrap.url}}" dest="${{tasks.jar}}" usetimestamp="true" verbose="true"/>
33
                <taskdef name="autoupdate" classname="org.netbeans.nbbuild.AutoUpdate" classpath="${{tasks.jar}}"/>
33
                <taskdef name="autoupdate" classname="org.netbeans.nbbuild.AutoUpdate" classpath="${{tasks.jar}}"/>
34
                <autoupdate installdir="${{nbplatform.active.dir}}" updatecenter="${{autoupdate.catalog.url}}">
34
                <autoupdate installdir="${{nbplatform.active.dir}}" updatecenter="${{autoupdate.catalog.url}}" cache="${{autoupdate.cache}}">
35
                    <modules includes="${{module.includes}}.*" clusters="${{download.clusters}}"/>
35
                    <modules includes="${{module.includes}}.*" clusters="${{download.clusters}}"/>
36
                    <modules includes="org[.]netbeans[.]modules[.]apisupport[.]harness" clusters="harness"/>
36
                    <modules includes="org[.]netbeans[.]modules[.]apisupport[.]harness" clusters="harness"/>
37
                </autoupdate>
37
                </autoupdate>
(-)a/apisupport.harness/release/README (-3 / +6 lines)
Lines 777-787 Link Here
777
nbm.target.cluster [since 5.0u2] - allow to declare a target cluster where
777
nbm.target.cluster [since 5.0u2] - allow to declare a target cluster where
778
install if NBM install globally.
778
install if NBM install globally.
779
779
780
autoupdate.catalog.url - if you want to use module's or suite's update target
780
autoupdate.catalog.url [since 7.1] - if you want to use module's or suite's update target
781
during build, you need to specify the URL of your NBMs catalog. Since 7.1, this
781
during build, you need to specify the URL of your NBMs catalog.
782
may be used (in conjunction with bootstrap.url) to download the harness and
782
May be used (in conjunction with bootstrap.url) to download the harness and
783
platform from an update site.
783
platform from an update site.
784
784
785
autoupdate.cache [since 7.2] - optional location of per-user/machine update cache.
786
785
netbeans.dest.dir - [up to 6.5.1] absolute pathname of NB platform (or IDE or 
787
netbeans.dest.dir - [up to 6.5.1] absolute pathname of NB platform (or IDE or 
786
whatever) that you are building your module against, and into which your module 
788
whatever) that you are building your module against, and into which your module 
787
will be built. Available in project.properties (and in all properties files for 
789
will be built. Available in project.properties (and in all properties files for 
Lines 1042-1047 Link Here
1042
+harness.dir=${nbplatform.active.dir}/harness
1044
+harness.dir=${nbplatform.active.dir}/harness
1043
+bootstrap.url=http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/lastStableBuild/artifact/nbbuild/netbeans/harness/tasks.jar
1045
+bootstrap.url=http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/lastStableBuild/artifact/nbbuild/netbeans/harness/tasks.jar
1044
+autoupdate.catalog.url=http://updates.netbeans.org/netbeans/updates/7.0.1/uc/final/distribution/catalog.xml.gz
1046
+autoupdate.catalog.url=http://updates.netbeans.org/netbeans/updates/7.0.1/uc/final/distribution/catalog.xml.gz
1047
+autoupdate.cache=${user.home}/.cache/nbupdate
1045
1048
1046
cluster.path [since 6.7] - list of clusters to build your modules against and
1049
cluster.path [since 6.7] - list of clusters to build your modules against and
1047
include in your application.
1050
include in your application.
(-)a/apisupport.harness/release/suite.xml (+1 lines)
Lines 599-604 Link Here
599
        <subant target="update" buildpath="${modules.test.sorted}" inheritrefs="false" inheritall="false">
599
        <subant target="update" buildpath="${modules.test.sorted}" inheritrefs="false" inheritall="false">
600
            <property name="cluster.path.evaluated" value="${cluster.path.evaluated}"/> <!-- Just for speed of pre-7.0 projects -->
600
            <property name="cluster.path.evaluated" value="${cluster.path.evaluated}"/> <!-- Just for speed of pre-7.0 projects -->
601
            <property name="autoupdate.catalog.url" value="${autoupdate.catalog.url}"/>
601
            <property name="autoupdate.catalog.url" value="${autoupdate.catalog.url}"/>
602
            <property name="autoupdate.cache" value="${autoupdate.cache}"/>
602
        </subant>
603
        </subant>
603
    </target>
604
    </target>
604
605
(-)a/nbbuild/antsrc/org/netbeans/nbbuild/AutoUpdate.java (-10 / +48 lines)
Lines 74-79 Link Here
74
import org.apache.tools.ant.Task;
74
import org.apache.tools.ant.Task;
75
import org.apache.tools.ant.taskdefs.Get;
75
import org.apache.tools.ant.taskdefs.Get;
76
import org.apache.tools.ant.types.FileSet;
76
import org.apache.tools.ant.types.FileSet;
77
import org.apache.tools.ant.util.FileUtils;
77
import org.netbeans.nbbuild.AutoUpdateCatalogParser.ModuleItem;
78
import org.netbeans.nbbuild.AutoUpdateCatalogParser.ModuleItem;
78
import org.w3c.dom.Document;
79
import org.w3c.dom.Document;
79
import org.w3c.dom.Element;
80
import org.w3c.dom.Element;
Lines 94-99 Link Here
94
    private File cluster;
95
    private File cluster;
95
    private URL catalog;
96
    private URL catalog;
96
    private boolean force;
97
    private boolean force;
98
    private File cache;
99
    boolean optimizeForLocal; // for test
97
100
98
    public void setUpdateCenter(URL u) {
101
    public void setUpdateCenter(URL u) {
99
        catalog = u;
102
        catalog = u;
Lines 130-135 Link Here
130
        return m;
133
        return m;
131
    }
134
    }
132
135
136
    /**
137
     * Location of per-user cache of already downloaded binaries.
138
     * Optional; no cache will be used if unset.
139
     * The directory will be created if it does not yet exist.
140
     */
141
    public void setCache(File cache) {
142
        if (cache.getAbsolutePath().contains("${")) {
143
            log("Ignoring unevaluated cache dir: " + cache, Project.MSG_INFO);
144
        } else {
145
            this.cache = cache;
146
        }
147
    }
148
133
    @Override
149
    @Override
134
    public void execute() throws BuildException {
150
    public void execute() throws BuildException {
135
        boolean downloadOnly = false;
151
        boolean downloadOnly = false;
Lines 183-189 Link Here
183
        }
199
        }
184
200
185
201
186
        for (ModuleItem uu : units.values()) {
202
        for (Map.Entry<String,ModuleItem> entry : units.entrySet()) {
203
            String id = entry.getKey();
204
            ModuleItem uu = entry.getValue();
187
            if (!matches(uu.getCodeName(), uu.targetcluster)) {
205
            if (!matches(uu.getCodeName(), uu.targetcluster)) {
188
                continue;
206
                continue;
189
            }
207
            }
Lines 201-207 Link Here
201
            boolean delete = false;
219
            boolean delete = false;
202
            File lastM = null;
220
            File lastM = null;
203
            try {
221
            try {
204
                if (download == null && uu.getURL().getProtocol().equals("file")) {
222
                if (download == null && uu.getURL().getProtocol().equals("file") && !optimizeForLocal) {
205
                    try {
223
                    try {
206
                        tmp = new File(uu.getURL().toURI());
224
                        tmp = new File(uu.getURL().toURI());
207
                    } catch (URISyntaxException ex) {
225
                    } catch (URISyntaxException ex) {
Lines 232-244 Link Here
232
                    } else {
250
                    } else {
233
                        log("Version " + info.get(0) + " of " + uu.getCodeName() + " needs update to " + uu.getSpecVersion(), Project.MSG_INFO);
251
                        log("Version " + info.get(0) + " of " + uu.getCodeName() + " needs update to " + uu.getSpecVersion(), Project.MSG_INFO);
234
                    }
252
                    }
235
                    Get get = new Get();
253
                    if (cache == null) {
236
                    get.setProject(getProject());
254
                        download(uu, tmp);
237
                    get.setTaskName("get:" + uu.getCodeName());
255
                    } else {
238
                    get.setSrc(uu.getURL());
256
                        File cacheLoc = new File(cache, id + ".nbm");
239
                    get.setDest(tmp);
257
                        if (cacheLoc.isFile()) {
240
                    get.setVerbose(true);
258
                            log("Cache hit: " + cacheLoc, Project.MSG_INFO);
241
                    get.execute();
259
                        } else {
260
                            cache.mkdirs();
261
                            File momentary = new File(cacheLoc.getParentFile(), cacheLoc.getName() + ".tmp");
262
                            momentary.delete();
263
                            download(uu, momentary);
264
                            if (!momentary.renameTo(cacheLoc)) {
265
                                throw new IOException("rename " + momentary + " to " + cacheLoc);
266
                            }
267
                        }
268
                        FileUtils.getFileUtils().copyFile(cacheLoc, tmp, null, true);
269
                    }
242
                }
270
                }
243
                if (downloadOnly) {
271
                if (downloadOnly) {
244
                    continue;
272
                    continue;
Lines 346-352 Link Here
346
                    config.close();
374
                    config.close();
347
                }
375
                }
348
            } catch (IOException ex) {
376
            } catch (IOException ex) {
349
                throw new BuildException(ex);
377
                throw new BuildException("Failed to unpack " + tmp, ex);
350
            } finally {
378
            } finally {
351
                if (delete && tmp != null) {
379
                if (delete && tmp != null) {
352
                    tmp.delete();
380
                    tmp.delete();
Lines 357-362 Link Here
357
            }
385
            }
358
        }
386
        }
359
    }
387
    }
388
389
    private void download(ModuleItem uu, File f) throws BuildException {
390
        Get get = new Get();
391
        get.setProject(getProject());
392
        get.setTaskName("get:" + uu.getCodeName());
393
        get.setSrc(uu.getURL());
394
        get.setDest(f);
395
        get.setVerbose(true);
396
        get.execute();
397
    }
360
    
398
    
361
    private InputStream externalDownload(InputStream is, AtomicLong crc) throws IOException {
399
    private InputStream externalDownload(InputStream is, AtomicLong crc) throws IOException {
362
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
400
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
(-)a/nbbuild/antsrc/org/netbeans/nbbuild/AutoUpdateCatalogParser.java (-2 / +8 lines)
Lines 61-66 Link Here
61
import java.util.List;
61
import java.util.List;
62
import java.util.Map;
62
import java.util.Map;
63
import java.util.Stack;
63
import java.util.Stack;
64
import java.util.TreeMap;
64
import java.util.jar.Manifest;
65
import java.util.jar.Manifest;
65
import java.util.logging.Level;
66
import java.util.logging.Level;
66
import java.util.logging.Logger;
67
import java.util.logging.Logger;
Lines 132-137 Link Here
132
    private static final String LICENSE_ATTR_URL = "url"; // NOI18N
133
    private static final String LICENSE_ATTR_URL = "url"; // NOI18N
133
    
134
    
134
    private static final String MANIFEST_ATTR_SPECIFICATION_VERSION = "OpenIDE-Module-Specification-Version"; // NOI18N
135
    private static final String MANIFEST_ATTR_SPECIFICATION_VERSION = "OpenIDE-Module-Specification-Version"; // NOI18N
136
    private static final String MANIFEST_ATTR_IMPLEMENTATION_VERSION = "OpenIDE-Module-Implementation-Version"; // NOI18N
135
    
137
    
136
    private static final String TIME_STAMP_FORMAT = "ss/mm/hh/dd/MM/yyyy"; // NOI18N
138
    private static final String TIME_STAMP_FORMAT = "ss/mm/hh/dd/MM/yyyy"; // NOI18N
137
    
139
    
Lines 148-154 Link Here
148
    private static URI cacheURI;
150
    private static URI cacheURI;
149
    synchronized static Map<String, ModuleItem> getUpdateItems (URL url, URL provider, Task task) throws IOException {
151
    synchronized static Map<String, ModuleItem> getUpdateItems (URL url, URL provider, Task task) throws IOException {
150
152
151
        Map<String, ModuleItem> items = new HashMap<String, ModuleItem> ();
153
        Map<String, ModuleItem> items = new TreeMap<String, ModuleItem> ();
152
        URI base;
154
        URI base;
153
        try {
155
        try {
154
            if (provider != null) {
156
            if (provider != null) {
Lines 471-478 Link Here
471
        
473
        
472
        public void appendManifest (Attributes manifest) {
474
        public void appendManifest (Attributes manifest) {
473
            specVersion = manifest.getValue (MANIFEST_ATTR_SPECIFICATION_VERSION);
475
            specVersion = manifest.getValue (MANIFEST_ATTR_SPECIFICATION_VERSION);
476
            String implVersion = manifest.getValue(MANIFEST_ATTR_IMPLEMENTATION_VERSION);
477
            /* Useful fallback for implVersion, but 2.6 DTD lacks it (#207137 comment #2):
478
            String buildVersion = manifest.getValue(MANIFEST_ATTR_BUILD_VERSION);
479
            */
480
            id = moduleCodeName + '_' + specVersion + '_' + (implVersion != null && !implVersion.matches("\\d{1,3}") ? implVersion : catalogDate != null ? catalogDate : "").replaceAll("[^a-zA-Z0-9._-]+", "_");
474
            mf = getManifest (manifest);
481
            mf = getManifest (manifest);
475
            id = moduleCodeName + '_' + specVersion; // NOI18N
476
        }
482
        }
477
        
483
        
478
        public void appendNotification (String notification) {
484
        public void appendNotification (String notification) {
(-)a/nbbuild/default-properties.xml (+1 lines)
Lines 73-78 Link Here
73
  <property name="moduleCluster.file" location="${netbeans.dest.dir}/moduleCluster.properties"/>
73
  <property name="moduleCluster.file" location="${netbeans.dest.dir}/moduleCluster.properties"/>
74
74
75
  <property name="autoupdate.catalog.url" value="http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/lastStableBuild/artifact/nbbuild/nbms/updates.xml.gz"/>
75
  <property name="autoupdate.catalog.url" value="http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/lastStableBuild/artifact/nbbuild/nbms/updates.xml.gz"/>
76
  <property name="autoupdate.cache" location="${user.home}/.cache/nbupdate"/>
76
77
77
  <macrodef name="resolve">
78
  <macrodef name="resolve">
78
    <attribute name="name"/>
79
    <attribute name="name"/>
(-)a/nbbuild/templates/common.xml (+1 lines)
Lines 192-197 Link Here
192
        <autoupdate
192
        <autoupdate
193
            updatecenter="${autoupdate.catalog.url}"
193
            updatecenter="${autoupdate.catalog.url}"
194
            todir="${cluster}"
194
            todir="${cluster}"
195
            cache="${autoupdate.cache}"
195
        >
196
        >
196
            <modules includes="${code.name.base}"/>
197
            <modules includes="${code.name.base}"/>
197
        </autoupdate>
198
        </autoupdate>
(-)a/nbbuild/test/unit/src/org/netbeans/nbbuild/AutoUpdateTest.java (+35 lines)
Lines 52-57 Link Here
52
import java.util.zip.CRC32;
52
import java.util.zip.CRC32;
53
import java.util.zip.ZipEntry;
53
import java.util.zip.ZipEntry;
54
import java.util.zip.ZipOutputStream;
54
import java.util.zip.ZipOutputStream;
55
import org.apache.tools.ant.Project;
56
import org.apache.tools.ant.types.FileSet;
55
import org.w3c.dom.Document;
57
import org.w3c.dom.Document;
56
import org.w3c.dom.Element;
58
import org.w3c.dom.Element;
57
import org.w3c.dom.NodeList;
59
import org.w3c.dom.NodeList;
Lines 677-682 Link Here
677
        }
679
        }
678
    }
680
    }
679
681
682
    public void testDownloadOnlyWithCache() throws Exception {
683
        AutoUpdate au = new AutoUpdate();
684
        au.setProject(new Project());
685
        generateNBM("org-netbeans-api-annotations-common.nbm", "netbeans/modules/org-netbeans-api-annotations-common.jar");
686
        au.setUpdateCenter(extractResource("org-netbeans-api-annotations-common.xml").toURI().toURL());
687
        File cache = new File(getWorkDir(), "cache");
688
        au.setCache(cache);
689
        File target = new File(getWorkDir(), "target");
690
        target.mkdirs();
691
        au.setDownloadDir(target);
692
        au.createModules().setIncludes(".+");
693
        au.execute();
694
        assertTrue(new File(target, "org-netbeans-api-annotations-common.nbm").isFile());
695
        assertTrue(new File(cache, "org.netbeans.api.annotations.common_1.3_nbms-and-javadoc-4296-on-091113.nbm").isFile());
696
    }
697
698
    public void testUnpackWithCache() throws Exception {
699
        AutoUpdate au = new AutoUpdate();
700
        au.setProject(new Project());
701
        au.optimizeForLocal = true;
702
        generateNBM("org-netbeans-api-annotations-common.nbm", "netbeans/modules/org-netbeans-api-annotations-common.jar");
703
        au.setUpdateCenter(extractResource("org-netbeans-api-annotations-common.xml").toURI().toURL());
704
        File cache = new File(getWorkDir(), "cache");
705
        au.setCache(cache);
706
        File cluster = new File(getWorkDir(), "cluster");
707
        cluster.mkdirs();
708
        au.setToDir(cluster);
709
        au.createModules().setIncludes(".+");
710
        au.execute();
711
        assertTrue(new File(cluster, "modules/org-netbeans-api-annotations-common.jar").isFile());
712
        assertTrue(new File(cache, "org.netbeans.api.annotations.common_1.3_nbms-and-javadoc-4296-on-091113.nbm").isFile());
713
    }
714
680
    public File generateNBM (String name, String... files) throws IOException {
715
    public File generateNBM (String name, String... files) throws IOException {
681
        List<String> filesAndContent = new ArrayList<String>();
716
        List<String> filesAndContent = new ArrayList<String>();
682
        for (String s : files) {
717
        for (String s : files) {

Return to bug 207137