https://github.com/townsfolk/gradle-templates
After much reading in forums, gradle's jira, and githubs, it seems the above plugin is the popular choice for getting maven archetype-like functionality in Gradle.
It comes with multiple templates to choose from, but how do I make my own?
Is there a guide or something that can kick start me into making my own template?
I have a setup I made to generate a new application with all the boiler plate pieces my company requires. I was able to generate this from an existing project using maven archetypes. I want to accomplish the same in Gradle so I can also take advantage of the ability to run groovy scripts when the generation occurs.
So far it looks like the only way to do this is to fork that project and make my own plugin with added template files and such.
Know this is a old question, but there is a wiki page on how to create your own templates:
https://github.com/townsfolk/gradle-templates/wiki/Template-Customization
Related
I'm new to Gradle and I want to ask if Gradle can implement this kind of project structure
Yes it can, and it is called multi-project builds. For information on it, take a look here in the Gradle user guide.
If you are completely new to Gradle, you may want to follow a guide such as this one for creating the basic structure.
I am willing to create an archetype which will be useful to create a lot of projects sharing the same architecture. I followed the maven guide and read some bloggers guides but even with these informations I am struggling.
I have some constraints for my projects :
All the project code is in a package which must be something like com.ei.app.project (app and project are vars I would like to set during the project generation)
I have dependencies I would like to be present in my POM when the project is generated
I have some scripts file with data (paths, app name...) and I would like to set them according to the project parameters, and if it is possible add additional parameters.
We don't use the official maven repo but set up another online repo. We have a strict security policy an whenever we have to add a lib into the repo it takes a lot of time for verifications.
How can I achieve this ? I tried several solutions but encountered a lot of errors. If you have a complete step-by-step guide in english or french that would be fantastic, but I would also like to understand how it works.
Many thanks for your help
Let me answer parts of your question.
From an example project, you can create an archetype by using archetype:create-from-project (https://maven.apache.org/archetype/maven-archetype-plugin/create-from-project-mojo.html).
You can supply a property file that will be used to replace actual values (like 1.0.0-SNAPSHOT) with references (like $version). All filtered files will be treated as velocity templates so that you can use $-type replacement.
Your repository restriction may be problem because you probably need dozens of artifacts to make the archetype plugin run.
I finally created a "base" project with all I need inside (libraries, main Vert.x class...), and developed a script to replace a template value (i.e __projectName__ ) in dir / file names and inside configuration / pom.
It's close enough to what we need and provide a cool replacement tool for my company, which will be used for multiple purposes.
We are using the latest version of Jenkins CI and we have a large number of projects, which have Maven dependencies on other projects. We also are using Jenkins views to group associated projects together.
I would like to be able to generate a graphical representation of the project hierarchy within a view. I am aware that if I select a project that I can see the upstream projects, but going through approximately 40 projects, writing this down and compiling it into a tree would be tedious, time-consuming and error-prone.
Does anyone know of a technique or plugin for Jenkins that could achieve this? Ideally it would work against all the projects within a view.
I would prefer an automated technique rather than performing it manually, since this process would need to be run periodically (say once a month) for a management report.
Update
Having investigated this question, I am not averse to writing a script to query the Jenkins API to get the JSON or XML for the projects within a view and then asking each for its upstream projects. But I'd rather save myself some work and using someone else's tool :)
You can use Maven to generate the dependencies for each project (http://maven.apache.org/plugins/maven-dependency-plugin/tree-mojo.html).
It won't give you a dependency tree for all your Jenkins projects though. Maybe you could pull from all maven outputs and create your own? Or maybe (not really) create a super project in which all modules are your existing projects (again, not really).
There is a Downstream Buildview plugin. It's per job, and it displays job names, but if you job names are named after maven modules, it shouldn't be an issue.
I´ve been reading lot about, but since there are several web frameworks that uses Maven for the project, I got confused, so I´m not entirely sure if Maven is an archetype that defines an schema to start developing apps by following good practices, or is just some piece of sdk that converts my code to bytecode. Thanks in advance to anyone who can drag me out of my confusion and gave me the required info. BTW is that rigth to say an archetype is a directory structure?
I am not sure if you are reading enough about maven, Maven is a build system which can help you build your application, manage your dependencies, run your tests, create reports and many other things.
First link in google result is http://maven.apache.org/
Apache Maven is a software project management and comprehension tool.
Based on the concept of a project object model (POM), Maven can manage
a project's build, reporting and documentation from a central piece of
information.
Each application has many dependencies and many small tasks that needs to be done before you can run your application, developers define them in a file called POM and that will be a instruction for Maven to build the application. Maven can do pretty much everything other than writing your code. In that sense it is like Genie in the story of Aladdin, you wish for something it will bring it for you.
There is a Grails maven plugin that can populate Grails project with the same convention that Grails uses. It can work with Grails to execute your commands and many other. More importantly it will manage your dependencies.
I am working on a project and using Maven to build it. The project is a quite big Java web application and it is supposed to work with both Mysql and Oracle databases.
The problem is that there are some specific annotations related to either of the two databases in the source code, plus some other differences, so that I am forced to manually comment/uncomment part of the code before building the application for one of the two databases.
Basically what I would like to achieve is to have my build script, maybe via a Maven profile, to automatically switch the source classes before building depending on the database I want my war to work against.
Putting it simply, the idea is to have MyClass.oracle and MyClass.mysql, and depending on my build profile I should move one of the two in the source dir, rename it MyClass and build. This should be done for some packages, classes, and also configuration files.
Is there any way I can achieve it via "pure" Maven? The only solution I came across till now is to use an antrun plugin and reference an Ant build.xml inside of it.
Thank you,
Mattia
A pure maven solution would be to develop your own maven plugin. Depending on your requirements this can be an overkill, however it is not hard at all, you can see how to achieve this here.
This is a limitation of Maven. One of Maven's purposes is to not have a build script. You should simply use the plugins as available, and setup your project the right way, and magically, everything will build!
There is one solution: Use Ant. Well, not to redo your whole project with Ant, but with the antrun plugin, you can run a few Ant tasks at various phases of your Maven build life cycle.
It's been a long, long time since I've used this, so I am not going to try to write a test pom.xml, but I don't remember it being very difficult to use.
Of course, the correct Maven solution is to divide your project up into "common core" code, and then a separate Oracle and MySql client that uses the "common core". By the way, I hope you're not patching source code. Instead, you're using a properties file to do this for you.