Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Commit

Permalink
* Migrated to gradle.
Browse files Browse the repository at this point in the history
* Added task for publishing to artifactory
Fernando Hernandez committed Feb 9, 2015
1 parent 20dda02 commit 57a7875
Showing 154 changed files with 193 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -11,3 +11,7 @@ dist
*.iml
*.ipr
*.iws

# where gradle properties are stored
gradle.properties
.gradle/
149 changes: 149 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
apply plugin: 'java'
apply plugin: 'idea'

buildscript {
repositories {
maven {
url "http://jcenter.bintray.com"
}

dependencies {
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.2.5')
}
}
}

task wrapper(type: Wrapper) {
gradleVersion = '2.0'
}

allprojects {
group = "com.complexible.common"
sourceCompatibility = '1.7'
targetCompatibility = '1.7'

repositories {
mavenCentral()
}


}

ext {
projectDescription = "A collection of basic utility classes for various common tasks. " +
"Classes provided here often extend or supplement the functionality provided by Guava."
projectUrl = "https://github.com/mhgrove/cp-common-utils"
}

subprojects {
apply plugin: "java"
apply plugin: "maven"
apply plugin: "artifactory"

dependencies {
compile 'org.slf4j:slf4j-api:1.7.5'
compile 'org.slf4j:slf4j-jdk14:1.7.5'

testCompile 'junit:junit:4.11'
}

sourceSets {
main {
java {
srcDir 'main/src'
}
resources {
srcDir 'main/resources'
}
}
test {
java {
srcDir 'test/src'
}
resources {
srcDir 'test/resources'
}
}
}

// create a 'tests' conf for importing test classes from other sub-projects
task testJar(type: Jar, dependsOn: testClasses) {
classifier = 'tests'
from sourceSets.test.output
}

artifacts {
testRuntime testJar // include the tests of other subprojects
}

if (project.hasProperty('publishUrl')
&& project.hasProperty('artifactoryUser')
&& project.hasProperty('artifactoryPassword')) {

// this task is just so artifactory picks up the pom changes
task('uploadMvn', type: Upload) {
configuration = configurations.archives
repositories {
mavenDeployer {
repository(url: publishUrl)
pom.project {
name = archivesBaseName
packaging = 'jar'
description projectDescription
url projectUrl
}

//mess with the generated pom to remove test dependencies from published artifacts
pom.withXml { XmlProvider xmlProvider ->
def xml = xmlProvider.asString()
def pomXml = new XmlParser().parse(new ByteArrayInputStream(xml.toString().bytes))

pomXml.dependencies.dependency.each { dep ->
if (dep.scope.text() != 'compile') {
def parent = dep.parent()
parent.remove(dep)
}
}

def newXml = new StringWriter()
def printer = new XmlNodePrinter(new PrintWriter(newXml))
printer.preserveWhitespace = true
printer.print(pomXml)
xml.setLength(0)
xml.append(newXml.toString())
}

}
}
}

artifactory {
// publishUrl is defined in gradle.properties
publish {
contextUrl = publishUrl
repository {
repoKey = 'stardog-mvn' //The Artifactory repository key to publish to
username = "${artifactoryUser}" //The publisher user name
password = "${artifactoryPassword}" //The publisher password
}
}
resolve {
contextUrl = publishUrl
repository {
repoKey = 'stardog-mvn' //The Artifactory (preferably virtual) repository key to resolve from
username = "${artifactoryUser}" //Optional resolver user name (leave out to use anonymous resolution)
password = "${artifactoryPassword}" //The resolver password
maven = true
}
}

}
}
}

dependencies {
compile project(":core")
compile project(":protobuf")
}


9 changes: 9 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
group = "com.complexible.common.core"
version = "4.0"
archivesBaseName = "cp-common-utils"

dependencies {
compile (group: "com.google.guava", name: "guava", version: "18.0") {
exclude group: "com.google.code.findbugs"
}
}
6 changes: 3 additions & 3 deletions core/build.xml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@

