Skip to content

Commit

Permalink
Initial 2.0 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
timyates committed Feb 27, 2013
1 parent 90a2541 commit 23fa579
Show file tree
Hide file tree
Showing 15 changed files with 337 additions and 300 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
module.iml
bin
build
out
out
mods
150 changes: 87 additions & 63 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import org.vertx.java.platform.PlatformLocator
import org.vertx.java.core.Handler

/*
* Copyright 2012 the original author or authors.
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,43 +17,61 @@
* limitations under the License.
*/

apply from: "gradle/maven.gradle"

apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'eclipse'

group = groupname
archivesBaseName = artifact

defaultTasks = ['assemble']

sourceCompatibility = '1.7'
targetCompatibility = '1.7'

jar.enabled = false // we don't need this
// We don't produce a jar
jar.enabled = false
assert configurations.archives.artifacts.removeAll { it.file == jar.archivePath }

compileJava.options.compilerArgs << "-Xlint:unchecked" << "-Werror"
configurations {
provided
testCompile.extendsFrom provided
}

repositories {
mavenLocal()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
mavenCentral()
}

configurations {
provided
}

dependencies {
provided "io.vertx:vertx-core:$vertxVersion"
provided "io.vertx:vertx-platform:$vertxVersion"
compile "c3p0:c3p0:$c3p0Version"
compile "commons-dbutils:commons-dbutils:$dbutilsVersion"
provided "org.vert-x:vertx-core:$vertxVersion"
provided "org.vert-x:vertx-platform:$vertxVersion"

testCompile "org.vert-x:vertx-core:$vertxVersion"
testCompile "org.vert-x:vertx-platform:$vertxVersion"
testCompile "org.vert-x:vertx-lang-java:$vertxVersion"
testCompile "org.vert-x:vertx-lang-rhino:$vertxVersion"
testCompile "org.mozilla:rhino:$rhinoVersion"
testCompile "org.hsqldb:hsqldb:$hsqldbVersion"
testCompile "junit:junit:$junitVersion"
testCompile( "io.vertx:testtools:$toolsVersion" ) {
transitive = false
}
}

