appassembler maven plugin doesn't set "execute" permissions on generated script - linux

The AppAssembler Maven plugin does a great job of generating distribution for me. One last problem is that the generated Shell script does not have execution permissions so I need to set them manually.
I am on Linux RedHat
Does anybody know of a clean way to set them automatically?

The only way to do this is to process the file with another maven plugin like Antrun or Assembly after running AppAssembler.
This issue (see link below) has been brought up on the AppAssembler project issue tracker and it was rejected as Won't Fix.
Issue: MAPPASM-54

I think it can be set in your assembly.xml, in the fileSet tag:
<fileSets>
<fileSet>
<directory>src/resources/bin</directory>
<lineEnding>keep</lineEnding>
<useDefaultExcludes>true</useDefaultExcludes>
<outputDirectory>bin</outputDirectory>
<includes>
<include>*.bat</include>
<include>*.sh</include>
</includes>
<fileMode>744</fileMode>
</fileSet>
...

Since Maven 3.0.3 all plugins are executed in the order they are in your pom.xml. So setting the executeable flag in a platform independet manner is as easy as using the maven-enforcer-plugin right after your appassembler plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce-beanshell</id>
<phase>package</phase>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<evaluateBeanshell>
<condition>
import java.io.File;
print("set executable for file ${basedir}/dist/bin/mql");
new File("${basedir}/dist/bin/mql").setExecutable(true,false);
true;
</condition>
</evaluateBeanshell>
</rules>
<fail>false</fail>
</configuration>
</execution>
</executions>
</plugin>

Related

how does the ant use in groovy

