You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Madhu <bm...@gmail.com> on 2012/09/11 15:18:50 UTC

How to zip the source code separately using Maven

Please tell me how we can add a task in POM.xml file to zip the source code
separately while build the application. I want both .war file and .zip files
independent of each other. 

Thank you in advance.



-----
Madhu
--
View this message in context: http://maven.40175.n5.nabble.com/How-to-zip-the-source-code-separately-using-Maven-tp5721257.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: How to zip the source code separately using Maven

Posted by Jim McCaskey <ji...@pervasive.com>.
You can use either the Maven source plugin [1] or the more generic Maven Assembly Plugin [2] if you want more control of what goes into your zip.

-Jim


[1] http://maven.apache.org/plugins/maven-source-plugin/
[2] http://maven.apache.org/plugins/maven-assembly-plugin/


-----Original Message-----
From: Madhu [mailto:bm.madhavi@gmail.com]
Sent: Tuesday, September 11, 2012 8:19 AM
To: users@maven.apache.org
Subject: How to zip the source code separately using Maven

Please tell me how we can add a task in POM.xml file to zip the source code
separately while build the application. I want both .war file and .zip files
independent of each other.

Thank you in advance.



-----
Madhu
--
View this message in context: http://maven.40175.n5.nabble.com/How-to-zip-the-source-code-separately-using-Maven-tp5721257.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


NOTICE: All information in and attached to this email may be proprietary, confidential, privileged and otherwise protected from improper or erroneous disclosure. If you are not the sender's intended recipient, you are not authorized to intercept, read, print, retain, copy, forward, or disseminate this message.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Re: How to zip the source code separately using Maven

Posted by Madhu <bm...@gmail.com>.
Thank you guys for your help.

I have a question is there any order for writing the plugins. I wrote my
source plugin at the end it is not doing anything. Another question is what
is the difference between defining the plugin at project-->plugin vs
project-->profile.

the code which I wrote in project --> plugin are is as given below:
<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-source-plugin</artifactId>
					<version>2.2</version>
					<executions>
						<execution>
							<id>attach-source</id>
							<phase>verify</phase>
							<goals>
								<goal>jar</goal>
								<goal>test-jar</goal>
							</goals>
							<configuration>
								<finalName>mySource</finalName>
								<forceCreation>true</forceCreation>
								<includePom>true</includePom>
								<outputDirectory>${basedir}/target</outputDirectory>
							</configuration>
						</execution>
					</executions>
				</plugin>

can we write the code in both plugin and profile areas.

Thank you.



-----
Madhu
--
View this message in context: http://maven.40175.n5.nabble.com/How-to-zip-the-source-code-separately-using-Maven-tp5721257p5721720.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Re: How to zip the source code separately using Maven

Posted by Curtis Rueden <ct...@wisc.edu>.
Hi Madhu,

As suggested earlier, did you try the maven-source-plugin? It might be
easier for you.

        <plugin>
          <artifactId>maven-source-plugin</artifactId>
          <version>2.1.2</version>
          <!-- Build source JARs in addition to binary ones. -->
          <executions>
            <execution>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

This will generate a JAR file like target/myArtifact-x.y.z-sources.jar
containing your sources and resources with Maven metadata including the
POM. You can even deploy the sources JAR to your Maven repository so that
other developers on your team have easy access to the code that goes along
with each binary release.

Alternately, if you really want to use the assembly plugin... your error
message indicates that no descriptors are configured, which is strange
given your plugin block in the POM. Are you using "mvn assembly:single"?
Did you try adding the <executions> block suggested by Jim and just using
"mvn package" to create the assembly?

HTH,
Curtis


On Wed, Sep 12, 2012 at 8:26 AM, Madhu <bm...@gmail.com> wrote:

