Hi,
I'm looking at a best way to organise my project to avoid the subject.
Currently I have:
define "proj" do
desc "main module that contains all the code (for now at least)"
define :webui do
compile.with GWT, PECTIN, HIBERNATE, GILEAD, SHIRO, SERVLET_API
test.with TEST
resources.from _("src/main/webapp")
task("deploy_local"=>[package(:war), jetty.use]) do |task|
puts "Deploying webapp to a jetty instance"
Java.classpath.concat([
"org.mortbay.jetty:jsp-api-2.1:jar:#{Buildr::Jetty::VERSION}",
"org.mortbay.jetty:jsp-2.1:jar:#{Buildr::Jetty::VERSION}"
])
class << task ; attr_accessor :url, :path ; end
task.url = "http://localhost:8080"
task.path = jetty.deploy(task.url, task.prerequisites.first)
end
task("run" => "deploy_local") do |task|
Readline::readline('[Type ENTER to stop Jetty]')
end
package(:war).include(gwt_dest, :as => ".").exclude("WEB-INF/deploy")
package(:war).libs -= artifacts(SERVLET_API)
unzip(_("target/root") => package(:war).to_s) # explode war if needed
package(:jar) # so that dependant test projects can use the classes
end
desc "database migration tool (based on liquibase)"
define "db-migrate" do
compile.with LIQUIBASE, LIQUIBASE_HIBERNATE, project("webui"),
project("webui").compile.dependencies
package(:jar)
manifest["Liquibase-Package"] = "ru.proj.db.migrate.liquibase"
task "update" do
Java::Commands.java("liquibase.integration.commandline.Main",
"--changeLogFile=" +
project("proj:webui")._("src/main/resources/db/db.changelog-0.0.xml"),
"--logLevel=info",
"--driver=" + Buildr.settings.profile['jdbc']['drvr'],
"--url=" + Buildr.settings.profile['jdbc']['url'],
"--username=" + Buildr.settings.profile['jdbc']['user'],
"--password=" + Buildr.settings.profile['jdbc']['pass'],
ENV['cmd'].nil? ? "update" : ENV['cmd'],
{:classpath => [compile.dependencies, package(:jar)], :java_args =>
["-Xmx256M"], :verbose=>true})
end
end
desc "system tests that require database setup"
define "test-system" do
test.using :integration
test.with TEST_FUNC + projects("webui") +
project("webui").compile.dependencies
# integration tests need app (jetty) to be running
integration.setup [project("db-migrate").task("update"),
project("proj:webui").task("deploy_local")]
end
end
so when i run "buildr integration" it causes "test-system.integration.setup
=> [db-migrate.update, webui.deploy_local]". This is acceptable, but I'd
like the webui.deploy_local to directly depend on db-migrate.update - this
sounds much more reasonable. But if i do that i'm getting a circular
dependency detected. How do i organize my tasks to avoid that?
Thanks a lot!