Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #1913 bnd-export-maven-plugin produces stray generated directory after execution #1918

Merged
merged 1 commit into from
Feb 27, 2017

Conversation

rotty3000
Copy link
Contributor

No description provided.

@@ -81,6 +81,7 @@ private void export(File runFile) throws Exception {
}
run.setProperty(Constants.RUNBUNDLES, runBundles);
}
run.setProperty(Constants.DEFAULT_PROP_TARGET_DIR, targetDir.getAbsolutePath());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct thing to do is call run.setBase(new File(targetDir, "export/"+getNamePart(runFile))), at the start of the try block. So any directories that Project.prepare might create are in that folder.

@@ -111,6 +111,7 @@ private void testing(File runFile) throws Exception {
String bndrun = getNamePart(runFile);
File bndrunCwd = new File(cwd, bndrun);
File bndrunResportsDir = new File(reportsDir, bndrun);
run.setProperty(Constants.DEFAULT_PROP_TARGET_DIR, cwd.getAbsolutePath());
Copy link
Member

@bjhargrave bjhargrave Feb 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct thing to do is call run.setBase(new File(cwd, getNamePart(runFile))), at the start of the try block. So any directories that Project.prepare might create are in that folder.

Then you no longer need to set cwd since it is set by the setBase call. I would then clean up the Bndrun.test method signature to remove the cwd argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason your second statement is not working out. The tests are failing because the cwd is not set. Shall I leave it set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[INFO] [ERROR] Failed to execute goal biz.aQute.bnd:bnd-testing-maven-plugin:3.4.0-SNAPSHOT:testing (testing) on project test-no-resolve: Working directory must be a directory: /home/rotty/projects/bnd/maven/bnd-testing-maven-plugin/target/integration-test/projects/test/test-no-resolve/target/test/test -> [Help 1]
[INFO] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal biz.aQute.bnd:bnd-testing-maven-plugin:3.4.0-SNAPSHOT:testing (testing) on project test-no-resolve: Working directory must be a directory: /home/rotty/projects/bnd/maven/bnd-testing-maven-plugin/target/integration-test/projects/test/test-no-resolve/target/test/test
[INFO] 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
[INFO] 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
[INFO] 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
[INFO] 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
[INFO] 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
[INFO] 	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
[INFO] 	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[INFO] 	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
[INFO] 	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
[INFO] 	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
[INFO] 	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
[INFO] 	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
[INFO] 	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
[INFO] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[INFO] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] 	at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] 	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
[INFO] 	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
[INFO] 	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
[INFO] 	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[INFO] Caused by: org.apache.maven.plugin.MojoExecutionException: Working directory must be a directory: /home/rotty/projects/bnd/maven/bnd-testing-maven-plugin/target/integration-test/projects/test/test-no-resolve/target/test/test
[INFO] 	at aQute.bnd.maven.testing.plugin.TestingMojo.execute(TestingMojo.java:80)
[INFO] 	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
[INFO] 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
[INFO] 	... 20 more
[INFO] Caused by: java.lang.IllegalArgumentException: Working directory must be a directory: /home/rotty/projects/bnd/maven/bnd-testing-maven-plugin/target/integration-test/projects/test/test-no-resolve/target/test/test
[INFO] 	at aQute.libg.command.Command.setCwd(Command.java:239)
[INFO] 	at aQute.bnd.build.ProjectLauncher.launch(ProjectLauncher.java:299)
[INFO] 	at aQute.launcher.plugin.ProjectLauncherImpl.launch(ProjectLauncherImpl.java:123)
[INFO] 	at aQute.tester.plugin.ProjectTesterImpl.test(ProjectTesterImpl.java:66)
[INFO] 	at biz.aQute.resolve.Bndrun.test(Bndrun.java:185)
[INFO] 	at aQute.bnd.maven.testing.plugin.TestingMojo.testing(TestingMojo.java:114)
[INFO] 	at aQute.bnd.maven.testing.plugin.TestingMojo.execute(TestingMojo.java:74)
[INFO] 	... 22 more

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or I can do projectTester.setCwd(getBase()); in Bndrun.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, the only thing required is to call getBase().mkdirs(); then everything works.

@fhuberts
Copy link
Contributor

@rotty3000 While at it, could you guys also fix the stray 'run properties files' that export produces?
I filed an issue on it a looooong time ago, but it was never fixed.

@bjhargrave
Copy link
Member

@rotty3000 While at it, could you guys also fix the stray 'run properties files' that export produces?
I filed an issue on it a looooong time ago, but it was never fixed.

That sounds like a separate item. What is that issue #?

@fhuberts
Copy link
Contributor

#326

It is separate, but seems related (stray files)

@rotty3000
Copy link
Contributor Author

Updated!

@bjhargrave
Copy link
Member

#326

It is separate, but seems related (stray files)

I made #1922 to fix that.

@rotty3000
Copy link
Contributor Author

this didn't solve the issue with some directories!

@rotty3000
Copy link
Contributor Author

