On Github alexssandroreis / automacao-build-maven
Autor:Alexssandro A. Reis / @alereis
Os builds eram feitos de forma manual.
Exemplo
javac Compute.java Task.java mkdir target cd target cp ../*.class . jar cvf compute.jar *.class tar -zcf compute.tar comput.jar scp -i key user:pass@host.com:/home/user/deploy
<project name="myProject" default="build" basedir="."> <description> My Project's Description </description> <property name="build" location="build" /> <target name="init"> <mkdir dir="${build}" /> </target> <target name="clean"> <delete dir="${build}" /> </target> </project>
|-- pom.xml `-- target `-- src |-- main | `-- java | `--pacote | `-- App.java `-- test `-- java `-- pacote `-- AppTest.java
Contém todas as dependências já baixadas pelo maven
<project> <modelVersion /> <groupId /> <artifactId /> <version /> </project>
<dependencies> <dependency> <groupId /> <artifactId /> <version /> <scope /> </dependency> </dependencies>
<plugins> <plugin> <groupId /> <artifactId /> <version /> <executions> <execution> <phase /> <goals> <goal /> </goals> </execution> </executions> </plugin> </plugins>
<distributionManagement> <repository> <id /> <url /> </repository> <snapshotRepository> <id /> <url /> </snapshotRepository> </distributionManagement>
<repositories> <repository> <id /> <url /> </repository> </repositories>
mvn clean package deploy
|-- settings.gradle `-- build.gradle `-- gradle |-- wrapper |-- gradle-wrapper.jar `-- gradle-wrapper.properties `-- src |-- main | `-- java | `-- pacote | `-- App.java `-- test `-- java `-- pacote `-- AppTest.java
apply plugin: 'java' sourceCompatibility = 1.5 version = '1.0' repositories { mavenCentral() } dependecies { compile group: 'groupId', name: 'artifactId', version: 'version' testCompile group: 'groupId', name: 'artifactId', version: 'version' }
dependecies { compile group: 'groupId', name: 'artifactId', version: 'version' testCompile group: 'groupId', name: 'artifactId', version: 'version' }
repositories { mavenCentral() maven { url "http://repo.mycompany.com/maven2" } ivy { url "http://repo.mycompany.com/repo" } }
task hello << { println 'Hello world!' } task intro(dependsOn: hello) << { println "I'm Gradle" }
apply plugin: 'java' //binários apply from: 'other.gradle' //scripts
apply plugin: 'maven' uploadArchives { repositories { mavenDeployer { repository(url: "file://localhost/tmp/myRepo/") } ivy { credentials { username "username" password "pw" } url "http://repo.mycompany.com" } } }