Disable auto compilation of LESS - css

I am in Eclipse environment. I want LESS to compile only when explicitly invoked via mvn package. At the moment, as soon as I make any changes in my less file it propagates the change to CSS. What should I do to avoid this behaviour?
<plugin>
<groupId>org.lesscss</groupId>
<artifactId>lesscss-maven-plugin</artifactId>
<version>1.7.0.1.1</version>
<configuration>
<watch>false</watch>
<sourceDirectory>src/main/webapp/css</sourceDirectory>
<outputDirectory>src/main/webapp/css</outputDirectory>
<compress>true</compress>
<force>true</force>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
also posted this issue here

As a workaround I have encapsulated LESS plugin inside a profile. On server side I invoke that profile to do LESS compilation
mvn package -pless_compile

M2Eclipse is an Eclipse plugin which provides tight integration for Maven. It determines who and when plugins should be executed. Each plugin can store lifecycle mapping metadata with data on which it based its decision (see M2E compatible maven plugins). By default this plugin is called on incremental builds:
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<goals>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
<runOnConfiguration>false</runOnConfiguration>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
If you want to disable automatic compilation, then you need to add the following entry to your pom.xml:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.lesscss</groupId>
<artifactId>lesscss-maven-plugin</artifactId>
<versionRange>[0,)</versionRange>
<goals>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>

You need to define in which maven phase you want to execute your plugin, basically adding the phase tag under the execution tag. Take look to the following examples: http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_executions_Tag.

Related

Dependencies in fat jar not working outside of IDE (Java 8)

So im working on this JavaFx application (Java 8) which copies a .xlsx file and fills it with data from a .txt-file, for this I use the apache poi dependency. I have successfully build a fat jar through the maven-assembly-plugin. Here my pom.xml:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<archive>
<manifest>
<mainClass>sample.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
</dependencies>
I build it with:
mvn clean compile assembly:single
The application and its dependencies work fine when I run the main.java in IntelliJ, also the built fat jar starts and works fine when I run it through IntelliJ (performes all functions without a problem).
Only when I start my fat jar outside of the IDE, through a cmd-file (to start the JavaFx application), I'm encountering problems. It starts and loads the .txt-file just fine, but at the point where it's supposed to use the dependency and create a worksheet the program does nothing. Here's what I run in .cmd-file:
start javaw -jar ExcelConverter-1.0-jar-with-dependencies.jar
I've tried building it with various other plugins (shade etc), all seem to have the same problem.
I've also tried building it through intelliJ as an artifact, same issue.
Dependency order is also not an issue as I only use one.
use maven shade plugin for this .check http://maven.apache.org/plugins/maven-shade-plugin/index.html.
below is the sample
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
The problem wasn't the plugins or dependencies not working but that the apache-poi dependency was too memory intensive and thus my JVM ran out of memory. The IntelliJ IDE I've installed uses JVM 64-bit by default, my system on the other hand was using a 32-bit version. I was able to update my JVM to 64 bit and getting it to work fine.

Intellij does not update CSS with LessCSS Maven plugin

I am currently using lesscss-maven-plugin by org.lesscss in my Intellij Spring application; the build is ok, and it is compiling properly.
<build>
<plugins>
<plugin>
<groupId>org.lesscss</groupId>
<artifactId>lesscss-maven-plugin</artifactId>
<version>1.7.0.1.1</version>
<configuration>
<sourceDirectory>${project.basedir}/src/main/webapp/resources/less</sourceDirectory>
<outputDirectory>${project.basedir}/src/main/webapp/resources/css</outputDirectory>
<compress>true</compress>
<includes>
<include>bootstrap/bootstrap.less</include>
<include>template.less</include>
<include>var.less</include>
</includes>
<force>true</force>
<lessJs>${project.basedir}/src/main/webapp/resources/js/less-rhino-1.7.0.js</lessJs>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
To update the css output directory, I have to run a mvn clean install and relaunch my tomcat... This is definitely not efficient !!
This method works perfectly under Eclipse.
You can use the "Maven Projects" tab, go to the project and look under "Plugins" for the lesscss plugin. Set it to Execute before/after your desired step and you should be golden.
A more elegant and global setting would be cool, though. Anyone else have a hint?

maven-failsafe-plugin won't run on verify and does not find xml on failsafe:verify

The Maven failsafe plugin will not run on my project. If I run mvn verify only surefire runs. If I type mvn failsafe:verify it fails with the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.11:verify (default-cli) on project experiment-server: /home/user/workspace/MyProject-Main/MyProject-IntegrationTest/target/failsafe-summary.xml (The system cannot find the path specified) -> [Help 1]
So I basicly have the same problem as: failsafe plugin won't run on one project but will run on another -- why?
With the difference that my pom already looks like this:
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.14.1</version>
<executions>
<execution>
<id>failsafe-integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>failsafe-verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
And this was the solution to this guys problem. Except the solutions on this site didn't work for me. Can someone point out where I messed up?
I also have the problem that I want to start a server with exec-maven-plugin in pre-integration-phase. But when I try mvn-verify it's the very last thing that gets executed.
Just found out for this one, solution is here: http://maven.apache.org/surefire/maven-failsafe-plugin/plugin-info.html
maven-failsafe-plugin, contrarely to maven-compiler-plugin for example, is NOT in the default maven build lifecycle.
Consequently, one must respect this tags hierarchy:
<project>
<build>
<pluginManagement>
<plugins>
<!-- For understanding only, below is the 'maven-compiler-plugin':
its path is 'project -> build -> pluginManagement -> plugins
-> plugin', because it's defaulty part of the maven build
lifecycle: we just 'manage' it -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
..
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- HERE is the 'maven-failsafe-plugin':
its path is 'project -> build -> plugins ->
plugin', because it's NOT defaulty part of
the maven build lifecycle: we have to
'define' it, and not just manage it as
stated earlier -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
..
</plugin>
</plugins>
</build>
<project>
Quoting from the official documentation link: "To define the plugin version in your parent POM" and "To use the plugin goals in your POM or parent POM". One must pay attention to the difference.
I moved my failsafe pom snippet to the parents pom and that seems to do the trick. I have no Idea why.