In the maven case executing tests now leaves behind a fw directory in the root of the maven project which was not the case before this fix.

@bjhargrave
Copy link
Member

In the maven case executing tests now leaves behind a fw directory in the root of the maven project which was not the case before this fix.

OK, let me look. We need to fix the root cause and not just apply band aids.

@rotty3000
Copy link
Contributor Author

this call is returning the root dir rather than the set base:

https://github.com/bndtools/bnd/blob/master/biz.aQute.bndlib/src/aQute/bnd/build/ProjectLauncher.java#L297

@rotty3000
Copy link
Contributor Author

rotty3000 commented Feb 27, 2017

Seems that without calling setCwd() the project's base is the root of the maven project.

@rotty3000
Copy link
Contributor Author

... maybe it's not because of that...

@bjhargrave
Copy link
Member

... maybe it's not because of that...

https://github.com/bndtools/bnd/blob/master/biz.aQute.bndlib/src/aQute/bnd/build/ProjectLauncher.java#L96 sets cwd from base.

@rotty3000
Copy link
Contributor Author

The problem is the launch properties are messed up. Here's an example:

the mvn project is: /home/rotty/projects/bnd/maven/bnd-testing-maven-plugin/target/integration-test/projects/test/test-no-resolve

the launch properties contain:

launch.name=test
tester.dir=/home/rotty/projects/bnd/maven/bnd-testing-maven-plugin/target/integration-test/projects/test/test-no-resolve/target/test-reports/test
launch.noreferences=false
launch.notificationPort=-1
launch.trace=false
launch.services=true
launch.activators=
launch.system.packages=org.osgi.framework;version\="1.8",org.osgi.framework.dto;version\="1.8";uses\:\="org.osgi.dto",org.osgi.framework.hooks.bundle;version\="1.1";uses\:\="org.osgi.framework",org.osgi.framework.hooks.resolver;version\="1.0";uses\:\="org.osgi.framework.wiring",org.osgi.framework.hooks.service;version\="1.1";uses\:\="org.osgi.framework",org.osgi.framework.hooks.weaving;version\="1.1";uses\:\="org.osgi.framework.wiring",org.osgi.framework.launch;version\="1.2";uses\:\="org.osgi.framework",org.osgi.framework.namespace;version\="1.1";uses\:\="org.osgi.resource",org.osgi.framework.startlevel;version\="1.0";uses\:\="org.osgi.framework",org.osgi.framework.startlevel.dto;version\="1.0";uses\:\="org.osgi.dto",org.osgi.framework.wiring;version\="1.2";uses\:\="org.osgi.framework,org.osgi.resource",org.osgi.framework.wiring.dto;version\="1.2";uses\:\="org.osgi.dto,org.osgi.resource.dto",org.osgi.resource;version\="1.0",org.osgi.resource.dto;version\="1.0";uses\:\="org.osgi.dto",org.osgi.service.packageadmin;version\="1.2";uses\:\="org.osgi.framework",org.osgi.service.startlevel;version\="1.1";uses\:\="org.osgi.framework",org.osgi.service.url;version\="1.0",org.osgi.service.resolver;version\="1.0";uses\:\="org.osgi.resource",org.osgi.util.tracker;version\="1.5.1";uses\:\="org.osgi.framework",org.osgi.dto;version\="1.0"
tester.continuous=false
launch.embedded=false
launch.timeout=0
tester.unresolved=true
launch.storage.dir=/home/rotty/projects/bnd/maven/bnd-testing-maven-plugin/target/integration-test/projects/test/fw
launch.bundles=/home/rotty/.bnd/default-ws/cnf/cache/3.4.0/repo01/osgi.enroute.junit.wrapper-4.12.0.201610141744.jar,/home/rotty/.bnd/default-ws/cnf/cache/3.4.0/repo01/osgi.enroute.hamcrest.wrapper-1.3.0.201610141744.jar,/home/rotty/.bnd/default-ws/cnf/cache/3.4.0/repo01/test-no-resolve-0.0.1.jar,/home/rotty/.bnd/default-ws/cnf/cache/3.4.0/bnd-cache/biz.aQute.tester/biz.aQute.tester-3.4.0.jar
launch.keep=false

the storage dir is the one messed up.

@rotty3000
Copy link
Contributor Author

Updated!

@@ -64,6 +64,9 @@ private void export(File runFile) throws Exception {
return;
}
try (Bndrun run = Bndrun.createBndrun(null, runFile)) {
String bndrun = getNamePart(runFile);
File bndrunBase = new File(targetDir, "export/" + bndrun);
Copy link
Member

@bjhargrave bjhargrave Feb 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the call to exportRunbundles needs to change to use bndrunBase instead of targetDir as the argument. You do not want all the runbundles of all the bndrun files to dump their jars into one folder.

@rotty3000
Copy link
Contributor Author

Updated!

@rotty3000
Copy link
Contributor Author

oops... fixing.

…ed` directory after execution

Signed-off-by: Raymond Auge <raymond.auge@liferay.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants