Menu
  • HOME
  • TAGS

What is a better way for checking for the existence of an environment variable in the Maven antrun plugin?

Tag: maven,environment-variables,antrun,maven-antrun-plugin

I’m using Maven 3.2.3. I have this for my ant run plugin …

                                                    <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-antrun-plugin</artifactId>
                            <version>1.8</version>
                            <dependencies>
                                    <dependency>
                                            <groupId>ant-contrib</groupId>
                                            <artifactId>ant-contrib</artifactId>
                                            <version>20020829</version>
                                    </dependency>
                            </dependencies>
                            <executions>
                                    <execution>
                                            <id>create-dodeploy-file</id>
                                            <phase>package</phase>
                                            <configuration>
                                                    <target>
                                                            <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
                                                            <property environment="env"/>
                                                            <if>
                                                                    <isset property="env.JBOSS_HOME"/>
                                                                    <then> 
                                                                            <echo file="${JBOSS_HOME}/standalone/deployments/${project.artifactId}.war.dodeploy" append="false" message="" />
                                                                    </then>
                                                            </if> 
                                                    </target>
                                            </configuration>
                                            <goals>
                                                    <goal>run</goal>
                                            </goals>
                                    </execution>
                                    </executions>
                                    </plugin>

Despite the fact I know $JBOSS_HOME is defined in my environment (I’m able to run

echo $JBOSS_HOME

from the same bash shell in which I run my Maven build), the “isset” directive always returns false. Is there a better way to test for the existence of an environment variable in the Antrun plugin?

Best How To :

A target also has the ability to perform its execution if (or unless) a property has been set. To make a target sense this property, you should add the if (or unless) attribute with the name of the property that the target should react to.

<target name="build-if" if="env.JBOSS_HOME"/>

<target name="build-unless" unless="env.JBOSS_HOME"/>

setting JAVA_HOME to the JDK location mac osx 10.9.5

java,osx,maven,java-home

My ~/.bash_profile has this line in it, and it's been working fine. export JAVA_HOME=$(/usr/libexec/java_home) This line basically says "run the program named /usr/libexec/java_home and export its output as a variable named JAVA_HOME." I suggest opening your .profile or .bash_profile in a text editor rather than using echo statements to append...

Python: can't access newly defined environment variables

python,bash,environment-variables

After updating your .bashrc, perform source ~/.bashrc to apply the changes. Also, merge the two BONSAI-related calls into one: export BONSAI=/home/me/Utils/bonsai_v3.2 UPDATE: It was actually an attempt to update the environment for some Eclipse-based IDE. This is a different usecase altogether. It should be described in the Eclipse help. Also,...

Maven multi-project depths

maven

the reactor project (the root of the multimodule project) must have pom packaging. So your nested structure is invalid since A is not of type pom and I'm pretty sure you won't get it to work this way. Second point is that Maven is a modularized build system and uses...

maven activate by property value and version

maven,maven-3

I believe there is no such functionality with out-of-the-box Maven. Maven is usually really simple when looking into its internals. Profile activation based on property is basically about two strings equality, nothing more, no extra logic here. I can image a solution that introduces own, simple Maven plugin that does...

Failed to execute goal on project. Unable to find POM in project

java,maven,jboss

You need to add redhat repo in your pom.xml or setting.xml. Install and Use the Maven Repository such as: <repositories> <repository> <id>jboss-enterprise-techpreview-group</id> <name>JBoss Enterprise Technology Preview Maven Repository Group</name> <url>http://maven.repository.redhat.com/techpreview/all/</url> <layout>default</layout> <releases> <enabled>true</enabled> <updatePolicy>never</updatePolicy> </releases> <snapshots>...

How to configure user bundles so that they can be autostarted with higher priority - hence earlier than others?

java,maven,osgi,equinox

You were right. Start level in OSGi is defined by the @2 you put in your config.ini file. The default (by default) is a start level of 4. It seems that your problem is more related to a directory path problem to access the bundle rather than the load order...

How to access jenkins parent job build id in a MultiJob?

maven,jenkins

I'm using this method to pass the build ID from a parent multi-job into the children jobs: In the parent job, add a "Execute Shell" build step that saves the ${BUILD_ID} into a file, like this: cat > build.properties << _EOF_ PARENT_BUILD_ID=${BUILD_ID} _EOF_ For the "MultiJob Phase" -> "Phase Jobs",...