<!-- Global Properties -->
<property name="core" location="."/>
<property name="core.src" location="${core}/src" />
<property name="core.src" location="/core/main/src" />
<property name="core.lib" location="${core}/lib" />
<property name="core.test" location="${core}/test" />

@@ -117,7 +117,7 @@
<target name="build" depends="compile"
description="Compile sources and copy data files into build directory.">
<copy todir="${build}">
<fileset dir="${core.src}">
<fileset dir="/core/main/src">
<exclude name="**/*.java" />
</fileset>
</copy>
@@ -195,7 +195,7 @@ artifactId=${ivy.module}
<link href="http://docs.guava-libraries.googlecode.com/git-history/v17.0/javadoc/"/>

<classpath refid="project.class.path"/>
<fileset dir="${core.src}" defaultexcludes="yes"/>
<fileset dir="/core/main/src" defaultexcludes="yes"/>
</javadoc>
</target>

Original file line number Diff line number Diff line change
@@ -26,4 +26,4 @@
*/
public interface BinaryFunction<Arg1,Arg2,Output> {
public Output apply(Arg1 theArg1, Arg2 theArg2);
}
}
Original file line number Diff line number Diff line change
@@ -2,4 +2,4 @@
* This package defines a set of classes primarily working with Java core objects or other basic operations. Many
* are a supplement to what is found in Guava.
*/
package com.complexible.common.base;
package com.complexible.common.base;
Original file line number Diff line number Diff line change
@@ -87,4 +87,4 @@ public <T> Hasher putObject(final T theT, final Funnel<? super T> theFunnel) {
theFunnel.funnel(theT, this);
return this;
}
}
}
Original file line number Diff line number Diff line change
@@ -115,4 +115,4 @@ private static long parseDuration(String theStr, TimeUnit theUnit) {
}
return theUnit.toMillis(aVal);
}
}
}
Original file line number Diff line number Diff line change
@@ -102,4 +102,4 @@ public void close() throws OE {
throw wrapException(e);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -3,4 +3,4 @@
* standard Java {@link Iterator Iterators} with the exception that they are {@link Iteration#close closeable}
* and can throw an exception when calling {@link Iteration#hasNext} or {@link Iteration#next}.
*/
package com.complexible.common.iterations;
package com.complexible.common.iterations;
Original file line number Diff line number Diff line change
@@ -38,4 +38,4 @@ public static void setup() throws GeneralSecurityException {
new java.security.SecureRandom() );
HttpsURLConnection.setDefaultSSLSocketFactory( sc.getSocketFactory() );
}
}
}
Original file line number Diff line number Diff line change
@@ -214,4 +214,4 @@ public static void main(String[] args) {
t.printStackTrace();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -70,4 +70,4 @@ public String getPassword() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(mUser, mPass.toCharArray());
}
}
}
Original file line number Diff line number Diff line change
@@ -101,4 +101,4 @@ public int compare(T o1, T o2) {

return n1 - n2;
}
}
}
3 changes: 3 additions & 0 deletions gradle.properties.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
publishUrl=/url/to/repo
artifactoryUser=user
artifactoryPassword=secret
9 changes: 9 additions & 0 deletions protobuf/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
group = "com.complexible.common.protobuf"
version = "1.2"
archivesBaseName = "cp-common-protobuf"

dependencies {
compile "com.google.protobuf:protobuf-java:2.5.0"

compile project(":core")
}
2 changes: 2 additions & 0 deletions protobuf/build.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<fileset dir="core/main/src" defaultexcludes="yes"/>
<fileset dir="protobuf/main/src" defaultexcludes="yes"/>
<?xml version="1.0"?>

<project name="Utils Protobuf" default="dist" basedir="" xmlns:ivy="antlib:org.apache.ivy.ant">
Original file line number Diff line number Diff line change
@@ -73,4 +73,4 @@ public T read() throws InvalidProtocolBufferException, IOException {
return null;
}
}
}
}
3 changes: 3 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rootProject.name = "common-utils"

include "core", "protobuf"

0 comments on commit 57a7875

Please sign in to comment.