Skip to content

Commit e8ab47c

Browse files
committed
fix "fail to upload" issue.
improve project build dependency.
1 parent 92899cf commit e8ab47c

File tree

9 files changed

+65
-100
lines changed

9 files changed

+65
-100
lines changed

tools/anttasks/anttasks.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
computeworkspacedeps: com.dianping.ant.ComputeWorkspaceDependency
1+
computedeps: com.dianping.ant.ComputeDependency
22
gensite: com.dianping.ant.GenSite
33
uploadsite: com.dianping.ant.UploadSite
44
launchsite: com.dianping.ant.LaunchSite

tools/anttasks/src/com/dianping/ant/ComputeWorkspaceDependency.java renamed to tools/anttasks/src/com/dianping/ant/ComputeDependency.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import org.apache.tools.ant.Task;
1111
import org.apache.tools.ant.types.Path;
1212

13-
public class ComputeWorkspaceDependency extends Task {
13+
public class ComputeDependency extends Task {
1414

1515
private File dir;
1616
private String refid;
@@ -39,8 +39,14 @@ public void execute() throws BuildException {
3939
}
4040

4141
ArrayList<File> deps = new ArrayList<File>();
42-
for (File proj : dir.listFiles()) {
43-
appendDependency(proj, deps);
42+
if (new File(dir, "AndroidManifest.xml").isFile()) {
43+
// it's a project
44+
appendDependency(dir, deps);
45+
} else {
46+
// it's a workspace
47+
for (File proj : dir.listFiles()) {
48+
appendDependency(proj, deps);
49+
}
4450
}
4551
Path p = new Path(getProject());
4652
for (File f : deps) {

tools/anttasks/src/com/dianping/ant/LaunchSite.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void execute() throws BuildException {
111111

112112
try {
113113
String crlf = "\r\n";
114-
Socket s = new Socket(InetAddress.getByName("localhost"), 5036);
114+
Socket s = new Socket(InetAddress.getByName("127.0.0.1"), 5036);
115115
OutputStream os = s.getOutputStream();
116116
StringBuilder sb = new StringBuilder();
117117
sb.append(debug ? "GET /debug/" : "GET /go/").append(defaultHost)

tools/anttasks/src/com/dianping/ant/LaunchWorkspace.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void execute() throws BuildException {
9595

9696
try {
9797
String crlf = "\r\n";
98-
Socket s = new Socket(InetAddress.getByName("localhost"), 5036);
98+
Socket s = new Socket(InetAddress.getByName("127.0.0.1"), 5036);
9999
OutputStream os = s.getOutputStream();
100100
StringBuilder sb = new StringBuilder();
101101
sb.append(debug ? "GET /debug/" : "GET /go/").append(defaultHost)

tools/anttasks/src/com/dianping/ant/UploadSite.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void execute() throws BuildException {
9797

9898
try {
9999
String crlf = "\r\n";
100-
Socket s = new Socket(InetAddress.getByName("localhost"), 5036);
100+
Socket s = new Socket(InetAddress.getByName("127.0.0.1"), 5036);
101101
OutputStream os = s.getOutputStream();
102102
StringBuilder sb = new StringBuilder();
103103
sb.append("PUT /site HTTP/1.0").append(crlf);
@@ -117,7 +117,7 @@ public void execute() throws BuildException {
117117
public static void upload(String path, byte[] bytes) {
118118
try {
119119
final String crlf = "\r\n";
120-
Socket s = new Socket(InetAddress.getByName("localhost"), 5036);
120+
Socket s = new Socket(InetAddress.getByName("127.0.0.1"), 5036);
121121
OutputStream os = s.getOutputStream();
122122
StringBuilder sb = new StringBuilder();
123123
sb.append("PUT ").append(path).append(" HTTP/1.0").append(crlf);

tools/anttasks/src/com/dianping/ant/UploadWorkspace.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void execute() throws BuildException {
8585

8686
try {
8787
String crlf = "\r\n";
88-
Socket s = new Socket(InetAddress.getByName("localhost"), 5036);
88+
Socket s = new Socket(InetAddress.getByName("127.0.0.1"), 5036);
8989
OutputStream os = s.getOutputStream();
9090
StringBuilder sb = new StringBuilder();
9191
sb.append("PUT /site HTTP/1.0").append(crlf);

tools/build-plugin.xml

Lines changed: 47 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,6 @@
244244
<checkenv />
245245
</target>
246246

247-
<!-- target to disable building dependencies -->
248-
<target name="nodeps">
249-
<property name="dont.do.deps" value="true" />
250-
</target>
251-
252247
<!-- generic setup -->
253248
<target name="-setup" depends="-check-env">
254249
<echo level="info">Project Name: ${ant.project.name}</echo>
@@ -259,41 +254,6 @@
259254

260255
</target>
261256

262-
<!-- empty default pre-clean target. Create a similar target in
263-
your build.xml and it'll be called instead of this one. -->
264-
<target name="-pre-clean"/>
265-
266-
<!-- clean target -->
267-
<target name="clean" depends="-setup, -pre-clean"
268-
description="Removes output files created by other targets.">
269-
<delete dir="${out.absolute.dir}" verbose="${verbose}" failonerror="false" />
270-
<delete dir="${gen.absolute.dir}" verbose="${verbose}" failonerror="false" />
271-
272-
<!-- get all the libraries -->
273-
<if>
274-
<condition><not><isset property="dont.do.deps" /></not></condition>
275-
<then>
276-
<getlibpath libraryFolderPathOut="project.library.folder.path" />
277-
<if>
278-
<condition>
279-
<isreference refid="project.library.folder.path" />
280-
</condition>
281-
<then>
282-
<!-- clean the libraries with nodeps since we already
283-
know about all the libraries even the indirect one -->
284-
<subant
285-
buildpathref="project.library.folder.path"
286-
antfile="build.xml"
287-
failonerror="true">
288-
<target name="nodeps" />
289-
<target name="clean" />
290-
</subant>
291-
</then>
292-
</if>
293-
</then>
294-
</if>
295-
</target>
296-
297257
<!-- Pre build setup -->
298258
<target name="-build-setup" depends="-setup">
299259
<!-- find location of build tools -->
@@ -340,33 +300,6 @@
340300
targetApi="${project.target.apilevel}"
341301
verbose="${verbose}" />
342302

343-
<!-- compile the libraries if any -->
344-
<if>
345-
<condition>
346-
<and>
347-
<isreference refid="project.library.folder.path" />
348-
<not><isset property="dont.do.deps" /></not>
349-
</and>
350-
</condition>
351-
<then>
352-
<echo level="info">----------</echo>
353-
<echo level="info">Building Libraries with '${project.libraries.target}'...</echo>
354-
355-
<!-- TODO: print the library folder paths -->
356-
<pathconvert property="pathconv" refid="project.library.folder.path" />
357-
<echo>${pathconv}</echo>
358-
359-
<!-- no need to build the deps as we have already
360-
the full list of libraries -->
361-
<property name="project.libraries.target" value="release" />
362-
<subant failonerror="true"
363-
buildpathref="project.library.folder.path"
364-
antfile="build.xml">
365-
<target name="nodeps" />
366-
<target name="${project.libraries.target}" />
367-
</subant>
368-
</then>
369-
</if>
370303
</target>
371304

372305
<!-- empty default pre-build target. Create a similar target in
@@ -513,6 +446,24 @@
513446
<target name="-post-package" />
514447
<target name="-post-build" />
515448

449+
<!-- ******************************************************* -->
450+
<!-- **************** Clean specific targets *************** -->
451+
<!-- ******************************************************* -->
452+
453+
<target name="-clean">
454+
<delete dir="${out.absolute.dir}" verbose="${verbose}" failonerror="false" />
455+
<delete dir="${gen.absolute.dir}" verbose="${verbose}" failonerror="false" />
456+
</target>
457+
458+
<target name="clean">
459+
<computedeps src="." refid="project.library.folder.path" />
460+
<subant failonerror="true"
461+
buildpathref="project.library.folder.path"
462+
antfile="build.xml">
463+
<target name="-clean" />
464+
</subant>
465+
</target>
466+
516467
<!-- ******************************************************* -->
517468
<!-- **************** Site specific targets **************** -->
518469
<!-- ******************************************************* -->
@@ -522,46 +473,55 @@
522473
</target>
523474

524475
<!-- ******************************************************* -->
525-
<!-- *************** Release specific targets ************** -->
476+
<!-- ***************** APK specific targets **************** -->
526477
<!-- ******************************************************* -->
527-
<target name="-set-release-mode">
478+
479+
<target name="-set-path">
528480
<property name="out.packaged.file" location="${out.absolute.dir}/${ant.project.name}-0.apk" />
529481
<property name="out.final.file" location="${out.absolute.dir}/${ant.project.name}.apk" />
530482
</target>
531483

532-
<target name="-release-sign">
533-
<sequential>
534-
<!-- Zip aligns the APK -->
535-
<zipalign-helper
536-
in.package="${out.packaged.file}"
537-
out.package="${out.final.file}" />
538-
<echo level="info">Final Package: ${out.final.file}</echo>
539-
</sequential>
484+
<target name="-zipalign">
485+
<!-- Zip aligns the APK -->
486+
<zipalign-helper
487+
in.package="${out.packaged.file}"
488+
out.package="${out.final.file}" />
489+
<echo level="info">Final Package: ${out.final.file}</echo>
540490
</target>
541491

542-
<!-- This runs -package-release and -release-nosign first and then runs
543-
only if release-sign is true (set in -release-check,
544-
called by -release-no-sign)-->
545-
<target name="do-release"
546-
depends="-set-release-mode, -package, -post-package, -release-sign, -post-build, site"
492+
<target name="-do-apk"
493+
depends="-set-path, -package, -post-package, -zipalign, -post-build, site"
547494
description="Builds the application in release mode.">
548495
</target>
549496

550-
<target name="-check-release" depends="-set-release-mode, site">
551-
<uptodate property="release.nochanges" targetfile="${out.final.file}">
497+
<target name="-uptodate" depends="-set-path, site">
498+
<uptodate property="uptodate.nochanges" targetfile="${out.final.file}">
552499
<srcfiles dir="${source.absolute.dir}" includes="**/*.java"/>
553500
<srcfiles dir="${resource.absolute.dir}" includes="**"/>
554501
</uptodate>
555502
</target>
556503

557-
<target name="release"
558-
depends="-check-release" unless="release.nochanges">
504+
<target name="-apk"
505+
depends="-uptodate" unless="uptodate.nochanges">
559506
<!-- Some changes in resources may cause issue. So rebuild this plugin -->
560507
<delete dir="${out.absolute.dir}/a" verbose="${verbose}" failonerror="false" />
561508

562-
<antcall target="do-release" />
509+
<antcall target="-do-apk" />
563510
</target>
564511

512+
<target name="release">
513+
<computedeps src="." refid="project.library.folder.path" />
514+
<subant failonerror="true"
515+
buildpathref="project.library.folder.path"
516+
antfile="build.xml">
517+
<target name="-apk" />
518+
</subant>
519+
</target>
520+
521+
<!-- ******************************************************* -->
522+
<!-- ************** Run/Debug specific targets ************* -->
523+
<!-- ******************************************************* -->
524+
565525
<target name="run"
566526
depends="release"
567527
description="start app, upload codes, and launch.">

tools/build-workspace.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@
66
</path>
77
<taskdef resource="anttasks.properties" classpathref="workspace.antlibs"/>
88
<target name="release">
9-
<computeworkspacedeps src="." refid="project.library.folder.path" />
9+
<computedeps src="." refid="project.library.folder.path" />
1010
<subant failonerror="true"
1111
buildpathref="project.library.folder.path"
1212
antfile="build.xml">
13-
<target name="nodeps" />
14-
<target name="release" />
13+
<target name="-build" />
1514
</subant>
1615
<genworkspace src="." />
1716
</target>
1817
<target name="clean">
19-
<subant target="clean">
18+
<subant target="-clean">
2019
<fileset dir="." includes="*/build.xml"/>
2120
</subant>
2221
</target>

tools/lib/anttasks.jar

14 KB
Binary file not shown.

0 commit comments

Comments
 (0)