2

I have a small Maven project whose only purpose is to generate a single text file. It reads some input and generates an SQL script. I want to keep that SQL script as the only artifact produced by the Maven project.

Using the maven-assembly-plugin, the project is now producing a zip file containing the SQL script. Ideally, I would like to keep only the script itself as the artifact instead of having to wrap it inside a zip file. The zip archiving is unnecesssary in this case since there is only one small file. Plus I'd like to be able to open the SQL script in Jenkins from the browser.

Is there a way to produce a single, flat file as a Maven artifact, for example db-update-2.0.1.0-20130711.151737-24.sql?

Pat McG
  • 706
  • 5
  • 7
  • Can you elaborate by maybe giving an example? How is the SQL script generated? – Behe Jul 11 '13 at 21:27
  • The project contains a Java class which reads a .properties file and then generates the SQL text based on the values in the .properties file. The generated SQL text is then saved to a file, and that file is what I want to use as the artifact. – Pat McG Jul 12 '13 at 03:43
  • I actually have this working with an Ant build now. Maybe Maven is overkill for something simple like this? – Pat McG Jul 12 '13 at 03:45
  • Maven does simple standard things very very well. When you deviate from the norm, you need more understanding of how the tool works. ANT on the other hand is a toolbox containing everything you need to do everything yourself. I would accept the answer below. It explains how your question is solved using Maven. – Mark O'Connor Jul 12 '13 at 07:28
  • See an answer of doing it using command line: http://stackoverflow.com/a/31809260/435605. – AlikElzin-kilaka Aug 05 '15 at 06:35

1 Answers1

3

If you want this to be the main-artifact, you need to have a packaging type for sql. That would mean defining a lifecycle for this packaging type, etc. so probably a bit too much for 1 simple file. The simple solution would be to use packaging type 'pom' and use the attach-artifact goal to attach it. And yes, that means you'll have to specify a classifier. This guide explains how to configure your pom.xml.

Saikat
  • 14,222
  • 20
  • 104
  • 125
Robert Scholte
  • 11,889
  • 2
  • 35
  • 44
  • Thanks for the useful info. I ended up going with Ant for this particular purpose, but the info above seemed to be just what I needed for Maven. – Pat McG Jul 12 '13 at 14:16