📜 ⬆️ ⬇️

Coffee, tobacco and bootstrap in 5 seconds

Omitting cunning in the title, it will be about my fresh open-source initiative, which is shown to be used inside and outwardly to all Java programmers.

Meet Tobacco Bootstrap or just later Tobacco, who collected all the best that I saw in the world of web projects in one archetype for Maven.

UPD: Tobacco has been updated to 1.0.2 with Twitter Bootstrap 2.2.2 inside, and in addition this release will already go to the central repository, that is, the installation is no longer needed

Why and why


I think everyone is familiar with the feeling of despondency when starting a new Java project. You catch fire with an interesting idea, open your favorite Idea (sorry for the pun) and realize that you have to set up the project properly, before everything even starts, and then deflate half a dozen JS libraries and paint some kind of CSS before it looks better than Yahoo in the 98th year. Well, if you manage to do all this tonight. Maybe I'm wrong about you, but this feeling of despondency haunts me regularly
')
To start the demo project from Tabaka. I hope to survive

This is not one-in-one start-up project - some where added visual comments, and also there is a demo page. So it is more clear and it is not necessary to remove garbage from a fresh project every time.

Of course whistles like Spring Roo or glamorous Play have long solved this problem. But somehow I didn’t have love with them. Sometimes I told myself - everything, I have to get used to magic - pumped out Roo, put it, started it and suddenly ran into bugs in Roo itself even before the introduction of commands in general. Well, I just did not give up that time, but then the situation was no better. Step to the left, step to the right of the tutorial - everything falls apart and I find myself on the Roo bugtracker, looking for solutions to problems that prevent me from doing what I would have done in 5-10 minutes (why would you need me then, Roo?) . Oh yeah, and the refusal of developers to generate JSP instead of JSPX just hit me. Roo is not for me :(

As for Play, I’m just not satisfied with its performance, maybe now things are better with it, but even if so, the whole Java world doesn’t live by it. Yes, and as it is not for me - to change the key libraries and compatibility with J2EE just to save on start. In the course of writing these lines, I thought that we should try it again!

There is a maven! There are archetypes in it! And donetchiki do not sleep ! And, once again licked Twitter Bootstrap, I amassed rage, brushed the dust from my knowledge of Maven and got down to business. What ultimately happened? As a result, javista and javiscans received a template for Twitter Bootstrap web cakes, which are cooked in 5 seconds.

Such a shaft, you say, and you will be right. But only in half - there are many archetypes of web applications, sharpened to a specific framework. Tobacco is also sharpened on Spring, but only because it is the mainstream for web applications (and in general I like it more than anyone else - for whom to do, if not for myself). The main focus of the archetype is not on the server-side, but on the client side of the application - to make the project a pleasant-looking and modern.

Server part


Inside the server-side, you will not find three levels, a customized database or security rules, only a configured context and a pair of controllers. Perhaps in future versions, I will do some commented out parts on this topic, but no more. The idea of ​​an archetype is to be unobtrusive, and not to require three levels from you, if you make a two-page application, does not require MySQL from you, if you want to try MongoDB, it does not force you to chew JSPX with your eyes (there is only the required minimum of pure JSP)

The project generated from Tobacco is immediately multi-modular. I didn’t see any particular flaws, except for a larger number of folders, but the area of ​​possible projects is no longer limited to the Web alone.

But on the client side you get everything you need, and even a little more!

Client part


Inside - the latest versions of Twitter Bootstrap, jQuery, Underscore.js and Bootstrap.js, as well as Modernizr and Normalize.css. The template code itself and unusual files at the root of the project are from the H5BP project, where the guys were bothering to make a quality template for HTML5.

In addition to TB, the commented CSS from the H5BP project is left inside in case you don’t transfer pop music, but like hardcore hardcore

The popularity of javascript templates is also not avoided. Inside is the best of the best - dust.js , which the guys from LinkedIn recognized as the best of more than 20 others . Moreover, dust.js templates in Tobacco can be written like regular JSP pages - they will be automatically compiled and the client will receive ready-to-use compiled templates. It can be said not a raisin, but a whole Raisin Tobacco.

I also tried to collect what is always said in the farm, it is always useful - functions for working with URL, UUID, Base64, generating small random strings, pub / sub for events and so on.

All scripts are automatically compressed and aggregated in production mode. I have not talked about modes? Three profiles are set up in the project at once - production, development and debug!

Unfortunately, the fly in the ointment didn’t happen - the yui-compressor-plugin will require the latest version of Maven (at least 3.0.4), and the buildernumber-maven-plugin will require a customized version control system.

After the project is generated and before the first launch, you need to put your project in some repository. This is required for the buildnumber-maven-plugin plugin . The decision to include this plugin seems to be the only thing I regret. Not everyone needs it, but everyone will need to adjust the version control system. In the next version, it’s worth getting rid of it.

Yes, so far not a single block of code in the article :) I did not even say how to install, a scoundrel. This is because I will send everyone to read the README, which is at the root of the project , where the installation instructions are described in detail.

In general, I hope Tobacco will save more than one hour of life for each of us. Next in line is a breakthrough in Maven Central and Twitter Bootstrap update to version 2.2.2

Source: https://habr.com/ru/post/162029/


All Articles