this is a groovy script file MavenInit.groovy, execute in a pom.xml as follow, the var 'SCRIPTS_GROOVY' is defined in another pom.xml,what confuse me is I can not find where the "DIR_TARGET" definition, and how can use ant direct without ant = new AntBuilder()
SCRIPTS_GROOVY=project.properties['SCRIPTS_GROOVY']
ant.pathconvert(targetos:"unix", property:"DIR_TARGET") {
path(location:project.build.directory)
}
DIR_TARGET=ant.project.properties['DIR_TARGET']
project.properties.setProperty('DIR_TARGET', "${DIR_TARGET}")
project.properties.setProperty('DIR_LOGS', "${DIR_TARGET}/logs")
ant.mkdir(dir:"${DIR_TARGET}/logs")
the pom.xml excute the MavenInit.groovy as follow
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<executions>
<execution>
<id>set-maven-property</id>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<scripts>
<script>file:///${SCRIPTS_GROOVY}/MavenInit.groovy</script>
</scripts>
</configuration>
</execution>
<execution>
<id>Windows-package</id>
<phase>compile</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<scripts>
<script>file:///${SCRIPTS_GROOVY}/PackageWindows.groovy</script>
</scripts>
</configuration>
</execution>
</executions>
</plugin>
how can I find the 'DIR_TARGET' initial defined and change the value
GMavenplus plugin set an ant property into its script
if (!properties.containsKey("ant")) {
try {
Object antBuilder = invokeConstructor(findConstructor(classWrangler.getClass("groovy.util.AntBuilder")));
properties.put("ant", antBuilder);
}
Also there are other properties like project, log, etc.
About DIR_TARGET, I think it is the value of project.build.directory with path separator normalized as unix like, from path(location: project.build.directory).
(I am not an ant expert, but I test on my computer and these two have same value.
Just adding the log lines to see
log.info( project.build.directory)
DIR_TARGET = ant.project.properties['DIR_TARGET']
log.info(DIR_TARGET)
I searched the ant doc and find an example from https://ant.apache.org/manual/Tasks/pathconvert.html, which verifies my guess.
<pathconvert property="prop" dirsep="|">
<map from="${basedir}/abc/" to=''/>
<path location="abc/def/ghi"/>
</pathconvert>

Hudson Config for Mule (Cloudhub)

I am setting up a job in hudson to build maven based mule application on SVN , uploading to artifactory and then deploy it on cloudhub.
I am able to build project and upload it to artifactory but the problem is how to deploy it on cloudhub after that.
I have groovy post build plugin but not sure what script to write in it to proceed.
Is there anyone who could give me some pointers to proceed??
Thanks in advance
You should use mule-maven-plugin, it is the currently supported way to deploy to CloudHub via Maven. This a sample plugin configuration:
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<deploymentType>cloudhub</deploymentType>
<muleVersion>3.7.0</muleVersion> <!-- This is the runtime version as it appears on the CloudHub interface -->
<username>myUsername</username>
<password>myPassword</password>
<environment>Production</environment>
</configuration>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
And remember to add this to your settings.xml so Maven can find the plugin:
<pluginRepositories>
<pluginRepository>
<id>mule-public</id>
<url>https://repository.mulesoft.org/nexus/content/repositories/releases</url>
</pluginRepository>
</pluginRepositories>
You can use maven cloudhub-maven-plugin. Please refer details at cloudhub-maven-plugin
Hope this helps.

How to set up JASMINE using MAVEN-PLUGIN?

I have a folder structure like
-root
-pom.xml
-service
-web
-pom.xml
-src
-main
-test
-java
-javascript
-lib
-specRunner.js
-runner.html
-spec
-model
-view
-collection
I have written JASMINE test cases in the "spec" folder containing "model","views","collections".
I'm able to see my test results in runner.html.
Now i'm trying to integrate with MAVEN build. SO followed steps given in http://searls.github.io/jasmine-maven-plugin
But i'm getting build failure when doing mvn clean install and unable to see anything on localhost:8234 when doing mvn jasmine:bdd
I'm unable to find out what went wrong. The errors in console show something about require js.
Following is my POM.xml for jasmine-maven plugin
<plugin>
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<version>1.3.1.5</version>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<jsSrcDir>${project.basedir}/src/main/webapp/js</jsSrcDir>
<jsTestSrcDir>${project.basedir}/src/test/javascript</jsTestSrcDir>
<specRunnerTemplate>REQUIRE_JS</specRunnerTemplate>
<preloadSources>
<source>${project.basedir}/src/main/webapp/js/libs/require.js</source>
</preloadSources>
</configuration>
</plugin>
Can anybody guide what is wrong or better provide some demo project (Backbone+Require+Jasmine) which is integrated with MAVEN build.
Thanks in Advance.
I read some blogs and tried editing my jasmine-maven plugin as follows
<plugin>
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<version>1.3.1.5</version>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
<configuration>
<debug>true</debug>
<specRunnerTemplate>REQUIRE_JS</specRunnerTemplate>
<sourceExcludes>
<exclude>lib/jasmine.js</exclude>
<exclude>lib/jasmine-html.js</exclude>
<!--<exclude>libs/text.js</exclude>-->
</sourceExcludes>
<preloadSources>
<source>${basedir}/src/main/webapp/js/libs/require.js</source>
<source>${basedir}/src/main/webapp/js/main.js</source>
</preloadSources>
<jsSrcDir>${basedir}/src/main/webapp/js</jsSrcDir>
<sourceIncludes>
<include>${basedir}/src/main/webapp/jslibs/*.js</include>
<!--<include>libs/jquery-1.9.1.js</include>
<include>libs/underscore-min.js</include>
<include>libs/backbone-min.js</include>
<include>libs/text.js</include>-->
<!--<include>../templates/*.tmpl</include>-->
</sourceIncludes>
<haltOnFailure>true</haltOnFailure>
<jsTestSrcDir>${basedir}/src/test/javascript</jsTestSrcDir>
<serverPort>8234</serverPort>
<specIncludes>
<include>spec/**/*.js</include>
</specIncludes>
<!--<specRunnerHtmlFileName>runner.html</specRunnerHtmlFileName>-->
</configuration>
</execution>
</executions>
</plugin>
Now i'm able to check the JASMINE specs in the console while mvn clean install as follows-
Caused by: net.sourceforge.htmlunit.corejs.javascript.JavaScriptException: Error: src/views/../../templates/menu.tmpl HTTP status: 404
I'm getting errors on template files (exceptions) not sure what this is about.
Any help on this?
Thanks.

Where to get a full list of pre-defined variables in gmaven-plugin?

Where to get a complete list of variables available in Groovy scripts executed under gmaven-plugin in Maven? Besides that, maybe someone knows where to find Gmaven documentation?
I'm aware about project and settings. I assume there are some others..
The page http://docs.codehaus.org/display/GMAVEN/Executing+Groovy+Code lists:
Default Variables
By default a few variables are bound into the scripts environment:
project The maven project, with auto-resolving properties
pom Alias for project
session The executing MavenSession
settings The executing Settings
log A SLF4J Logger instance
ant An AntBuilder instance for easy access to Ant tasks
fail() A helper to throw MojoExecutionException
This snippet in your pom should give you a better idea of what's available while running the script. Most of the interesting bits are probably in the binding.project, an instance of MavenProject.
<build>
<plugins>
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<properties>
<hello>world</hello>
</properties>
<source>
println this.binding.variables
println project.properties
println settings.properties
</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Setting environment variable with maven 2.x

Is it possible to set environment variable with maven (OS: Linux)?
I already have user-defined properties (in the pom and in profiles.xml)....my problem is, how to execute following from Maven
export GGA_FRE=/path
So will be possible, that every developer can set his own path for the GGA_FRE.
This answer is not correct, at least not completely (see comments).
Unfortunately I can't delete it as it has been accepted. Your milage may vary.
Use the exec:exec mojo.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>exportVar</id>
<phase>initialize</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>export</executable>
<arguments>
<argument>GGA_FRE=${my.path}</argument>
</arguments>
</configuration>
</plugin>
now call it like this mvn install -Dmy.path=/var/users/groucho
I don't think there is a Java way to set environment variable the way export command does (so that it is avaliable outside of Java). (see for example this question: How do I set environment variables from Java?)
However, you might hack you way around: for example use maven-exec plugin to run a shell script and then set the variable in the script. You might pass a parameter to your script to specify the variable value.
(note that I have not tested this)

Resources