// This sets up the classpath for
buildscript {

testCompile( "org.vert-x:vertx-testframework:$vertxVersion" ) {
transitive = false // don't need all of the other language deps
repositories {
mavenLocal()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
mavenCentral()
}

dependencies {
classpath "io.vertx:vertx-core:$vertxVersion"
classpath "io.vertx:vertx-platform:$vertxVersion"
}
testCompile "junit:junit:$junitVersion"
}

sourceSets {
Expand All @@ -59,73 +80,76 @@ sourceSets {
}
}

task prepareVertxModule( type:Copy, dependsOn: 'classes' ) {
into "build/mod/$modulename-v$version"
from 'build/classes/main'
from 'src/main/conf'
task copyMod( type:Copy, dependsOn: 'classes', description: 'Assemble the module into the local mods directory' ) {
into "mods/maven:$groupname:$artifact:$version"
from compileJava
from 'src/main/resources'
into( 'lib' ) {
from configurations.compile
}
}

// Package into build/libs/mod.zip
task distZip( type: Zip, dependsOn: 'prepareVertxModule' ) {
task modZip( type: Zip, dependsOn: 'pullInDeps', description: 'Package the module .zip file') {
group = 'vert.x'
description = "Assembles a vert.x module in 'mod.zip' format"
description = "Assembles a vert.x module"
destinationDir = project.file('build/libs')
archiveName = 'mod.zip'
from( project.file( "build/mod/${modulename}-v${version}" ) ).into( "${modulename}-v${version}" )
archiveName = "${artifact}-${version}" + ".zip"
from copyMod
}

// Check build/libs/mod.zip has a single root, and a mod.json entry
task dist( dependsOn: 'distZip' ) << {
def entries = new java.util.zip.ZipFile( project.file( 'build/libs/mod.zip' ) ).entries().collect { it.name }
def oneRoot = entries.every { it.startsWith "${modulename}-v${version}/" }
def modjson = entries.find { it == "${modulename}-v${version}/mod.json" }
if( !oneRoot ) {
throw new GradleException( "Invalid mod.zip. Multiple root folders located!" )
}
else if( !modjson ) {
throw new GradleException( "Invalid mod.zip. Cannot locate ${modulename}-v${version}/mod.json" )
}
artifacts {
archives modZip
}

task prepareVertxTest(type: Sync, dependsOn: ['prepareVertxModule']) {
from 'build/mod'
into 'build/tmp/mod-test'
task cleanModsDir(type: Delete) {
delete 'mods'
}

clean {
dependsOn cleanModsDir
}

test {
// Can't have the app on the vert.x classpath
classpath = files( classpath.findAll {
!( it.toString() ==~ /.+build\/(classes|resources)\/main$/ )
} )
dependsOn copyMod
// Remove any classpath entries for the module classes and resources- these must be picked up using the module classloader from
// inside the module, not from the system classpath
classpath -= sourceSets.main.output
classpath -= configurations.compile

// classpath.each {
// File file ->
// println file.absolutePath
// }

// Make sure tests are always run!
outputs.upToDateWhen { false }

// Some vert.x properties
systemProperty 'vertx.test.timeout', 15
systemProperty 'vertx.mods', "$projectDir/build/tmp/mod-test"
systemProperty 'vertx.version', "$project.version"
systemProperty 'vertx.modulename', "maven:$groupname:$artifact:$version"

// Show output
testLogging.showStandardStreams = true

// No idea why we need to depend on testClasses...
dependsOn << [ 'testClasses', 'prepareVertxTest' ]
testLogging { exceptionFormat "full" }
}

task collectDeps(type: Copy) {
group = 'vert.x'
description = 'conveniently collect dependencies for other IDEs'
destinationDir = file("build/deps")
into("compile") {
from configurations.compile
}
into("test") {
from configurations.testCompile
}
task runMod(dependsOn: copyMod, description: 'Run the module using all the build dependencies (not using installed vertx') << {
def pm = PlatformLocator.factory.createPlatformManager()
pm.deployModule("maven:$groupname:$artifact:$version", null, 1, new Handler<String>() {
public void handle(String deploymentID) {
System.out.println("CTRL-C to stop server")
}
});
Thread.sleep(Long.MAX_VALUE);
}

task wrapper(type: Wrapper) {
gradleVersion = '1.1'
jarFile = 'gradle/wrapper.jar'
}
task pullInDeps(dependsOn: copyMod, description: 'Pull in all the module dependencies for the module into the nested mods directory') << {
if (pullInDeps == 'true') {
def pm = PlatformLocator.factory.createPlatformManager()
def modName = "maven:$groupname:$artifact:$version"
System.out.println("Pulling in dependencies for module " + modName + " Please wait")
pm.pullInDependencies(modName)
System.out.println("Dependencies pulled into mods directory of module")
}
}
36 changes: 11 additions & 25 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
#
# Copyright 2011 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
groupname=com.bloidonia
artifact=mod-jdbc-persistor
version=2.0.0-SNAPSHOT

# Package properties
modulename=com.bloidonia.jdbc-persistor
version=1.2
# Set to true if you want module dependencies to be pulled in and nested inside the module itself
pullInDeps=false

gradleVersion=1.4
vertxVersion=2.0.0-SNAPSHOT
toolsVersion=1.0.0-SNAPSHOT
junitVersion=4.10

# Compile-time requirements
vertxVersion=1.3.1.final
c3p0Version=0.9.1.2
dbutilsVersion=1.5

# Testing requirements
junitVersion=4.11
rhinoVersion=1.7R4
hsqldbVersion=2.2.9
hsqldbVersion=2.2.9
99 changes: 99 additions & 0 deletions gradle/maven.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright 2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply plugin: 'maven'
apply plugin: 'signing'

if (!hasProperty('sonatypeUsername')) {
ext.sonatypeUsername = ''
}
if (!hasProperty('sonatypePassword')) {
ext.sonatypePassword = ''
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// maven task configuration

ext.isReleaseVersion = !version.endsWith("SNAPSHOT")

signing {
required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}

uploadArchives {
group 'build'
description = "Does a maven deploy of archives artifacts"

repositories {
mavenDeployer {
setUniqueVersion(false)

configuration = configurations.archives

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}

snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}

if (isReleaseVersion) {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
}

configurePom(pom)
}
}
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// configuration methods

def configurePom(def pom) {
pom.project {
description 'Vert.x module that provides JavaScript support using Rhino'
inceptionYear '2013'
packaging 'jar'
url 'http://vertx.io'

developers {
developer {
id 'purplefox'
name 'Tim Fox'
// email '[email protected]'
}
}

scm {
url 'https://github.com/vert-x/mod-lang-rhino'
}

licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}

properties {
setProperty('project.build.sourceEncoding', 'UTF8')
}
}
}

5 changes: 5 additions & 0 deletions gradle/setup.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

task wrapper(type: Wrapper, description: "Create a Gradle self-download wrapper") {
group = 'Project Setup'
gradleVersion = rootProject.gradleVersion
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Aug 07 17:22:15 BST 2012
#Mon Jan 28 08:12:12 GMT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.1-bin.zip
distributionUrl=http\://services.gradle.org/distributions/gradle-1.4-bin.zip
Loading

0 comments on commit 23fa579

Please sign in to comment.