Below is my configuration of maven-assembly-plugin
and it's working fine.but when i am adding my all plugins inside the pluginManagement
parent tag it's not working.
I am not sure why it's not working
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>MyId</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptor>assemblyFile.xml</descriptor>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
The execution section of your maven-assembly-plugin should not be contained in a pluginManagement section. If it is, it will be ignored. The build will not throw an error - just won't create an executable jar. Then you would get "no main manifest attribute..." if you try to run it.
The pluginManagement section, generally defined in a "parent" pom, shares plugin configuration across modules. It can specify version and configuration and it ensures the version matches across child poms, but is not intended to contain execution details.
Here's a valid example where pluginManagement specifies only the plugin's version (just keep in mind the pluginManagement would typically be in a separate, parent, pom):
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.my.App</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
And here's an example where pluginManagement has the plugin's version and also its configuration. The regular plugin section specifies only the execution details:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.my.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Note that child poms can override pluginManagement definitions.
See also this question and its answers.