How to make dependency transitive in Gradle

maven,javamail,android-gradle,build.gradle,gmail-api

The javax.mail-api-1.5.3 can also be downloaded from existing repositories (probably jCenter or mavenCentral) described in your build file. If you aren't tied to using your downloaded version in /libs, you might do this in your build file: dependency { compile 'javax.mail:javax.mail-api:1.5.3' } The default behavior in this case is to...

sonar maven analysis only picks .java file

maven,groovy,sonarqube,sonarqube-5.0

Since it was a multi module project, I had to include the properties sonar.sources and sonar.tests in all the module's pom.xml file. <properties> <sonar.sources>src/main</sonar.sources> <sonar.tests>src/test</sonar.tests> </properties> ...

Ionic - 'platform add android' Comand failed with exit code ENOENT

java,android,cordova,environment-variables,ionic

Sorry don't have enough privilege to comment on your question. I had faced similar issue. run this command before adding android platform, C:\your\Directory>npm link cordova C:\your\Directory>npm link ionic then go for, C:\your\Directory>ionic platform add android hope this helps!...

Maven: copy zipped resource subdirectories into target folder

java,maven,zip

Please read the following article : http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html This has the complete information for creating a zip artifact. ...

Maven Nested Modules - Second Level Children

maven,directory-structure,multi-module

Yeah, be there some time ago. To be honest, after trying things, I believe it's really matter of taste. For me it's much more clear to stick with root's pom.xml as a parent and not doing dedicated module for it. It's also the actual default of Maven, since <relativePath> for...

Referring to an ENV variable through javascript

javascript,ruby-on-rails,google-analytics,environment-variables

I really like this gem for passing back-end variables to Javascript: https://github.com/gazay/gon In your application_controller.rb, you can then add a before_action filter to run a method which means it will load on every page. Using gon you can use code such as this to assign variables: class ApplicationController < ActionController::Base...

Grails 3.0 Searchable plugin

maven,grails

The page you took the instructions from contains the following disclaimer: This portal is for Grails 1.x and 2.x plugins. Grails 3 plugins are available in Bintray https://bintray.com/grails/plugins There currenly is no version of this plugin for grails 3.x...

Maven error with Java 8

java,maven,java-8

Add plugin configuration for the compiler: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <verbose>true</verbose> <fork>true</fork> <source>1.8</source> <target>1.8</target> </configuration> </plugin> ...

python itertools combinations logic

python,environment-variables,itertools,scopes

Python is not block scoped. Roughly speaking, Python is function scoped. In other languages, if you did for (int i = 0; i < whatever; i++) { ... } then i would be local to the for loop. In Python, the equivalent for i in xrange(whatever): uses an i variable...

Maven hamcrest parent depedency failed to resolve

maven,maven-3,dependency-management

Correct. There is no such artifact of jar type which is default if you don't specify any. This one will work: <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-parent</artifactId> <version>1.3</version> <type>pom</type> </dependency> ...

Compilation Error on maven

java,eclipse,maven,maven-plugin

Check with that below dependency is it present or not ?? <dependency> <groupId>javax.ws.rs</groupId> <artifactId>javax.ws.rs-api</artifactId> <version>2.0-m01</version> </dependency> ...

Eclipse error using Maven filtering in persistence.xml

maven,jar,persistence,filtering

I have solved it this way: in persistence.xml substitute the whole <jar-file> tag, i.e. <persistence-unit name="PersistenceUnit" transaction-type="JTA"> ... <!-- here is where the jar file is supposed to go --> ${importjarfile} ... </persistence-unit> Then include in pom.xml the property <properties> <!-- jar of persistence --> <importjarfile><![CDATA[<jar-file>lib/${project.persistencejar}.jar</jar-file>]]></importjarfile> </properties> or alternatively in...

Use alternative producers of EntityManager / EMF in integration tests

java,maven,jpa,integration-testing,cdi

After some research i found that DeltaSpike already has module called 'Test-Control', which enable use CDI in tests. So i decided to extend current EMF producer to read name of persistence unit from property file which contains configuration. Different property files in src/main/resources and src/test/resources lets me use different persistence...

maven-war-plugin include subdirectories

java,maven,maven-war-plugin

You can force maven-war-plugin to add empty folders if you say explicitly by using the appropriate configuration parameter: <project> ... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.6</version> <configuration> <includeEmptyDirectories>true</includeEmptyDirectories> .. </configuration> </plugin> </plugins> </build> ... </project> ...

