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

(-)a/nbbuild/antsrc/org/netbeans/nbbuild/AutoUpdate.java (-5 / +23 lines)
Lines 88-93 Link Here
88
public class AutoUpdate extends Task {
88
public class AutoUpdate extends Task {
89
    private List<Modules> modules = new ArrayList<Modules>();
89
    private List<Modules> modules = new ArrayList<Modules>();
90
    private FileSet nbmSet;
90
    private FileSet nbmSet;
91
    private File download;
91
    private File dir;
92
    private File dir;
92
    private File cluster;
93
    private File cluster;
93
    private URL catalog;
94
    private URL catalog;
Lines 112-117 Link Here
112
    public void setToDir(File dir) {
113
    public void setToDir(File dir) {
113
        this.cluster = dir;
114
        this.cluster = dir;
114
    }
115
    }
116
    
117
    public void setDownloadDir(File dir) {
118
        this.download = dir;
119
    }
115
120
116
    /** Forces rewrite even the version of a module is not newer */
121
    /** Forces rewrite even the version of a module is not newer */
117
    public void setForce(boolean force) {
122
    public void setForce(boolean force) {
Lines 126-133 Link Here
126
131
127
    @Override
132
    @Override
128
    public void execute() throws BuildException {
133
    public void execute() throws BuildException {
134
        boolean downloadOnly = false;
129
        if ((dir != null) == (cluster != null)) {
135
        if ((dir != null) == (cluster != null)) {
130
            throw new BuildException("Specify either todir or installdir");
136
            if (dir == null && cluster == null && download != null) {
137
                log("Going to download NBMs only to " + download);
138
                downloadOnly = true;
139
            } else {
140
                throw new BuildException("Specify either todir or installdir");
141
            }
131
        }
142
        }
132
        Map<String, ModuleItem> units;
143
        Map<String, ModuleItem> units;
133
        if (catalog != null) {
144
        if (catalog != null) {
Lines 194-200 Link Here
194
            boolean delete = false;
205
            boolean delete = false;
195
            File lastM = null;
206
            File lastM = null;
196
            try {
207
            try {
197
                if (uu.getURL().getProtocol().equals("file")) {
208
                if (download == null && uu.getURL().getProtocol().equals("file")) {
198
                    try {
209
                    try {
199
                        tmp = new File(uu.getURL().toURI());
210
                        tmp = new File(uu.getURL().toURI());
200
                    } catch (URISyntaxException ex) {
211
                    } catch (URISyntaxException ex) {
Lines 206-214 Link Here
206
                }
217
                }
207
                final String dash = uu.getCodeName().replace('.', '-');
218
                final String dash = uu.getCodeName().replace('.', '-');
208
                if (tmp == null) {
219
                if (tmp == null) {
209
                    tmp = File.createTempFile(dash, ".nbm");
220
                    if (download != null) {
210
                    tmp.deleteOnExit();
221
                        tmp = new File(download, dash + ".nbm");
211
                    delete = true;
222
                    } else {
223
                        tmp = File.createTempFile(dash, ".nbm");
224
                        tmp.deleteOnExit();
225
                        delete = true;
226
                    }
212
                    Get get = new Get();
227
                    Get get = new Get();
213
                    get.setProject(getProject());
228
                    get.setProject(getProject());
214
                    get.setTaskName("get:" + uu.getCodeName());
229
                    get.setTaskName("get:" + uu.getCodeName());
Lines 217-222 Link Here
217
                    get.setVerbose(true);
232
                    get.setVerbose(true);
218
                    get.execute();
233
                    get.execute();
219
                }
234
                }
235
                if (downloadOnly) {
236
                    continue;
237
                }
220
238
221
                File whereTo = dir != null ? new File(dir, uu.targetcluster) : cluster;
239
                File whereTo = dir != null ? new File(dir, uu.targetcluster) : cluster;
222
                whereTo.mkdirs();
240
                whereTo.mkdirs();
(-)a/nbbuild/test/unit/src/org/netbeans/nbbuild/AutoUpdateTest.java (+21 lines)
Lines 67-72 Link Here
67
        super(name);
67
        super(name);
68
    }
68
    }
69
69
70
    public void testJustDownloadNBMs() throws Exception {
71
        File nbm = generateNBM("org-netbeans-api-annotations-common.nbm",
72
            "netbeans/config/Modules/org-netbeans-api-annotations-common.xml",
73
            "netbeans/modules/org-netbeans-api-annotations-common.jar");
74
        assertTrue("NBM file created", nbm.isFile());
75
76
        File target = new File(getWorkDir(), "target");
77
        target.mkdirs();
78
79
        execute(
80
            "autoupdate.xml", "-verbose", "-Ddir=" + nbm.getParent(),
81
            "-Dincludes=org.netbeans.api.annotations.common",
82
            "-Dtarget=" + target,
83
            "mirror"
84
        );
85
        
86
        File[] arr = target.listFiles();
87
        assertEquals("One item in the array:\n" + getStdOut(), 1, arr.length);
88
        assertEquals("It is the NBM file", nbm.getName(), arr[0].getName());
89
        assertEquals("Length is the same", nbm.length(), arr[0].length());
90
    }
70
    public void testDirectlySpecifiedNBMs() throws Exception {
91
    public void testDirectlySpecifiedNBMs() throws Exception {
71
        File nbm = generateNBM("org-netbeans-api-annotations-common.nbm",
92
        File nbm = generateNBM("org-netbeans-api-annotations-common.nbm",
72
            "netbeans/config/Modules/org-netbeans-api-annotations-common.xml",
93
            "netbeans/config/Modules/org-netbeans-api-annotations-common.xml",
(-)a/nbbuild/test/unit/src/org/netbeans/nbbuild/autoupdate.xml (+13 lines)
Lines 59-62 Link Here
59
        </autoupdate>
59
        </autoupdate>
60
60
61
    </target>
61
    </target>
62
    
63
    <target name="mirror">
64
        <echo message="${root}"/>
65
66
        <taskdef classname="org.netbeans.nbbuild.AutoUpdate" name="autoupdate" classpath="${nb_all}/nbbuild/nbantext.jar"/>
67
68
        <autoupdate downloaddir="${target}">
69
            <nbms dir="${dir}">
70
                <include name="*.nbm"/>
71
            </nbms>
72
            <modules includes="${includes}"/>
73
        </autoupdate>
74
    </target>
62
</project>
75
</project>

Return to bug 196428