You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by ch...@transport.qld.gov.au on 2008/03/17 08:29:55 UTC

Reading a property from the settings.xml file inside a pom.xml file.

Hi

I'm trying to SIGN jar files using the sign goal with the maven JAR 
plugin. To sign a jar file, you would use the following code in your 
pom.xml file as an example:

<!-- Build Settings -->
  <build>
    <finalName>${artifactId}-${version}</finalName>
        <plugins>
                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <executions>
                                <execution>
                                        <goals>
                                                <goal>sign</goal>
                                        </goals>
                                </execution>
                        </executions>
                        <configuration>
                                <keystore>c:/key/systest.jks</keystore>
                                <alias>SomeAliasHere</alias>
                                <storepass>SomeStorePass</storepass>
                        </configuration>
                </plugin>
        </plugins>
  </build>

Now, i want the keystore, the alias and the storepass settings read from 
the settings.xml file instead of hardcoded in the pom.xml file by a name i 
can give. I also need the option so that another artifact could use a 
complete set of different settings in the settings.xml file. Is there 
anywhere i can go to get an example of how this is done? Could someone 
provide some example code here to get this going?

Thanks for the help in advance,

***********************************************************************
WARNING: This e-mail (including any attachments) may contain legally
privileged, confidential or private information and may be protected by
copyright. You may only use it if you are the person(s) it was intended
to be sent to and if you use it in an authorised way.  No one is 
allowed to use, review, alter, transmit, disclose, distribute, print 
or copy this e-mail without appropriate authority.

If this e-mail was not intended for you and was sent to you by mistake,
please telephone or e-mail me immediately, destroy any hardcopies of
this e-mail and delete it and any copies of it from your computer
system. Any right which the sender may have under copyright law, and 
any legal privilege and confidentiality attached to this e-mail is not 
waived or destroyed by that mistake.

It is your responsibility to ensure that this e-mail does not contain
and is not affected by computer viruses, defects or interference by
third parties or replication problems (including incompatibility with
your computer system).

Opinions contained in this e-mail do not necessarily reflect the
opinions of the Queensland Department of Main Roads, Queensland
Transport or Maritime Safety Queensland, or endorsed organisations
utilising the same infrastructure.
***********************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Reading a property from the settings.xml file inside a pom.xml file.

Posted by Samuel Le Berrigaud <sa...@gmail.com>.
Hi Chris,

You can simply use properties in an activated profile of your settings.xml,
see
http://maven.apache.org/ref/current/maven-settings/settings.html#class_profile
Then properties are simply referenced in your pom as ${property name}.

That would be something like the following in your pom.xml:

 <build>
   <finalName>${artifactId}-${version}</finalName>
       <plugins>
               <plugin>
                       <groupId>org.apache.maven.plugins</groupId>
                       <artifactId>maven-jar-plugin</artifactId>
                       <executions>
                               <execution>
                                       <goals>
                                               <goal>sign</goal>
                                       </goals>
                               </execution>
                       </executions>
                       <configuration>
                               <keystore>${keystore}</keystore>
                               <alias>SomeAliasHere</alias>
                               <storepass>SomeStorePass</storepass>
                       </configuration>
               </plugin>
       </plugins>
 </build>


And you would have something like this in the activated profile of your
settings.xml:

<properties>
  <keystore>c:/key/systest.jks</keystore>
</properties>

You can also define the property in your pom.xml and it would stand as the
default value.

Regarding different set of properties for different project, I would scope
the properties names such as "com.mycompany.myproject.keystore".
You could also use different profile, but to my opininon this is more
complicated to use and more likely to be of some problem if you ever need to
activate multiple profiles at the same time…

Hope this helps,
SaM



On Mon, Mar 17, 2008 at 6:29 PM, <ch...@transport.qld.gov.au> wrote:

> Hi
>
> I'm trying to SIGN jar files using the sign goal with the maven JAR
> plugin. To sign a jar file, you would use the following code in your
> pom.xml file as an example:
>
> <!-- Build Settings -->
>  <build>
>    <finalName>${artifactId}-${version}</finalName>
>        <plugins>
>                <plugin>
>                        <groupId>org.apache.maven.plugins</groupId>
>                        <artifactId>maven-jar-plugin</artifactId>
>                        <executions>
>                                <execution>
>                                        <goals>
>                                                <goal>sign</goal>
>                                        </goals>
>                                </execution>
>                        </executions>
>                        <configuration>
>                                <keystore>c:/key/systest.jks</keystore>
>                                <alias>SomeAliasHere</alias>
>                                <storepass>SomeStorePass</storepass>
>                        </configuration>
>                </plugin>
>        </plugins>
>  </build>
>
> Now, i want the keystore, the alias and the storepass settings read from
> the settings.xml file instead of hardcoded in the pom.xml file by a name i
> can give. I also need the option so that another artifact could use a
> complete set of different settings in the settings.xml file. Is there
> anywhere i can go to get an example of how this is done? Could someone
> provide some example code here to get this going?
>
> Thanks for the help in advance,
>
> ***********************************************************************
> WARNING: This e-mail (including any attachments) may contain legally
> privileged, confidential or private information and may be protected by
> copyright. You may only use it if you are the person(s) it was intended
> to be sent to and if you use it in an authorised way.  No one is
> allowed to use, review, alter, transmit, disclose, distribute, print
> or copy this e-mail without appropriate authority.
>
> If this e-mail was not intended for you and was sent to you by mistake,
> please telephone or e-mail me immediately, destroy any hardcopies of
> this e-mail and delete it and any copies of it from your computer
> system. Any right which the sender may have under copyright law, and
> any legal privilege and confidentiality attached to this e-mail is not
> waived or destroyed by that mistake.
>
> It is your responsibility to ensure that this e-mail does not contain
> and is not affected by computer viruses, defects or interference by
> third parties or replication problems (including incompatibility with
> your computer system).
>
> Opinions contained in this e-mail do not necessarily reflect the
> opinions of the Queensland Department of Main Roads, Queensland
> Transport or Maritime Safety Queensland, or endorsed organisations
> utilising the same infrastructure.
> ***********************************************************************
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>


-- 
Samuel Le Berrigaud