Maven can not find the 'main' class for my Java app

java,maven

Class names are case-sensitive. Your class is called Main so the manifest should be: <manifest> <mainClass>com.ollio.nlp.Main</mainClass> </manifest> ...

Eclipse Kepler is unable to set the Java jdk 1.8 when maven project is updated

java,maven,java-8,eclipse-kepler

With the help of Hogler's comment above I am able to reswolve this issue Just did this : https://wiki.eclipse.org/JDT/Eclipse_Java_8_Support_For_Kepler...

Unable to download com.thoughtworks.paranamer#paranamer;2.5.6 with sbt

maven,sbt

Author of Paranamer here. I've no idea why this happened. Could be related to https://issues.sonatype.org/browse/OSSRH-16113 Paul ...

Switching branches in Git with external dependencies

git,maven,dependencies,git-branch

It actually depends on an IDE you're using. I haven't noticed any issue with this when using IntelliJ IDEA. It handles any pom.xml changes on the filesystem level very smoothly. However, some time ago, when I was using Eclipse, I believe I saw such a problem you're talking about. Then...

spring.xml not packaged in executable jar

java,spring,maven,executable-jar

If you're using maven, you can put your XML files in src/main/resources. By default, all files placed in the resources folder will be included in the jar file and will be accessible by your application.

is it possible to filter artifacts in Maven-release-plugin?

maven,maven-release-plugin

I believe what you actually want to do is to release all modules (to handle proper versioning, dependencies, etc.) and only skip deploying some of them. If so, you can skip particular module for maven-deploy-plugin by its configuration: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <configuration> <skip>true</skip> </configuration> </plugin> or user property: <properties> <maven.deploy.skip>true</maven.deploy.skip>...

Unable to load servlet listener class: com.sun.faces.config.ConfigureListener

maven,jsf,tomee

Simply get rid of the in the exception mentioned <listener> entry in webapp's web.xml. TomEE ships with MyFaces, not Mojarra. That Mojarra-specific <listener> entry in web.xml is usually auto-included by some IDEs trying to be smarter than they are and/or left behind in poor quality open source projects. Be careful...

How to create zip file with maven: Java Client + JRE

java,maven,zip,client

Take a look at Apache Maven Assembly Plugin. For datailed instructions, see here and here....

Importing an OSGI bundle into eclipse

java,eclipse,maven,dependency-management,osgi-bundle

You will need to also install bundles that export these packages into your target platform.

Different ways to override java version especified in parent pom

java,maven,pom.xml

Properties are just properties, which do not mean much unless you use them somewhere. The important thing is that you set the version in the maven-compiler-pluginconfiguration: <properties> <jdk.version>1.6</jdk.version> </properties> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>${jdk.version}</source>...

spring-boot integration testing using rest-assured

maven,spring-boot,h2

Are you using Eclipse? I somehow noticed that src/main/resources/application.properties gets excluded from the Java Build Path, if you generate the project with the "eclipse:eclipse" maven goal. To workaround this you can either add a src/test/resources/application.properties or correct the Java Build Path. I don't know if this behavior is intended. I...

How do you create a custom project type (from my plugin) without opening Eclipse?

java,eclipse,maven,eclipse-plugin

Here are my findings :- I went through the advice of Amos M. Carpenter and searched for the source code of the plugin that I have written. After that, I did a debug (Plugin Debug) and searched for the methods that are called when we create a project from the...

Liquibase 3.3.3 refusing to run “due to maven configuration”

maven,liquibase

Check here: CORE-2360 It looks like <skip> is set to true by default in 3.3.3 version. Just use 3.3.4 and it should be OK.

Cannot import correctly maven properties with PropertiesFactoryBean and PropertyPlaceholderConfigurer in spring

spring,maven,datasource,placeholder,jrebel

This can happen if you're using resource filtering with JRebel, as the application looks up the bean's xml in its unfiltered form from the project working directory (as per rebel.xml). To resolve this, you'll need to update rebel.xml for that module, adding exclude for that particular XML file - see...

how to manage multiple war application in tomcat server?

java,maven,tomcat,servlets

Use same tomcat server, but copy and rename your web application to something different. For eg, original application name app, copy and rename as following. webapp -> app1 app2 app3 Running tomcat server per each war application need to maintain many server. This is a bad idea....

Maven local artifactory file edit

