Where can I find the schema definition for nbactions.xml?  I'm using the Payara 
Micro maven plugin, and I need to pass some environment variables to the war.  
I'd like to put the variables in an .env file (similarly how I do with the 
Docker runtime).

Here is my nbactions.xml:

<?xml version="1.0" encoding="UTF-8"?>
<actions>
    <action>
        <actionName>debug</actionName>
        <packagings>
            <packaging>war</packaging>
        </packagings>
        <goals>
            <goal>resources:resources</goal>
            <goal>compiler:compile</goal>
            <goal>war:exploded</goal>
            <goal>payara-micro:stop</goal>
            <goal>payara-micro:start</goal>
        </goals>
        <properties>
            <exec.args>-Xdebug 
-Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}</exec.args>
            <jpda.listen>true</jpda.listen>
            <netbeans.deploy.debugmode>true</netbeans.deploy.debugmode>
            <netbeans.deploy>false</netbeans.deploy>
            <Env.DATABASE_USER>user</Env.DATABASE_USER>
            <Env.DATABASE_PASS>password</Env.DATABASE_PASS>
            <Env.DATABASE_NAME>MyDatabase</Env.DATABASE_NAME>
            <Env.DATABASE_SERVER>MyServer</Env.DATABASE_SERVER>
            <Env.DATABASE_SERVER_PORT>1433</Env.DATABASE_SERVER_PORT>
            <Env.DATABASE_SERVER_ENCRYPT>true</Env.DATABASE_SERVER_ENCRYPT>
        </properties>
    </action>
    <action>
        <actionName>run</actionName>
        <packagings>
            <packaging>war</packaging>
        </packagings>
        <goals>
            <goal>resources:resources</goal>
            <goal>compiler:compile</goal>
            <goal>war:exploded</goal>
            <goal>payara-micro:stop</goal>
            <goal>payara-micro:start</goal>
        </goals>
        <properties>
            <netbeans.deploy>false</netbeans.deploy>
            <Env.DATABASE_USER>user</Env.DATABASE_USER>
            <Env.DATABASE_PASS>password</Env.DATABASE_PASS>
            <Env.DATABASE_NAME>MyDatabase</Env.DATABASE_NAME>
            <Env.DATABASE_SERVER>MyServer</Env.DATABASE_SERVER>
            <Env.DATABASE_SERVER_PORT>1433</Env.DATABASE_SERVER_PORT>
            <Env.DATABASE_SERVER_ENCRYPT>true</Env.DATABASE_SERVER_ENCRYPT>
        </properties>
    </action>
</actions>

In Netbeans, whether running or debugging, those environment variables are 
passed to the war runtime and used in payara-resources.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//Payara.fish//DTD Payara Server 4 Resource 
Definitions//EN" 
"https://raw.githubusercontent.com/payara/Payara-Server-Documentation/master/schemas/payara-resources_1_6.dtd";>
<resources>
    <jdbc-resource pool-name="DMSDB" jndi-name="java:app/jdbc/my-service" 
enabled="true" ></jdbc-resource>

    <jdbc-connection-pool 
datasource-classname="com.microsoft.sqlserver.jdbc.SQLServerDataSource"
                          name="MyDB"
                          res-type="javax.sql.DataSource"
                          is-connection-validation-required="true"
                          connection-validation-method="table"
                          validation-table-name="sys.tables"
                          fail-all-connections="true">
        <property name="User" value="${ENV=DATABASE_USER}"></property>
        <property name="Password" value="${ENV=DATABASE_PASS}"></property>
        <property name="DatabaseName" value="${ENV=DATABASE_NAME}"></property>
        <property name="ServerName" value="${ENV=DATABASE_SERVER}"></property>
        <property name="PortNumber" 
value="${ENV=DATABASE_SERVER_PORT}"></property>
        <property name="Encrypt" 
value="${ENV=DATABASE_SERVER_ENCRYPT}"></property>
    </jdbc-connection-pool>
</resources>

When running a docker container, I can use a file, say .env, and load that up 
when running the container.

DATABASE_NAME=MyDatabase
DATABASE_SERVER=MyServer
DATABASE_SERVER_PORT=1433
DATABASE_USER=user
DATABASE_PASS=password
DATABASE_SERVER_ENCRYPT=true

The motivation is to add the .env file to .gitignore so each developer can 
customize those connection properties in that file but leave nbactions.xml 
alone.

Reply via email to