You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-user@ant.apache.org by snowflake <ne...@gmail.com> on 2009/05/09 01:39:13 UTC

Location of configuration files as artifacts

Hi,

I am not sure how I can set the location of different artifacts which I want
to publish.  I tried a hack, which was to have my publish target copy my
configuration files that I want to publish to the build directory.  I am
very new to Ivy and would appreciate any suggestions.

I would like different configuration types to match my different ivy
views/configurations.  Here is how my ivy.xml is set up:

 <configurations>
        <conf name="default" visibility="public" />
        <conf name="deploy" visibility="public" />
        <conf name="test" visibility="public" />
</configurations>


<publications>
        <artifact name="ivyplay" type="defaultConfigFile"   conf="default"
ext="conf" />
        <artifact name="ivyplay"  type="deployConfigFile"   conf="deploy"
ext="conf"/>
        <artifact name="ivyplay"    type="testConfigFile"   conf="test"
ext="conf"/>

        <artifact name="ivyplay" type="jar" ext="jar" />
</publications>


As a result, in my repository i would like to see under my project, three
directories, "defaultConfigFiles" , "deployConfigFiles", and
"testConfigFiles".

The problem is, I have files with the same exact name, and thus my simple
copying them all to the build directory does not work.

I looked at the documentation and noticed you can set a url for each
artifact, but I don't believe that will solve my problem.  I just need to
somehow notify the publish task of the location(s) of my configuration
files.  I even tried a different publish task for each configuration type to
no avail:

<ivy:publish artifactspattern="${build.dir}/[artifact].[ext]"
resolver="my-repository" pubrevision="${revision}" status="release" />
<ivy:publish artifactspattern="${conf.dir}/[artifact].[ext]"
resolver="my-repository" pubrevision="${revision}" status="release" />
<ivy:publish artifactspattern="${test.conf.dir}/[artifact].[ext]"
resolver="my-repository" pubrevision="${revision}" status="release" />
...


In general, how does one go about handling configuration files such as
these?  Also, how does one go about removing the revision numbers appended
to the file names of the configuration artifacts?  I'm sure this can be done
manually at some point but is there a better way?  For example, my project
my publish mysql.properties-1.conf , but in the code i'm simply looking for
mysql.properties


any suggestions?

thanks,

Sam

Re: Location of configuration files as artifacts

Posted by snowflake <ne...@gmail.com>.
Thanks. I decided to use different types to distinguish the different
artifacts for different confs/views and alter my artifact pattern in the
publish tag to pick them up.  I no longer need to copy the manually to the
build directory.  Please have a look at the configuration below as a few
problems still exist.

ivy.xml:

    <publications>

        <artifact name="ivyplay" type="config"         conf="default"
ext="conf" />
        <artifact name="ivyplay"  type="configDeploy"   conf="deploy"
ext="conf"/>
        <artifact name="ivyplay"    type="configTest"     conf="test"
ext="conf"/>

        <artifact name="ivyplay" type="jar" ext="jar" />
    </publications>

build.xml:

<ivy:publish resolver="myrepository" pubrevision="${revision}"
status="release">

            <artifacts pattern="${conf.dir}/[artifact].[ext]"  />
            <artifacts pattern="${conf.dir.test}/[artifact].[ext]"  />
            <artifacts pattern="${conf.dir.deploy}/[artifact].[ext]"  />

            <artifacts pattern="${build.dir}/[artifact].[ext]" />

</ivy:publish>

my resolver pattern which partitions the artifacts by their types and allows
me to keep track of different module revisions in different folders:

<artifact
pattern="${dest.repo.dir}/no-namespace/[organisation]/[module]/[module]-[revision]/[type]s/[artifact].[ext]"
/>


a couple problems still remain:

1.) if I have files with the same name under the different configurations
and types (i.e. ivyplay.conf both in conf.dir and conf.dir.test), then the
first resolved file (from conf.dir) is used for all successive
dependencies.  In this case all three folders (conf.dir, conf.dir.test, and
conf.dir.deploy) will contain the ivyplay.conf file of (conf.dir).

2.) perhaps this should go in another thread, but:   Is it possible to have
different patterns for different artifacts.  For example, as Joshua
suggested, I can remove the revision from my pattern, but this results in
the revision being removed from all types of artifacts (including my jar
files).  I wish to keep the revision for jars, BUT remove it from
configuration files (as manual work will be required during deployment to
strip them in order for programs to function properly).  I tried a few
things with chained resolvers without any results.  I tried setting up two
resolvers, each with it's own pattern, but I'm not able to have two
different publish tasks (one for jars, and one for artifacts) each of which
would use a different resolver.

Any suggestions are very appreciated.  Thank you all in advance for your
support.

-Sam

Re: Location of configuration files as artifacts

Posted by Joshua Tharp <jo...@alumni.calpoly.edu>.
I can't help with the different config files and types... but the revision
number is specified in your ivysettings.xml file or in your publish task.
You currently have a pattern defined (perhaps by the default settings) that
looks something like [artifact]-[revision].[ext] just change it to
[artifact].[ext] and you will lose the revision number in your file names.

On Fri, May 8, 2009 at 4:39 PM, snowflake <ne...@gmail.com> wrote:

> Hi,
>
> I am not sure how I can set the location of different artifacts which I
> want
> to publish.  I tried a hack, which was to have my publish target copy my
> configuration files that I want to publish to the build directory.  I am
> very new to Ivy and would appreciate any suggestions.
>
> I would like different configuration types to match my different ivy
> views/configurations.  Here is how my ivy.xml is set up:
>
>  <configurations>
>        <conf name="default" visibility="public" />
>        <conf name="deploy" visibility="public" />
>        <conf name="test" visibility="public" />
> </configurations>
>
>
> <publications>
>        <artifact name="ivyplay" type="defaultConfigFile"   conf="default"
> ext="conf" />
>        <artifact name="ivyplay"  type="deployConfigFile"   conf="deploy"
> ext="conf"/>
>        <artifact name="ivyplay"    type="testConfigFile"   conf="test"
> ext="conf"/>
>
>        <artifact name="ivyplay" type="jar" ext="jar" />
> </publications>
>
>
> As a result, in my repository i would like to see under my project, three
> directories, "defaultConfigFiles" , "deployConfigFiles", and
> "testConfigFiles".
>
> The problem is, I have files with the same exact name, and thus my simple
> copying them all to the build directory does not work.
>
> I looked at the documentation and noticed you can set a url for each
> artifact, but I don't believe that will solve my problem.  I just need to
> somehow notify the publish task of the location(s) of my configuration
> files.  I even tried a different publish task for each configuration type
> to
> no avail:
>
> <ivy:publish artifactspattern="${build.dir}/[artifact].[ext]"
> resolver="my-repository" pubrevision="${revision}" status="release" />
> <ivy:publish artifactspattern="${conf.dir}/[artifact].[ext]"
> resolver="my-repository" pubrevision="${revision}" status="release" />
> <ivy:publish artifactspattern="${test.conf.dir}/[artifact].[ext]"
> resolver="my-repository" pubrevision="${revision}" status="release" />
> ...
>
>
> In general, how does one go about handling configuration files such as
> these?  Also, how does one go about removing the revision numbers appended
> to the file names of the configuration artifacts?  I'm sure this can be
> done
> manually at some point but is there a better way?  For example, my project
> my publish mysql.properties-1.conf , but in the code i'm simply looking for
> mysql.properties
>
>
> any suggestions?
>
> thanks,
>
> Sam
>