java,maven,artifactory

First, do not upload maven-metadata files. They are generated by Artifactory for you. Second, since Artifactory usually manages uneditable binary files, there is no edit functionality in Artifactory. I am with JFrog, the company behind Bintray and [artifactory], see my profile for details and links....

Dyanamic web module 3.0 required java 1.6 or newer

java,maven,spring-mvc

When I got this error setting java version in pom fixed my problem In pom.xml you can set java version you can do this by setting below properties <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> or by providing version in maven-compiler-plugin....

deploying ejb-module for ObjectDB fails: PersistenceProvider not found

java,maven,ejb,wildfly,objectdb

Wow just writing about it here on SO helped me find my error :) I just have to force maven to include all dependencies. This can be done by including the following plugin into the pom.xml: <plugins> ... <plugin> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> <configuration> <descriptorRefs>...

Missing artifact error while adding a depentency in pom

java,maven

You have used mismatched versions: sauce-connect-plugin presents in: http://repository-saucelabs.forge.cloudbees.com/release/com/saucelabs/sauce-connect-plugin/ which have only versions of 1.0.11, 1.0.12, 1.0.13 and 1.0.14. But you have tried to download 2.1.18 What you mentioned with the URL http://repository-saucelabs.forge.cloudbees.com/release/com/saucelabs/sauce-connect/3.1.32/ will not represent for sauce-connect-plugin. It will represent for only sauce-connect So you should try with following...

@RestController throws HTTP Status 406

java,spring,rest,maven

The issue is with the dependencies that you have in pom.xml file. In Spring 4.1.* version the pom.xml dependency for Jackson libraries should include these: <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.4.1</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.1.1</version> </dependency> You...

Trying to access Oracle's Maven repository

oracle,maven,repository

From your settings.xml I can see that you use Artifactory. Why won't you define Oracle's repository as a remote in Artifactory? That will make the access much easier. Here's a simple guide on how to do so. And, of course, here's the official user guide on it. I am with...

Logging with log4j2 in Spring Boot app

java,spring,maven,logging,log4j2

You have multiple SLF4J bindings in your classpath. Logback classic, which is included by default in spring boot Log4j that you want to use. You need to have a single one in the classpath, by using maven dependency exclusion....

How to deploy public-project Maven artifacts to a different remote repository?

maven

To deploy the created artifacts into another maven repository you need to add or change the <distributionManagement> section of the pom. Or add one and replace the one in the parent. The result will be that the deploy goal will upload the artifacts to the new location. Furthermore I would...

IntelliJ - use imported modules as dependencies like maven projects in Eclipse

eclipse,scala,maven,intellij-idea,sbt

It should work out of box for dependencies, which are imported to the project as modules, no additional settings needed. At least for Java. Just do not run a Maven goal, that would use dependencies from the repository. ...

How to use a local tomcat version with maven

java,maven,tomcat

I found a solution here: https://tomcat.apache.org/maven-plugin-trunk/executable-war-jar.html Ex you set the serverXml to point to your local tomcat installation. <project> ... <packaging>war or pom</packaging> ... <build> ... <plugins> ... <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.3-SNAPSHOT</version> <executions> <execution> <id>tomcat-run</id> <goals>...

Flink error - org.apache.hadoop.ipc.RemoteException: Server IPC version 9 cannot communicate with client version 4

maven,hadoop,flink

Have you tried the Hadoop-2 build of Flink? Have a look at the downloads page. There is a build called flink-0.9.0-milestone-1-bin-hadoop2.tgz that should work with Hadoop 2.

Deploy closed source aar maven repo to github

android,git,maven,github,gradle

use the raw link, try changing blob for raw: http://downright-amazed.blogspot.com/2011/09/hosting-maven-repository-on-github-for.html...

Gradle: Adding sources.jar file within /lib folder of published dist.zip along with all my other dependencies

java,maven,jar,gradle

You need to tell the application plugin to include the output of your sourcesJar task in the distribution: distributions { main { contents { from sourcesJar } } } That will place it in the root, if you want it somewhere else you can do this: distributions { main {...

exec-maven-plugin error, even on working example

java,eclipse,maven

The error log which you posted says the following: java.lang.ClassNotFoundException com.jadex.qna.QNAProject.App So it clear what the root source of the error is. You are trying to execute the main() method of a class whose class file Maven cannot find. As this SO article discusses, you can try explicitly compiling first,...