Hi Odelya,
The code inside the 'define' block gets executed during project definition
so it should only contain code that pertains to the project's definition
(i.e., no side-effects).
I suggest you refactor the code as follows,
war = package(:war, :id => "MyBuild")
war.with :libs => project('Common')
war.enhance do |war|
sh "$CATALINA_HOME/bin/shutdown.sh"
cp war.to_s, _(ENV['CATALINA_HOME'], 'webapps')
sh "$CATALINA_HOME/bin/startup.sh"
end
The `enhance` code block will now only run _after_ the war has been created.
alex
On Mon, Aug 13, 2012 at 10:33 AM, Odelya Holiday <[email protected]>wrote:
> Hi
>
> I have the following lines in buildfile
>
> define "BE" do
>
> project.version = VERSION_NUMBER
> project.group = GROUP
> manifest['Copyright'] = COPYRIGHT
>
> desc 'Building common project for engine and API'
> define 'Common' do
> compile.with SPRING_CORE,COMMONS_CODEC, COMMONS_IO
> package :jar
> end
>
> desc 'Building API (Grroo) project'
> define 'My' do
> info "starting My project"
> # specify the artifact for plimus, twilio and floristone
> since I
> created it locally
> plimus = artifact('plimus.com:
> plimus:jar:1.0').from('/var/lib/selfdep/wsintegration.jar')
> floristone = artifact('floristone.com:
> floristone:jar:1.0').from('/var/lib/selfdep/floristone.jar')
> twilio = artifact('twilio.com:
> twilio:jar:1.0').from('/var/lib/selfdep/twilio.jar')
> # install the artifact locally
> install plimus
> install floristone
> install twilio
> compile.with
> projects('Common'),RESTFB,SEARCH,SEARCH_HIBERNATE,SLF4J,SLF4J_LOG4J,STAX_API,TWITTER4J_CORE,WSDL4J
> #there are more files
> package(:war, :id=>"MyBuild").with :libs=>project('Common')
> # stop tomcat on port 8081
> sh "$CATALINA_HOME/bin/shutdown.sh"
> # move the war to tomcat
> cp 'GrrooBuild.war', '$CATALINA_HOME/webapps'
> # start tomcat
> sh "$CATALINA_HOME/bin/startup.sh"
> end
> end
>
> When I run it in windows, I see how nicely the jar and war are being
> created:
>
> (this is part of the output)
>
> mkdir -p C:/jenkins/Common/target/classes
> Compiling BE:Common into C:/jenkins/Common/target/classes
> Note: Some input files use unchecked or unsafe operations.
> Note: Recompile with -Xlint:unchecked for details.
> touch C:/jenkins/Common/target/classes
> mkdir -p C:/jenkins/My/target/resources
> mkdir -p C:/jenkins/My/target/resources
> cp C:/jenkins/My/src/main/resources/applicationContext-persistence.xml
> C:/jenkins/My/target/resources/applicationContext-persistence.xml
> mkdir -p C:/jenkins/My/target/resources
> cp C:/jenkins/My/src/main/resources/applicationContext.xml
> C:/jenkins/My/target/resources/applicationContext.xml
> mkdir -p C:/jenkins/My/target/resources
> cp C:/jenkins/My/src/main/resources/jdbc.properties
> C:/jenkins/My/target/resources/jdbc.properties
> mkdir -p C:/jenkins/My/target/resources
> cp C:/jenkins/My/src/main/resources/logback.xml
> C:/jenkins/My/target/resources/logback.xml
> touch C:/jenkins/My/target/resources
>
>
> However, in Linux, I run it with the same user and group that created
> the Common and My folders from subversion and as if buildr ignores the
> compile tasks:
>
> The out put is:
>
> ** Invoke alicento-BE (first_time)
> ** Execute alicento-BE
> Defining task BE:shell:bsh
> Defining task BE:shell:jirb
> Defining task BE:shell:clj
> ** Invoke BE:Common (first_time)
> ** Execute BE:Common
> Defining task BE:Common:shell:bsh
> Defining task BE:Common:shell:jirb
> Defining task BE:Common:shell:clj
> ** Invoke BE:My (first_time)
> ** Execute BE:My
> Defining task BE:My:shell:bsh
> Defining task BE:My:shell:jirb
> Defining task BE:My:shell:clj
> starting My project
> ** Invoke BE:Common
> ** Invoke BE:Common
> Aug 13, 2012 10:14:44 AM org.apache.catalina.startup.Catalina stopServer
> cp MyBuild.war webapps
> Buildr aborted!
> Errno::ENOENT : No such file or directory - MyBuild.war
>
> The file MyBuild.war is not being created!
>
> While in windows the file is created.
>
> What is the problem in linux? I don't even see a log that describes
> what prevents buildr from building the projects and packaging it!
>
> Thanks
> --
> Odelya
>