You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Weyert de Boer <we...@gmail.com> on 2013/03/13 08:55:26 UTC
Compiling multiple projects with a small change
Hello,
I am working on a project for which I need to generate client-specific
builds. I would like to automate this by creating a nice Buildr
script.
Only I am having trouble how to define a project which gets build 28
times with only three changes to a class of the project. I already
have
written some code for in Buildfile which generates the class for each
client. Only now I am having the problem how to force the building 28
times of the project.
I don't really want to copy the project definition and its source code
28 times. This can only cause problems.
I have tried the following without much luck:
define "application", :layout => layout do
# Create build for Client 1
client= "client1"
app = _(:src, "application_" + client + ".as")
client_options = {'client' => client, 'client_key' => 'XXXXXX',
'client_secret' => 'XYZXYZXYZ'}
generate_configuration_class(project, client_options)
compile.using( :mxmlc, :main => app, :flexsdk => flexsdk, :args
=> args, :debug => false).
with( _(:library, :swc, 'assets.swc'))
compile.options[:output] = application_" + client + ".swf"
compile.into _(:target, :bin)
package :swf
# Create build for Client 2
client= "client2"
app = _(:src, "application_" + client + ".as")
client_options = {'client' => client, 'client_key' => 'XXXXXX',
'client_secret' => 'XYZXYZXYZ'}
generate_configuration_class(project, client_options)
compile.using( :mxmlc, :main => app, :flexsdk => flexsdk, :args
=> args, :debug => false).
with( _(:library, :swc, 'assets.swc'))
compile.options[:output] = application_" + client + ".swf"
compile.into _(:target, :bin)
package :swf
# Create build for Client 3
client= "client3"
app = _(:src, "application_" + client + ".as")
client_options = {'client' => client, 'client_key' => 'XXXXXX',
'client_secret' => 'XYZXYZXYZ'}
generate_configuration_class(project, client_options)
compile.using( :mxmlc, :main => app, :flexsdk => flexsdk, :args
=> args, :debug => false).
with( _(:library, :swc, 'assets.swc'))
compile.options[:output] = application_" + client + ".swf"
compile.into _(:target, :bin)
package :swf
end
Now if I run this script I am having a few problems. First of all my
generate_configuration_class gets run too early in the process and
just before compilation time. Next, it also only executes the the last
compile definition in my project definition. Can I also define
projects and use a different project location? E.g. have a client1
project which has its sources in a totally different location? If so I
could define multiple projects and hard-code the source code to main
source directory of the application. Or are there better approaches?
Looking forward to hear form you,
Weyert de Boer
Re: Compiling multiple projects with a small change
Posted by Peter Donald <pe...@realityforge.org>.
Hi,
On Wed, Mar 13, 2013 at 6:55 PM, Weyert de Boer <we...@gmail.com> wrote:
> Now if I run this script I am having a few problems. First of all my
> generate_configuration_class gets run too early in the process and
> just before compilation time. Next, it also only executes the the last
> compile definition in my project definition. Can I also define
> projects and use a different project location? E.g. have a client1
> project which has its sources in a totally different location? If so I
> could define multiple projects and hard-code the source code to main
> source directory of the application. Or are there better approaches?
>From what I understand you are trying to build three different
artifacts, one customized for each client. We do this quite a bit with
java code but have never done it with flash (?) or whatever code type
you are using. There is a couple of strategies we have used in the
past. I don't know enough about flash to know if any of them are
appropriate.
* Extract out the common code into a different project and then have a
project per client. Each client-specific project includes the shared
project and adds customisation for the client. ie pseudo code is
project 'foo' do
project 'common' do
package :jar
end
project 'client-1' do
compile.with project('common')
package(:jar).merge(project('common'))
end
project 'client-2' do
compile.with project('common')
package(:jar).merge(project('common'))
end
end
* The other possibility is that you place all the code in one project
but produce multiple packages, each with other client code stripped
out. i.e.
project 'foo' do
package(:jar, :classifier=>'client-1').exclude('/client-2/*)
package(:jar, :classifier=>'client-2').exclude('/client-1/*)
end
* The other is to define multiple projects that share overlapping
source/resources.
project 'foo' do
project 'client-1' do
compile.from _('../common/src')
package(:jar)
end
project 'client-2' do
compile.from _('../common/src')
package(:jar)
end
end
HTH,
Peter Donald