jueves, abril 05, 2012
Hey! Teachers! Leave them kids alone! All in all it's just another brick in the wall. All in all you're just another brick in the wall. (Another Brick In The Wall - Pink Floyd)
domingo, marzo 18, 2012
Moi je pense à l'enfant, Entouré de soldats, Moi je pense à l'enfant, Qui demande pourquoi (Non Non Rien N'a Changé - Les Poppys)
Last year I went to Devoxx as speaker but also I attended Patrycja Wegrzynowicz conference about Hibernate Anti-Patterns. In that presentation Patrycja shows us an anti-pattern that shocks me because it proved to expect the unexpected.
In previous classes, we should pay attention in three important points:
- we are annotating at property level instead of field level.
- @OneToMany and @ManyToOne uses default options (apart from cascade definition)
- officers getter on Starship class returns an immutable list.
At this point let's examine why these SQL queries are executed:
First eight inserts are unavoidable; they are required by inserting data into database.
Next seven inserts are required because we have annotated getOfficers property without mappedBy attribute. If we look closely at Hibernate documentation, it points us that “Without describing any physical mapping, a unidirectional one to many with join table is used.”
Next group of queries are even stranger, the first select statement is to find Starship by id, but what are these deletes and inserts of data that we have already created?
During commit Hibernate validates whether collection properties are dirty by comparing object references. When a collection is marked as dirty, Hibernate needs to re-create whole collection, even containing the same objects. In our case when we are getting officers we are returning a different collection instance, concretely an unmodifiable list, so Hibernate considers officers collection as dirty.
Because a join table is used, Starship_Officer table should be re-created, deleting previous inserted tuples and inserting the new ones (although they have the same values).
Let's try to fix this problem. We start by mapping a bidirectional one-to-many association, with many-to-one side as owning side.
Although we have reduced the number of SQL statements, from 25 to 10, we still have an unnecessary query, the ones just in commit section of second transaction. Why if officers are lazy by default (JPA specification), and we are not getting officers in transaction, Hibernate executes a select on Officers table? By the same reason as previously configuration, returned collection has different Java identifier, so Hibernate marks it as newly instantiated collection, but now obviously join table operations are no longer required. We have reduced the number of queries but we still have a performance problem. It is likely that we'll need some other solution, and the solution is not the most obvious one, we are not going to return collection objects returned by Hibernate, we might expand on this later, but we are going to change annotations location.
What we are going to do is to change mapping location from property approach to use field mapping. Simply we are going to move all annotations to class attributes rather than on getters.
Why using property mapping Hibernate runs queries during commit and using field mapping are not executed? When a Transaction is committed, Hibernate execute a flush to synchronize the underlying persistent store with persistable state held in memory. When property mapping is used, Hibernate calls getter/setter methods to synchronize data, and in case of getOfficers method, it returns a dirty collection (because of unmodifiableList call). On the other side when we are using field mapping, Hibernate gets directly the field, so collection is not considered dirty and no re-creation is required.
But we have not finished yet, I suppose you are wondering why we have not removed Collections.unmodifiableList from getter, returning Hibernate collection? Yes I agree with you that we finished quickly, and change would look like @OneToMany(cascade={CascadeType.ALL}) public List<Officer> getOfficers() {officers;} but returning original collection ends up with an encapsulation problem, in fact we are broken encapsulation!. We could add to mutable list anything we like; we could apply uncontrolled changes to the internal state of an object.
Using an unmodifiableList is an approach to use to avoid breaking encapsulation, but of course we could have used different accessors for public access and hibernate access, and not calling Collections.unmodifiableList method.
Considering what we have seen today, I suggest you to use always field annotations instead of property mapping, we are going to save from a plenty of surprises.
Hope you have found this post useful.
Screencast of example shown here:
Download code
Music: http://www.youtube.com/watch?v=H14VIsnr6aA
Etiquetas: dirty collection, encapsulation, hibernate, hibernate performance, java, onetomany, orm, sql, unmodifiableList
martes, marzo 06, 2012
Keep 'em laughing as you go, Just remember that the last laugh is on you, And always look on the bright side of life..., Always look on the right side of life... (Always Look on the Bright Side of Life - Mony Python)
- Repeatable.
- Consistent.
- In Memory.
- Fast.
- Self-validating.
- Testing single concept
- Creating a partial mock.
- Using fault injection.
Next class, would be the one that sends data through socket but will not be shown, because it is not necessary for this example.
And finally the backup service responsible of managing described behavior.
Byteman is a tool which allows you to insert/modify code into an application at runtime. These modifications can be used to inject code on your compiled application causing unusual or unexpected operations (aka Fault Injection).
See that BMUnitRunner (a special jUnit runner that comes with Byteman) is required.
First test called aFileWithContentShouldBeCreated is a standard test that writes Hello world into backup file.
But the second one dataShouldBeSentToServerInCaseOfIOException, has BMRule annotation which will contain when, where and what code should be injected. First parameter is the name of the rule, in this case a description of what we are going to do (throwing an IOException). Next attributes, targetClass and targetMethod configure when injected code should be added. In this case when FileUtils.createFileWithContent method is called. Next attribute targetLocation is location where code is inserted, and in our case is where createFileWithContent method calls write method of BufferedWriter. And finally what to do that obviously in this test is throwing an IOException.
So now you can go to your IDE and run them, and all tests should pass, but if you run through Maven using Surefire plugin, test will not work. To use Byteman with Maven, Surefire plugin should be configured in a specific way.
First important thing is adding tools jar as dependency. This jar provides classes needed in order to dynamically install the Byteman agent.
In Surefire plugin configuration is important to set useManifestOnlyJar to false to ensure that the Byteman jar appears in the classpath of the test JVM. Also see that we are defining empty environment variables (BYTEMAN_HOME and org.jboss.byteman.home). This is because when it loads the agent the BMUnit package will use environment variable BYTEMAN_HOME or System property org.jboss.byteman.home to locate byteman.jar but only if it is a non-empty string. Otherwise it scans the classpath to locate the jar. Because we want to ensure that jar added on dependency section is used, we are overriding any other configuration present on system.
And now you can run mvn clean test and two tests are successful too.
See that Byteman opens a new world into how we are writing our integration tests, now we can test in an easy way unusual exceptions like Communications Error, Input/Output Exceptions or Out Of Memory Error. Moreover because we are not mocking FileUtils, we are executing real code; for example in our second test, we are running a few lines of FileUtils object until write method is reached. If we had mocked-up FileUtils class, these lines would not be executed. Thanks of using fault injection our code coverage is improved.
Byteman is more than what I have shown you, it also has built-ins designed for testing in multithreaded environments, parameter binding, and an amount of location specifiers, to cite a few things.
I wish you have found this post useful and help you testing rare conditions of your classes.
Download Code
Etiquetas: byteman, code coverage, fault injection, integration tests, junit, maven, surefire plugin, test, testing unusual exceptions
lunes, febrero 27, 2012
For everything I long to do, No matter when or where or who, Has one thing in common too, It's a, it's a, it's a, it's a sin (It's a Sin - Pet Shop Boys)-
Etiquetas: dependencyManagement, eclispe, m2eclipse, maven, maven multimodule, maven multiproject, maven screencast
jueves, febrero 23, 2012
If there ain't all that much to lug around, Better run like hell when you hit the ground. When the morning comes. (This Too Shall Pass - Ok Go)
From my point of view, Javascript has become so popular thanks to jQuery, which has greatly simplified the way we wrote Javascript code. And you can also test jQuery applications with Jasmine using Jasmine-jQuery module, which provides two extensions for testing:
- set of matchers for jQuery framework like toBeChecked(), toBeVisible(), toHaveClass(), ...
- an API for handling HTML fixtures which enable you to load HTML code to be used by tests.
So I suppose you want to start coding. We are going to create a simple jQuery plugin in standard Maven war layout, where Javascript files go to src/webapp/js, css at src/webapp/css and Javascript tests at src/test/javascript. Of course this directory structure is fully configurable, for example if your project was a Javascript project, src/main/javascript would be better place. Next image shows you directory layout.
Now it is time for testing. Yes I know write tests first, and then business code, but I thought it will be more appropriate to show first the code to test.
So let's write Jasmine test file.
First thing to do is add a description (behaviour) of what we are going to test with describe function. Then with beforeEach, we are defining what function we want to execute before each test execution (like @Before JUnit annotation). In this case we are setting our fixture to test plugin code, you can set an html file as template or you can define html inline as done here.
And finally the test, written inside it function. Our test should validate that div element with id content, defined in fixture, should contain class attribute with value red after running redColor function. See how we are using jasmine-query toHaveClass matcher.
All these parameters will change depending on your project but in case you are creating a Maven war project, this layout is enough.
And now you can run Maven by typing:
mvn clean test
And next console output should be printed:
Music: http://www.youtube.com/watch?feature=player_embedded&v=qybUFnY7Y8w#!
jueves, febrero 16, 2012
Party rock is in the house tonight, Everybody just have a good time, And we gon' make you loose your mind, Everybody just have a good good good time. (Party Rock Anthem - LMFAO)
- Using webrick (not recommended in production environments).
- Run with mongrel and fastcgi.
- Using Passenger.
- Or package Redmine into war and deploy into Java container like Tomcat or Glassfish.
Redmine installation
Download Redmine 1.3 and install them on /usr/share directory:
cd /usr/share/redmine-1.3.0/config/
Installation comes with a database template configuration file, we are going to rename it and modify to suit our environment. Moreover Redmine contains different start up modes (production, development, test). In our case because we are configuring a production environment, only production section will be touched.
mysql -u root -p
Now it is time to initialize Redmine
Next step is required because we are installing Redmine 1.3, in next versions of Redmine 1.4 and beyond will not be necessary. Open config/environment.rb and comment next like:
config.gem 'rubytree', :lib => 'tree'
And then create database schema and fill them with default data with next scripts.
Now we are going to test that Redmine is correctly configured. For this purpose we are going to use webrick.
and open a browser at http://localhost:3000 to start checking installation.
Redmine web page will be shown, you can login with username and password admin/admin
At this point we have Redmine correctly installed.
I wish you have found useful.
martes, enero 31, 2012
Giuro per sempre a te, Di viver, morire per te, Se tu sarai con me lo so, Dea Roma, vincerò!
- The first level cache is the session cache. Objects are cached within the current session and they are only alive until the session is closed.
- The second level cache exists as long as the session factory is alive. Keep in mind that in case of Hibernate, second level cache is not a tree of objects; object instances are not cached, instead it stores attribute values.
To sum up, and as a conceptual schema, given next query: "from Country where population > :number", after first execution, Hibernate caches would contain next fictional values (note that number parameter is set to 1000):
L2 Cache
[
id:1, {name='Spain', population=1000, ....}
id:2, {name='Germany', population=2000,...}
....
]
QueryCache
[{from Country where population > :number, 1000}, {id:2}]
First of all you must decide what cache provider you are going to use. For this example Ehcache is chosen, but refer to Hibernate documentation for complete list of all supported providers.
To configure second level cache, set next Hibernate properties:
hibernate.cache.provider_class = org.hibernate.cache.EhCacheProvider
hibernate.cache.use_structured_entries = true
hibernate.cache.use_second_level_cache = true
And if you are using annotation approach, annotate cachable entities with:
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
See that in this case cache concurrency strategy is NONSTRICT_READ_WRITE, but depending on cache provider, other strategies can be followed like TRANSACTIONAL, READ_ONLY, ... take a look at cache section of Hibernate documentation to chose the one that fits better with your requirements.
And finally add Ehcache dependencies:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>3.6.0.Final</version>
</dependency>
Now second level cache is configured, but not query cache; anyway we are not far from our goal.
Set hibernate.cache.use_query_cache property to true.
And for each cachable query, we must call setCachable method during query creation:
List<Country> list = session.createQuery("from Country where population > 1000").setCacheable(true).list();
To make example more practical I have uploaded a full query cache example with Spring Framework. To see clearly that query cache works I have used one public database hosted in ensembl.org. The Ensembl project produces genome databases for vertebrates and other eukaryotic species, and makes this information freely available online. In this example query to dna table is cached.
First of all Hibernate configuration:
It is a simple Hibernate configuration, using properties previously explained to configure second level cache.
Entity class is an entity that represents a sequence of DNA.
We can see that we are returning first fifty dna sequences, and if you execute it, you will see that elapsed time between creation of query and commiting transaction is printed. As you can suppose only first iteration takes about 5 seconds to get all data, but the other ones only milliseconds.
The foreach line just before query iteration will print object identifier through console. If you look carefully none of these identifiers will be repeated during all execution. This fact just goes to show you that Hibernate cache does not save objects but properties values, and the object itself is created each time.
Last note, remember that Hibernate does not cache associations by default.
Now after writing a query, think if it will contain static data and if it will be executed often. If it is the case, query cache is your friend to make Hibernate applications run faster.
Download Code
Music: http://www.youtube.com/watch?v=fw1VJSU92mw
viernes, enero 27, 2012
Once upon a time and long ago, I heard someone singing, Soft and low (Distant Melody - Peter Pan)
- Thymeleaf: http://www.thymeleaf.org
- HTML5 + CSS 3 Form Using Thymeleaf + Spring MVC tutorial: http://www.lordofthejars.com/2011/11/your-big-daddys-got-no-place-to-stay.html
- Spring Framework: 3.0.5
- Thymeleaf: 1.1.2
- Hibernate-Validator: 4.1.0
- Slf4j: 1.5.10
- Servlet-api: 2.5
- JUnit: 4.9
For any question regarding of how to use this archetype or any issue/improvement, do not hesitate to contact me or open a new issue on github.
I wish this archetype can help you to start a new project using Thymeleaf template engine.
Music: http://www.youtube.com/watch?v=7EaGSocm5dc
lunes, enero 23, 2012
Nevermind, I'll find someone like you, I wish nothing but the best, for you too, Don't forget me, I beg, I remember you said:-, Sometimes it lasts in love but sometimes it hurts instead (Someone Like You - Adele))
Music: http://www.youtube.com/watch?v=hLQl3WQQoQ0&ob=av3e
Etiquetas: 100k visits, dzone, javacodegeeks, lordofthejars.com, springsource, theserverside, twitter
lunes, enero 02, 2012
Sábado na balada, A galera começou a dançar, E passou a menina mais linda, Tomei coragem e comecei a falar (Ai se eu te pego - Michel Teló)
- define models in Javascript.
- deal with Collections using a rich API.
- define Views with declarative event handling and template support.
- interface to Rest architectures.
Then download backbone.js and its dependencies and copy to webapp/resources/js directory:
Open servlet-context.xml and add root and js folder as static resource.
Models in Backbone has a particularity that make them useful, they are an implementation of Active Record pattern, so when you are creating a model you will have CRUD operations against a Rest-WebService. So for example when you call save method of your model, Backbone converts that model to JSON and sends the result to server as HTTP POST (if model has no id), or HTTP PUT (update). Other available operations are fetch (load) and destroy (delete).
See how in this case we have created a Character model setting urlRoot property. This property is used to build endpoint to ResetServer. As long as the endpoint returns JSON for a single character, properties will be merged into model.
And the same applies to Collections. When you call fetch method of characters var, all characters returned by calling GET .../characters will be stored into.
See how easy is implementing a Rest Client using Backbone. And I suppose you are wondering where are attributes' definition? Don't worry, with Backbone is not necessary to explicitly define at definition time.
Now it is time for Views. As I cited at the begin of post, Backbone has template support. For this example two templates are going to be used, one for filling a new character and another for showing character information.
To define a template you must use <script> tag with text/template type instead of text/javascript and an id. The structure is similar to JSP (embedded HTML code, <%= %> for printing variables and <% %> for logical structures).
Next step is creating Views.
For this example we are going to create three views, one for each template, and one that will be a composition of both.
Let's start with View responsible of showing information of one character.
Next important line is number 6. There we are defining a function that will be invoked each time we want to render a view (one time per character). See how we are passing a model object (trust me it is not defined yet, but will be there), to template. To fill template variables, template engine requires data in JSON format, and Backbone model has a toJSON method. And finally generated html code is saved into el attribute.
Next View is responsible of showing character form, and deal with submit action.
createOnEnter method does three things:
- gets values from template form.
- instantiates CharacterModel class. See that this is the place where model attributes are defined.
- calls save method. This method sends object data to defined endpoint at server side. Because this operation is asynchronous, a callback is registered, so when a success is received, character is added into characters list.
Next line is used to populate data to Collection. When fetch is called an HTTP GET to defined endpoint is sent, data is retrieved and Collection's add method is called for each result.
addCharacter function is responsible of creating one View for each character. There is not much secret, we are creating a CharacterView, and appending the result of calling its render method to html element with character-list id.
And finally render function that is responsible of rendering CharacterFormView.
See that page is only loaded first time we access it, subsequent updates are done by DOM manipulations.
To finish I embedded all html file explained here so you can see a global overview of all pieces used. Also feel free to download all Eclipse project. I wish you find this post useful.
Download Code
Etiquetas: asynchronous UI, Backbone, javascript, javascript templates, jquery, rest, restclient, restful web services, spring MVC res
miércoles, diciembre 14, 2011
Elle ne me quitte pas d'un pas, fidèle comme une ombre. Elle m'a suivi ça et là, aux quatres coins du monde. Non, je ne suis jamais seul avec ma solitude (Ma Solitude - Georges Moustaki)
Also you can visit two entries of my blog where I talk about same theme.
Links of technologies I talked about:
- Jawr: http://jawr.java.net/
- Wro4j: http://code.google.com/p/wro4j/
Music: http://www.youtube.com/watch?v=qSZKO5K2eTE
Etiquetas: aggregation, css, css minification, devoxx, html5, javascript, jawr, maven, minification, minification javascript
viernes, diciembre 09, 2011
Far away, long ago, glowing dim as an Ember, Things my heart use to know, things it yearns to remember (Once upon a December - Anastasia)
- Multiple developers developing an application with continuous integration.
- Multiple clients each one with different versions of production code.
- Automatic migration: Flyway will update from any version to the latest version of schema. Flyway can be executed as Command-line (can be used with non JVM environments), Ant script, Maven script (to update integration/acceptance test environments) or within application (when application is starting up).
- Convention over configuration: Flyway comes with default configuration so no configuration is required to start using.
- Plain SQL scripts or Java classes: To execute updates, you can use plain SQL files or Java classes for advanced migrations.
- Highly reliable: safe for cluster environments.
- Schema clean: Flyway can clean existing schema, so empty installation is produced.
- Plain SQL files go to db/migration directory inside src/main/resources structure.
- Java classes go to db.migration package.
- Files (SQL and Java) must follow next name convention: V<version>[__description]. Where each version number is separated by dots (.) or underscore (_) and if description is provided, two underscores must proceed. A valid example is V_1_1_0__Update.sql
Imagine we are going to develop a small application using Spring Framework that will allow us registering authors and which books they have written.
First version will contain two tables, Author and Book related with one to many relationship.
First step is registering Flyway into Spring Application Context. Flyway class is the main class and requires a javax.sql.DataSource instance. migrate method is responsible to start migration process.
See that there is no secret. Only be careful because if your project uses JPA or ORM frameworks for persistence, you should configure them to avoid auto creation of tables, because now Flyway is responsible of managing database structure. And because of that, creation of SessionFactory (in case of Hibernate) or EntityManagerFactoryBean( in case of JPA), should depends on Flyway bean.
And now let's write first version of SQL migration. Create db/migration directory into src/main/resources and create a file called V1__Initial_version.sql with next content:
This script creates Author and Book tables with their respective attributes.
And if you run next JUnit both tables are created into database.
Take a look at your console and next log message has appeared:
10:33:49,512 INFO glecode.flyway.core.migration.DbMigrator: 119 - Current schema version: null
10:33:49,516 INFO glecode.flyway.core.migration.DbMigrator: 206 - Migrating to version 1
10:33:49,577 INFO glecode.flyway.core.migration.DbMigrator: 188 - Successfully applied 1 migration (execution time 00:00.085s).
And if you open your database:
Note that Flyway has created a table to annotate all updates that have been executed (SCHEMA_VERSION) and last insert is a "Flyway insert" marking which is the current version.
Then your first version of application is distributed across the world.
And you can start to develop version 1.1.0 of application. For next release, Address table must be added with a relationship to Author.
As done before, create a new SQL file V1_1_0__AddressTable.sql into db/migration folder.
And run next unit test:
your database will be upgraded to version 1.1.0. Also take a look at log messages and database:
11:27:30,149 INFO glecode.flyway.core.migration.DbMigrator: 119 - Current schema version: 1
11:27:30,152 INFO glecode.flyway.core.migration.DbMigrator: 206 - Migrating to version 1.1.0
11:27:30,191 INFO glecode.flyway.core.migration.DbMigrator: 188 - Successfully applied 1 migration (execution time 00:00.053s).
New table is created, and a new entry into SCHEMA_VERSION table is inserted marking that current database version is 1.1.0.
When your 1.1.0 application is distributed to your clients, Flyway will be the responsible of updating their databases without losing data.
Previously I have mentioned that Flyway also supports Java classes for advanced migrations. Let's see how.
Imagine that in your next release, authors can upload their personal photo, and you decide to store as blob attribute into Author table. The problem resides on already created authors because you should set some data into this attribute. Your marketing department decides that authors inserted prior to this version will contain a photo of Spock,
Next step is developing a Java Migration class. Create a new package db.migration on src/main/java. Notice that this class cannot be named V2_0_0_AddAvatar.java because Flyway will try to execute two different migrations with same version, and obviously Flyway will detect a conflict.
To avoid this conflict you can follow many different strategies, but in this case we are going to add a letter as version suffix, so class will be named V2_0_0_A__AddAvatar.java instead of V2_0_0__AddAvatar.java.
Before run previous unit test, open testdb.script file and add next line just under SET SCHEMA PUBLIC command.
INSERT INTO AUTHOR(ID, FIRSTNAME, LASTNAME, BIRTHDATE) VALUES(1, 'Alex', 'Soto', null);
And running unit test, next lines are logged:
20:21:18,032 INFO glecode.flyway.core.migration.DbMigrator: 119 - Current schema version: 1.1.0
20:21:18,035 INFO glecode.flyway.core.migration.DbMigrator: 206 - Migrating to version 2.0.0
20:21:18,088 INFO glecode.flyway.core.migration.DbMigrator: 206 - Migrating to version 2.0.0.A
20:21:18,114 INFO glecode.flyway.core.migration.DbMigrator: 190 - Successfully applied 2 migrations (execution time 00:00.094s).
And if you open updated database, next lines are added:
See how all previous authors have avatar column with data.
Note that now you have not to worry about database migrations, your application is packaged and delivered to all your clients regardless of the version they had installed; Flyway will execute only required migration files depending on installed version.
I wish Flyway will help you make better life as developer.
Music: http://www.youtube.com/watch?v=oyUBdLm3s9U
Etiquetas: continuous integration, database, database migration, flyway, flyway-maven-plugin, maven
jueves, diciembre 01, 2011
All my scientists are working on a deadline, So my psychologist is working day and nighttime, They say they know what's best for me, But they don't know what they're doing (Atomic Garden - Bad Religion)
After template project is created and all desired files are added, you should have a directory layout like:
My personal advice is that if you are thinking about distributing this archetype with community (not only for your company), remove all IDE specific files.
Now you have your project created and ready to be packaged as archetype. Execute next command on root of your project.
mvn archetype:create-from-project
Now project is inside archetype-resources directory. This directory contains all files that will be added in generated project.
At first sight, not much differences between original project and "template" project, it seems that only three files has been added archetype-metadata.xml, archetype.properties and goal.txt, but shortly you will see that original project content has been modified too.
Before continuing see that in project exists two poms, one pom that is in root directory, that will be called archetype pom, because it contains all archetype configuration, and another one into archetype-resources, called template pom, because it will be the pom used in generated project.
Next step is isolate archetype project into separate folder, so can be dealt as alone project.
mv target/generated-sources/archetype ../spring-mvc-archetype
Following step is adding a name to generated archetype, so open archetype pom and change <name> tag value to your archetype name, for example spring-mvc-archetype, and if you want artifactId and groupId too.
After this modification, open archetype-resources' pom, and see how <artifactId> or <groupId> values are surrounded with ${artifactId} or ${groupId}. When you are creating a new archetype, by default Maven will ask you to enter four parameters, groupId, artifactId, version and package. Entered values will be used to fill placeholders.
With default four parameters should be enough, but imagine you want that user provides more information, for example, war name. To get this, open archetype-metadata.xml file (src/main/resources/META-INF/maven) and add one required property, using <requiredProperties> tag.
archetype.properties located on test/resources/projects/basic with default value of new property.
Now you can install archetype into your local catalog and start generating standardized projects.
mvn clean installAnd your artifact is ready to be used. Try next command or if you have installed m2Eclipse plugin open Eclipse and try your new archetype:
mvn archetype:generate -DarchetypeCatalog=localA list of all installed archetypes is shown. Choose previously created and fill up all required properties, and your new project is built and configured. You can start coding with same libraries that your workmates use and same style rules.
In this post a simple example has been provided, but think about all kind of elements that you copy and paste from one project to another like SCM connection, surefire plugin configuration, release plugin tag name, to cite a few, and how you can integrate them into your archetype.
I wish you have found this post interesting.















