Jadson Santos
22/10/15 Gradle 2 Gradle Gradle is an advanced build tool of general purpose base on Groovy
22/10/15 Gradle 3 Why use a build tool?
22/10/15 Gradle 4 Why do not use eclipse to build a system? You can not build automatically from everywhere with eclipse You will always need a person to build
22/10/15 Gradle 5 Make Makefile is used to compile, linking, assembly among other tasks such as cleaning up temporary files, executing commands, etc.
22/10/15 Gradle 6 Apache ANT The first widely build tool of the Java world Ant is extremely flexible and does not impose coding conventions or directory layouts to the Java projects
22/10/15 Gradle 7 Apache ANT Example
22/10/15 Gradle 8 Apache ANT Example
22/10/15 Gradle 9 Apache ANT Example
22/10/15 Gradle 10 Apache ANT Apache Ant cons Too flexible Write a lot of thing to do a simple build The projects have no a standard structure, everyone create your own structure
22/10/15 Gradle 11 Apache Maven Simple project setup that follows best practices - get a new project or module started in seconds Convention over Configuration Superior dependency management including automatic updating, dependency closures (also known as transitive dependencies)
22/10/15 Gradle 12 Apache Maven Project Structure
22/10/15 Gradle 13 Apache Maven Based on the concept of a Project Object Model (POM)
22/10/15 Gradle 14 Apache Maven Maven has a central repository http://mvnrepository.com/
22/10/15 Gradle 15 Apache Maven Apache Maven Central Repository
22/10/15 Gradle 16 Apache Maven Apache Maven Central Repository
22/10/15 Gradle 17 Apache Maven Apache Maven Central Repository 2º 1º Exist? 2º / 4º 3º Central Repository
22/10/15 Gradle 18 Apache Maven Apache Maven cons Too hard / rigid Use of XML in the build file Maven works great for 90% of the most common things, but complicates a lot for those 10% of specifics things of your project
22/10/15 Gradle 19 Apache Maven Apache Maven cons
22/10/15 Gradle 20 Why Gradle? Gradle combines good parts of both tools and builds on top of them with DSL and other improvements It has Ant s power and flexibility Maven s life-cycle and ease of use
22/10/15 Gradle 21 Why Gradle?
22/10/15 Gradle 22 Why Gradle?
22/10/15 Gradle 23 Why Gradle?
22/10/15 Gradle 24 Why Gradle? https://gradle.org/maven_vs_gradle/
22/10/15 Gradle 25 Who is using Gradle?
22/10/15 Who is using Gradle? Gradle 26
22/10/15 Gradle 27 Gradle Introduction The script of the Gradle is a groovy script with a DSL to facilitated the tasks necessary to build Instead with groovy language of fors and ifs, the Gradle DSL helps you
22/10/15 Gradle 28 DSL = Domain Specific Language Small languages to solve a very specific problem Example: SQL SQL is an easer way to recovery data, instead use generic languages: for(int i = 0 ; i < qtddiscente; i++){ } if(discentecollection[i].getmatricula() == 2013106430) discentes.add(new Object[].{discenteCollection[i].getId(), discentecollection[i].getmatricula(), discentecollection[i].getanoingresso()}); return discentes;
22/10/15 Gradle 29 Gradle DSL https://docs.gradle.org/current/dsl/
22/10/15 Gradle 30 Gradle Introduction Gradle is composed of two concepts: Projects and Tasks A Project may represent the creation of a jar or a deploy of an application on the server. Each project is composed of several Tasks Tasks represent some atomic job.
22/10/15 Gradle 31 Gradle Introduction Example of a gradle task
22/10/15 Gradle 32 Gradle Introduction Like ANT, it allows you to setup default tasks and dependencies between tasks.
22/10/15 Gradle 33 Gradle Introduction But will I have to go back to the ANT times and program every step of my build? No! Gradle supports the notion of plugins, like Maven
22/10/15 Gradle 34 Gradle Introduction Tasks of the Java Plugin
22/10/15 Gradle 35 Gradle Introduction Like Maven, Gradle uses Convention over Configuration Imagine what is the Gradle project Structure? The same of Maven J
22/10/15 Gradle 36 Gradle Introduction Dependency management is a critical feature of every build Transitive dependency management Support for non-managed dependencies Support for custom dependency definitions Full Compatibility with Maven and Ivy Integration with existing dependency management infrastructure
22/10/15 Gradle 37 Gradle in the SINFO Projects 8º 2º 3º 7º 5º / 9º 4º 1º Exist? 2º / 6º http://jenkins.info.ufrn.br/artifactory Maven Central Repository
22/10/15 Gradle 38 Gradle in practice Version of the System, at each build this value needs to be update
22/10/15 Gradle 39 Gradle in practice Information about the source code Group and Version of the artfact generated
22/10/15 Gradle 40 Gradle in practice Source Folders of your application
22/10/15 Gradle 41 Gradle in practice Maven Central Repository Others Repositories
22/10/15 Gradle 42 Gradle in practice Creating 4 own configurations Some configuration include the dependences of others No cache this dependences
22/10/15 Gradle 43 Gradle in practice Inside system dependences Outside system dependences Dependences Copied to deploy in JBOSS Dependences Can not be Copied to JBOSS
22/10/15 Gradle 44 Gradle in practice To generated an EAR from complex project structure, it was created some tasks Here we define the order how theses tasks will execute
22/10/15 Gradle 45 Gradle in practice Create the sigevento.war Copy to the EAR the dependences and META-INF directory
22/10/15 Gradle 46 Gradle in practice The power of Gradle make specific tasks that just exists in your systems
22/10/15 Gradle 47 Gradle in practice Configure the Eclipse class path. Configure Build Path any more!
22/10/15 Gradle 48 Gradle in practice Dependence of the Gradle script
22/10/15 Gradle 49 Gradle in practice Use the org.hidetake.ssh to make deploy of a system You can deploy in several serves Can execute something
22/10/15 Gradle 50 Gradle in practice Plugin the publish in the artifactory server Information of the JAR in the repository
22/10/15 Gradle 51 Gradle in practice Plugin to run tomcat embed in your application. Application Server any more! Dependences of embed tamcat
22/10/15 Gradle 52 Gradle in practice Integration of Gradle with Flyway Update database automatically
22/10/15 Gradle 53 Gradle Eclipse Plugin Windows -> Eclipse Market -> Gradle IDE pack
22/10/15 Gradle 54 Gradle Eclipse Plugin Executing Gradle in the Eclipse 1o Run As -> gradle build Gradle build
22/10/15 Gradle 55 Gradle Eclipse Plugin Executing Gradle in the Eclipse 2o Run As -> Gradle GUI -> Select the tasks
22/10/15 Gradle 56 Gradle Eclipse Plugin Executing Gradle in the Eclipse 3o Gradle -> Tasks Quick Launcher -> Type the tasks
22/10/15 Gradle 57 Gradle Eclipse Plugin Gradle dependences in the Eclipse
22/10/15 Gradle 58 Gradle Integration with Jenkins Jenkins is an award-winning, cross-platform, continuous integration and continuous delivery application that increases your productivity. Use Jenkins to build and test your software projects continuously making it easier for developers to integrate changes to the project
22/10/15 Gradle 59 Gradle Integration with Jenkins Jenkins basically schedule jobs (threads) to execute some task http://jenkins.info.ufrn.br/
22/10/15 Gradle 60 Gradle Integration with Jenkins
22/10/15 Gradle 61 Gradle Integration with Jenkins Projects that generated a JAR to be publish in artefactory
22/10/15 Gradle 62 Gradle Integration with Jenkins Projects that generated a EAR are deployed in JBOSS
22/10/15 Gradle 63 Gradle Integration with Jenkins Projects that generated a EAR are deployed in JBOSS
22/10/15 Gradle 64 Mudanças no Ambiente da SINFO Ambiente de Desenvolvimento Antigo Arquitetura SIGAA EntidadesComuns ServicoesIntegrados SIGRH SharedResources SIPAC LIBS JBOSS
22/10/15 Gradle 65 Mudanças no Ambiente da SINFO Ambiente de Desenvolvimento Antigo
22/10/15 Gradle 66 Mudanças no Ambiente da SINFO Ambiente de Produção Antigo SIGAA arq1.0.jar comum1.0.jar dto1.0.jar SIPAC arq2.0.jar comum2.0.jar dto2.0.jar SIGRH arq3.0.jar comum3.0.jar dto3.0.jar LIBS Hibernate.jar Asm.jar Jasper.jar *.jar JBOSS SharedResources
22/10/15 Gradle 67 Mudanças no Ambiente da SINFO Estrutura dos sistemas EAR SIGAA 3 JARS 1 WAR 1 META-INF
22/10/15 Gradle 68 Mudanças no Ambiente da SINFO Estrutura dos sistemas META-INF 1 META-INF 2
22/10/15 Gradle 69 Mudanças no Ambiente da SINFO META-INF 2 JARs da Arquitetura dentro do EAR *.class Outros Módulos
22/10/15 Gradle 70 Mudanças no Ambiente da SINFO Ambiente de Desenvolvimento Novo SIGAA lib *.jar SharedResources lib *.jar SIGRH lib *.jar SIPAC lib *.jar JBOSS
22/10/15 Gradle 71 Mudanças no Ambiente da SINFO Ambiente de Desenvolvimento Novo
22/10/15 Gradle 72 Mudanças no Ambiente da SINFO Ambiente de Produção Novo SIGAA lib *.jar SharedResources lib *.jar SIGRH lib *.jar Obs.: Fica no balanceador Só usa se você acessa a instância diretamente JBOSS SIPAC lib *.jar
22/10/15 Gradle 73 Mudanças no Ambiente da SINFO Nova Estrutura, apenas 1 META-INF eventos.jar
22/10/15 Gradle 74 Mudanças no Ambiente da SINFO Não precisa mais atualizar o arquivo.classpath
22/10/15 Gradle 75 Mudanças no Ambiente da SINFO Novo Arquivo application.xml
22/10/15 Gradle 76 Mudanças no Ambiente da SINFO Isolamento dos Sistemas (solução temporária)
22/10/15 Gradle 77 Mudanças no Ambiente da SINFO Desfazendo as mudanças 1. Arquivo application.xml: Retirar os diretórios libs, voltar o cabeçalho antigo 2. Remover arquivo jboss-classloading.xml 3. Arquivo jboss-app.jar: Retirar java2parentedelegation 4. Retornar o diretório META-INF externo 5. Fazer deploy do diretório LIBS, em vez dos *.jar dentro do projeto 6. Retirar dependências do gradle e adicionar manualmente no classpath o *.jar de LIBS e os projetos da arquitetura
22/10/15 Gradle 78 SIGEventos em Produção Diretório de Deploy Diretório LIBS Diretório LIBS comum do JBOSS
22/10/15 Gradle 79 Mudanças no Ambiente da SINFO Problemas O Isolamento do JBOSS 5.1.0 não funciona como deveria Existem vários conflitos das libs usadas hoje pela SINFO que não ocorriam quando as libs eram compartilhas e passaram a ocorrer quando tentou-se isolar Coisas do Tipo: Executa no windows, mas no Linux dá conflitos entre libs Alguns problemas para executar o Gradle no JDK 6.
22/10/15 Gradle 80 Sistemas Isolados Atualmente Arquitetura (svn) EntidadesComuns (svn) ServicosIntegrados (svn) SharedResources (svn) SigEventos (git) SIGRH (git) SIGAdmin (git) SIRI (svn) Todos esses devem ser abertos no Eclipse como projetos Gradle!!!
22/10/15 Gradle 81 Sistemas Isolados Atualmente Novo workspace:
22/10/15 Gradle 82 Let s Play with Gradle Gradle Project Example: https://github.com/jadsonjs/test
22/10/15 Gradle 83 70% 0%
22/10/15 Gradle 84 Gradle Pictures taken from https://pt.wikibooks.org/wiki/programar_em_c/makefiles https://solidsoft.wordpress.com/category/tricks-tips/ http://pt.slideshare.net/tomek_k/convention-overconfiguration-maven-3-polyglot-maven-gradle-and-ant https://kamaondev.wordpress.com/2013/09/16/porquevoce-deve-trocar-o-maven-pelo-gradle/
22/10/15 Gradle 85