How to set custom icon for javafx native package icon on Windows

I am trying to chance the icon of the exe file while creating native bundling of javafx packaging.
I tried adding icon into pom.xml but till it wont work out for me as it gives default icon
Using Intellij IDEA IDE which contain an Pom.xml creating an package by command = mvn jfx:build-native
Here is my pom.xml:
<build>
<plugins>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<mainClass>com.demoApp.testapp.testApplication</mainClass>
<!-- only required if signing the jar file -->
<keyStoreAlias>example-user</keyStoreAlias>
<keyStorePassword>example-password</keyStorePassword>
<permissions>
<permission>all-permissions</permission>
</permissions>
<icon>${basedir}/src/main/resources/images/logoIcon.ico</icon>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
I have added an icon path into pom.xml ${basedir}/src/main/resources/images/logoIcon.ico
that will run while native package execute but it wont work out for me
Is any other way to do it ?
Please suggest.
i tried fx tags in pom.xml using ant,here is my changes in pom.xml
<properties>
<javafx.tools.ant.jar>${env.JAVA_HOME}\lib\ant-javafx.jar</javafx.tools.ant.jar> </properties>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>create-launcher-jar</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target xmlns:fx="javafx:com.sun.javafx.tools.ant">
<taskdef
uri="javafx:com.sun.javafx.tools.ant"
resource="com/sun/javafx/tools/ant/antlib.xml"
classpath="${javafx.tools.ant.jar}"/>
<fx:application id="fxApp"
name="${project.name}"
mainClass="com.precisionhawk.flightplanner.FlightPlannerApp"/>
<fx:jar destfile="${project.build.directory}/${project.build.finalName}-launcher">
<fx:application refid="fxApp"/>
<fx:fileset dir="${project.build.directory}/classes"/>
</fx:jar>
<attachartifact file="${project.build.directory}/${project.build.finalName}-launcher.jar"
classifier="launcher"/>
<fx:deploy>
<fx:info>
<fx:icon href="${basedir}/src/main/deploy/logoIcon.ico"></fx:icon>
</fx:info>
</fx:deploy>
</target>
</configuration>
</execution>
</executions>
</plugin>
but it wont work out..
I just struggled with the same issue using Zonsky's great javafx-maven-plugin. As of version 1.5, which you also were using, the src/main/deploy directory will be added to the classpath. The icon you want to use could be added there and it will be available on the classpath for the native builder!
I added src/main/deploy/package/windows/myapp.ico there and it finally worked :)
For you:
Create src/main/deploy/package/windows/ folder
Add icon with name ${project.build.finalName}.ico
Run mvn jfx:build-native
I haven't played with it extensively - just got it to work and wanted to share. So if you want to use icon with different name, I don't know how. Not yet at least. The <icon>...</icon> section in the config section seems to be for webstart, so I haven't been using it.
Hope you get it to work!
You need to look at the logging while building a native app. That will tell you where the installer looks for the icon files and with wich name. For the default Windows native app it looks in ./package/windows/'appname'.ico
Can't remember where 'appname' comes from, but just look at the logging while building, it will tell you. (I use the Ant targets called from my pom btw)
you can do this:
`<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<vendor>YourCompany</vendor>
<mainClass>com.alan344.MapperGenApplication</mainClass>
<appName>mybatis-friend</appName>
<bundleArguments>
<icon>${project.basedir}/src/main/resources/image/icon.ico</icon>
</bundleArguments>
</configuration>
</plugin>`

Error reading assemblies: No assembly descriptors found

I get Error reading assemblies: No assembly descriptors found when building my project. I'm trying to set permissions for my .sh files and exclude a nasty .jar file that makes my application crash...I don't think the problem is about that though....
My maven-assembly plugin is added like this in my pom.xml file:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/src.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
My assembly descriptor looks like this:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>my-assembly-descriptor</id>
<formats>
<format>jar</format>
<format>war</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>${project.build.directory}</outputDirectory>
<includes>
<include>*.sh</include>
</includes>
<fileMode>0755</fileMode>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<excludes>
<exclude>spring-2.5.4.jar</exclude>
</excludes>
</dependencySet>
</dependencySets>
</assembly>
The structure in my project is:
Interface - src - main - assembly - src.xml
- pom.xml
When trying to do Run as -> Debug as -> and then in goal putting
assembly:single
I get the same error. I tried in console, with assembly:assembly, and I got nothing. I even tried to put a wrong path to my assembly descriptor, but the error didn't change. When putting ${basedir}/ before the path to my assembly descriptor, I get the same.
I have Ubuntu 10.10 Maverick Meerkat, and I'm working with Eclipse EE,...
Thanks!
I have been using version 2.3 of maven-assembly-plugin, but I believe the problem is the same: if the assembly configuration is declared inside an execution, it works from mvn package, but does not work from mvn assembly:assembly.
The solution I have found is to declare the configuration in the top-level configuration of the plugin, and keep the execution as small as possible:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/standalone.xml</descriptor>
</descriptors>
<finalName>standalone</finalName>
</configuration>
<executions>
<execution>
<id>standalone</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
It seems that you have configured the assembly plugin in <build>...<pluginManagement>...<plugins>. It should work if you configure the plugin in <build>...<plugins>.
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/src.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I was also facing the same issue with below command
$mvn clean assembly:single
But below command worked for me
$mvn clean assembly:assembly

Resources