Skip to content
This repository

when jar under generated directory is deleted and buildfiles only exist, ant build will failed. #154

Closed
tangyong opened this Issue April 26, 2012 · 10 comments

3 participants

Tang Yong Peter Kriens Ferry Huberts
Tang Yong

Hi Peter,

when jar under generated directory is deleted and buildfiles only exist, ant build will failed.

The problem is found when using bndtools to create a new bnd project.

[Env]
1 bnd plugin(build from master)
2 ant 1.7.1
3 windows xp

[Operation]
1 using bndtools to create a new simple project called "test1"
2 open $workspace\cnf\build.xml, and replace bnd plugin with my built bnd plugin("biz.aQute.bnd-latest.jar")
3 open "cmd", and cd "test1" directory and enter ''ant build" and no problem happened.
4 enter "del generated\test1.jar"
5 enter "ant build" again, the following error happened.

build:
[bnd] Updating classpath after classpathref setting
[bnd] 1 Errors
[bnd] buildfile lists file but the file does not exist E:\bndtools\temp\t
est1\generated\test1.jar
[bnd] Command build failed
[bnd] at aQute.bnd.ant.BndTask.execute(BndTask.java:106)
[bnd] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
va:288)
[bnd] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[bnd] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
[bnd] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
[bnd] at java.lang.reflect.Method.invoke(Method.java:597)
[bnd] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchU
tils.java:106)
[bnd] at org.apache.tools.ant.Task.perform(Task.java:348)
[bnd] at org.apache.tools.ant.Target.execute(Target.java:357)
[bnd] at org.apache.tools.ant.Target.performTasks(Target.java:385)
[bnd] at org.apache.tools.ant.Project.executeSortedTargets(Project.jav
a:1337)
[bnd] at org.apache.tools.ant.Project.executeTarget(Project.java:1306)

  [bnd]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(De

faultExecutor.java:41)
[bnd] at org.apache.tools.ant.Project.executeTargets(Project.java:1189
)
[bnd] at org.apache.tools.ant.Main.runBuild(Main.java:758)
[bnd] at org.apache.tools.ant.Main.startAnt(Main.java:217)
[bnd] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
[bnd] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

BUILD FAILED
Command build failed

Tang Yong

the problem is the same as bndtools/bndtools#382

Tang Yong

[Investigating result]

when jar under generated directory is deleted and buildfiles only exist, the problem happened
on the following file and method:

file:
bnd\biz.aQute.bndlib\src\aQute\bnd\build\Project.java

method:
public File[] getBuildFiles(boolean buildIfAbsent) throws Exception

Line Number:
1338 Line
error("buildfile lists file but the file does not exist %s", ff);

[My Opinion]
After all, when BUILDFILES and jar have not in sync state, should give user to build the project again.

[Fix Method]
1 modify error api to warning, after all, also informing user the unsync state.
2 return null immidately

if (!ff.isFile()) {
//error("buildfile lists file but the file does not exist %s", ff);
warning("buildfile lists file but the file does not exist %s", ff);
return null;
...

I have tested and anything is ok!

init:
[echo] Enter project test1

dependencies:
[subant] No sub-builds to iterate on

compile:

build:
[bnd] Updating classpath after classpathref setting
[bnd] Warnings
[bnd] buildfile lists file but the file does not exist E:\bndtools\temp\t
est1\generated\test1.jar

BUILD SUCCESSFUL
Total time: 0 seconds

I want to listen to your opinion.

Tang Yong tangyong referenced this issue from a commit in tangyong/bnd April 27, 2012
Tang Yong bnd #154 6662f82
Ferry Huberts
Collaborator

is this issue present if you use code from the next branch?
(next is the version to use)

Tang Yong

Hi fhuberts,

Now, I have confirmed the problem on the next branch and the result is

The problem still happened.

Ferry Huberts
Collaborator

@bnd reporter indicates this is a problem on next

Ferry Huberts fhuberts referenced this issue from a commit May 02, 2012
Ferry Huberts Merge branch 'master' into next
* master:
  bnd #154
  Fixed typo
  -Added failures, errors and skipped attributes because some build servers expect those. -Renamed sys-out to system-out because this is the name used by most tools.
  fixed #114 The tests property was never set resulting in tests="0" in the xml.

Conflicts:
	biz.aQute.junit/src/aQute/junit/JunitXmlReport.java
c5faee0
Peter Kriens bnd referenced this issue from a commit May 02, 2012
Peter Kriens #154 Removed error warning when build files did not
match the reality. Will now just rebuild.
529fed2
Peter Kriens
Owner
bnd commented May 02, 2012

I did the original bug slightly different (no error/warning, close file, delete file, but build if required)

Peter Kriens bnd closed this May 02, 2012
Tang Yong

Hi Peter,

I have updated my next branch and accorrding to your committing, I have confirmed that
the build error is disappeared and the buildfile is deleted. Of course, if the user wants to get built jar,
he/she can execute "ant build".

In addition,I am sorry that my original modify way has some leaks(file stream not closing) .

Thanks your committing!

Ferry Huberts
Collaborator

@tangyong it did not leak, see the finally statement. Peter just added a f.delete() that makes it necessary to first close the input stream.

Tang Yong

@fhuberts Thanks for your indication,you are right! I indeedly forgot the finally statement("fin.close()"). :)

Tang Yong

@bnd
@fhuberts

About #154 and bnd's fix way, today, I made a new test and have a question to discuss with you.

[Test Case]
1 create a test project with bndtools under "E:\bndtools\test\test1".
2 cd "E:\bndtools\test\test1", and execute "ant build", then, under "E:\bndtools\test\test1\generated",
buildfiles and test1.jar are generated. In the buildfiles, there are the following contents :

E:\bndtools\test\test1\generated\test1.jar

3 copy the test project("E:\bndtools\test") to "F:\test"

4 cd "F:\test\test1\generated", and delete the test1.jar

5 place the biz.aQute.bnd.jar(@bnd fixed version(next)) to "F:\test\cnf\repo\biz.aQute.bnd"

6 cd "F:\test\test1\" and execute "ant build"

7 the result is that under "F:\test\test1\generated", test1.jar has not been generated and buildfiles
has not been deleted also because "E:\bndtools\test\test1\generated\test1.jar" in
"F:\test\test1\generated\buildfiles" has existed.

[Question]
Is the above behavior correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.