> This is how my code looks which I wrote:
> This is my source.xml file
> <assembly
> xmlns="
> http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="
> http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
> http://maven.apache.org/xsd/assembly-1.1.0.xsd">
>   <id>src</id>
>   <formats>
>     <format>zip</format>
>   </formats>
>   <fileSets>
>     <fileSet>
>       <directory>${project.basedir}</directory>
>       <includes>
>         <include>src/main/*.java</include>
>         <include>src/main/resources/*.*</include>
>         <include>pom.xml</include>
>       </includes>
>       <useDefaultExcludes>true</useDefaultExcludes>
>     </fileSet>
>     <fileSet>
>
>       <directory>${project.basedir}/src/main</directory>
>       <useDefaultExcludes>true</useDefaultExcludes>
>     </fileSet>
>   </fileSets>
> </assembly>
>
> and in the pom.xml I have written this
>
>
>                                 <plugin>
>
> <artifactId>maven-assembly-plugin</artifactId>
>                                 <version>2.3</version>
>                                 <configuration>
>                                                 <descriptors>
>
> <descriptor>src/assemble/source.xml</descriptor>
>                                                 </descriptors>
>                                 </configuration>
>                         </plugin>
>
> I am not able to understand about goal and where to define the same.
>
> Please advice me what I am missing to make it work correctly.
>
> Thank you.
>
>
>
>
>
> -----
> Madhu
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/How-to-zip-the-source-code-separately-using-Maven-tp5721257p5721532.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

RE: Re: How to zip the source code separately using Maven

Posted by Madhu <bm...@gmail.com>.
This is how my code looks which I wrote:
This is my source.xml file
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
http://maven.apache.org/xsd/assembly-1.1.0.xsd">
  <id>src</id>
  <formats>
    <format>zip</format>
  </formats>
  <fileSets>
    <fileSet>
      <directory>${project.basedir}</directory>
      <includes>
        <include>src/main/*.java</include>
        <include>src/main/resources/*.*</include>
        <include>pom.xml</include>
      </includes>
      <useDefaultExcludes>true</useDefaultExcludes>
    </fileSet>
    <fileSet>
      
      <directory>${project.basedir}/src/main</directory>
      <useDefaultExcludes>true</useDefaultExcludes>
    </fileSet>
  </fileSets>
</assembly>

and in the pom.xml I have written this


				<plugin>
       				<artifactId>maven-assembly-plugin</artifactId>
       				<version>2.3</version>
       				<configuration>
         					<descriptors>
           					<descriptor>src/assemble/source.xml</descriptor>
         					</descriptors>
       				</configuration>
	    		</plugin>

I am not able to understand about goal and where to define the same.

Please advice me what I am missing to make it work correctly.

Thank you.





-----
Madhu
--
View this message in context: http://maven.40175.n5.nabble.com/How-to-zip-the-source-code-separately-using-Maven-tp5721257p5721532.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: Re: How to zip the source code separately using Maven

Posted by Jim McCaskey <ji...@pervasive.com>.
The documentation for the Maven Assembly Plugin [1] is pretty good (for Maven) and you'll probably find most of the answers you seek there.  You are getting the error you described because you have not configured the plugin properly.

You probably need the plugin to look something like this at minimum:

<plugin>
    <groupId>com.pervasive.connectivity</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <descriptorRefs>
            <descriptorRef>src</descriptorRef>
        </descriptorRefs>
    </configuration>
    <executions>
        <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>

It's probably a good idea to spend some time with the usage page [2] at least so you can't get this working the way you want it to.  The example above used the predefined src descriptor [3].

-Jim


[1] http://maven.apache.org/plugins/maven-assembly-plugin/
[2] http://maven.apache.org/plugins/maven-assembly-plugin/usage.html
[3] http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#src





-----Original Message-----
From: Madhu [mailto:bm.madhavi@gmail.com]
Sent: Wednesday, September 12, 2012 8:06 AM
To: users@maven.apache.org
Subject: Re: Re: How to zip the source code separately using Maven

I wanted only source code but it tries to combine the whole project content
with Jar and etc. I am getting the following error.

 Failed to execute goal
org.apache.maven.plugins:maven-assembly-plugin:2.3:assembly (make-assembly)
on project ABCServices: Error reading assemblies: No assembly descriptors
found. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e
switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please
read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException





-----
Madhu
--
View this message in context: http://maven.40175.n5.nabble.com/How-to-zip-the-source-code-separately-using-Maven-tp5721257p5721509.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


NOTICE: All information in and attached to this email may be proprietary, confidential, privileged and otherwise protected from improper or erroneous disclosure. If you are not the sender's intended recipient, you are not authorized to intercept, read, print, retain, copy, forward, or disseminate this message.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Re: Re: How to zip the source code separately using Maven

Posted by Thorsten Heit <th...@vkb.de>.
Hi,

> I wanted only source code but it tries to combine the whole project 
content
> with Jar and etc. I am getting the following error.
> 
>  Failed to execute goal
> org.apache.maven.plugins:maven-assembly-plugin:2.3:assembly 
(make-assembly)
> on project ABCServices: Error reading assemblies: No assembly 
descriptors
> found. -> [Help 1]
> [ERROR] 
> [ERROR] To see the full stack trace of the errors, re-run Maven with the 
-e
> switch.
> [ERROR] Re-run Maven using the -X switch to enable full debug logging.
> [ERROR] 
> [ERROR] For more information about the errors and possible solutions, 
please
> read the following articles:
> [ERROR] [Help 1]
> http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

You haven't said what you have done so far. Have you really read the link 
you were given? They contain several examples how to use these plugins.

Apart from that:
If you don't give any information about what you have done, how your 
project is structured, how your pom.xml looks like, how you trigger Maven, 
what you did to see the above mentioned error etc., nobody is able and 
possibly even willing to help you resolve your problems...


HTH

Thorsten

Re: Re: How to zip the source code separately using Maven

Posted by Madhu <bm...@gmail.com>.
I wanted only source code but it tries to combine the whole project content
with Jar and etc. I am getting the following error.

 Failed to execute goal
org.apache.maven.plugins:maven-assembly-plugin:2.3:assembly (make-assembly)
on project ABCServices: Error reading assemblies: No assembly descriptors
found. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e
switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please
read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException





-----
Madhu
--
View this message in context: http://maven.40175.n5.nabble.com/How-to-zip-the-source-code-separately-using-Maven-tp5721257p5721509.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Re: How to zip the source code separately using Maven

Posted by Thorsten Heit <th...@vkb.de>.
Hi,

> can somebody give me the sample code...

Please read the links you were given.
What have you tried so far? And what problems do you still have?


Regards

Thorsten

Re: How to zip the source code separately using Maven

Posted by Madhu <bm...@gmail.com>.
can somebody give me the sample code...



-----
Madhu
--
View this message in context: http://maven.40175.n5.nabble.com/How-to-zip-the-source-code-separately-using-Maven-tp5721257p5721311.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Antwort: How to zip the source code separately using Maven

Posted by Thorsten Heit <th...@vkb.de>.
Hi,

> Please tell me how we can add a task in POM.xml file to zip the source 
code
> separately while build the application. I want both .war file and .zip 
files
> independent of each other. 

https://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html
https://maven.apache.org/plugins/maven-source-plugin/


?

HTH

Thorsten