Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert project to use Gradle instead of Maven. #1

Open
wants to merge 1 commit into
base: opensource
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
/bin
# Eclipse
.settings/

# NetBeans
nbproject

# IntelliJ
*.iml
*.ipr
*.iws
.idea/

# maven
target/

# gradle
.gradle/
build/

# vim
.*.sw[a-p]

# various other potential build files
/buildassets/map_*.txt
bin/
dist/
manifest.mf
release/

# Mac filesystem dust
.DS_Store

# Project Specific Files
/mbee_util.jar
/target
.checkstyle
15 changes: 7 additions & 8 deletions .project
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>util</name>
<comment></comment>
<projects>
</projects>
<comment/>
<projects/>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
<arguments/>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<linkedResources/>
</projectDescription>
26 changes: 26 additions & 0 deletions License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) <${year}>, ${company} ("${companyNick}").
U.S. Government sponsorship acknowledged.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
- Neither the name of Caltech nor its operating division, the Jet Propulsion Laboratory,
nor the names of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
223 changes: 223 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
// Gradle task dependencies
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url "http://repository.jboss.org/nexus/content/groups/public/"
}

}
dependencies {
classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1'
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.10.0'
}
}

// Plugins adding various tasks involved in this script
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'license'
//apply plugin: 'checkstyle'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven-publish-auth'
// Allows jar signing
apply plugin: 'signing'

defaultTasks 'clean', 'licenseFormat', 'build'

// Equivalent to maven groupId, artifactId and version
group 'gov.nasa.jpl.mbee.util'
archivesBaseName = 'mbee_util'
version '2.1.0-SNAPSHOT'

// Minimum version of Java required
sourceCompatibility = 1.7
targetCompatibility = 1.7

// Project dependency repositories
repositories {
// Hooks to Maven Central
mavenCentral()
}

dependencies {
// Dependencies are organized in various ways, in this case:
// 'groupId:artifactId:version'
compile 'junit:junit:4.11'
}

// Define the source folder. Normally the source folder is 'src/main/java'. If moved to the
// standard, this section can be removed entirely.
sourceSets {
main {
java {
srcDir 'src'
}
}
}

// Generates sources jar
task sourceJar(type: Jar) {
// The classifier is appended at the end of the file name before the extension.
// Example: mbe_util-2.1.0-SNAPSHOT-sources.jar
classifier 'sources'
from sourceSets.main.allSource
}

// Extra properties defined for the project. These can be used in various configurations for
// other tasks that require them.
ext {
projectName = 'mbee_util'
inceptionYear = '2013'
packaging = 'jar'
url = 'http://example.com/' // TODO Fill in with a proper website url
description = "MBEE java utilities"
organization = 'Open-MBEE'
company = 'California Institute of Technology'
companyNick = 'CalTech'
pomFile = file("${project.projectDir}/pom.xml")
// These fields are optional but can be provided if needed.
// These are set with the following commandline arguments:
// '-PciSystem=Jenkins -Pcommit=${GIT_COMMIT} -PbuildNumber=${BUILD_NUMBER}'
// for a Jenkins installation.
buildNumber = project.hasProperty("buildNumber") ? buildNumber : '0'
ciSystem = project.hasProperty("ciSystem") ? ciSystem : 'unknown'
commit = project.hasProperty("commit") ? commit : 'unknown'
}

// These artifacts are generated by various tasks, both included from plugins and written in this
// script, and can be accessed for uploading to a maven/ivy repository
artifacts {
// Includes the produced archives from the jar task (usually the usable binary jar)
archives jar
// Includes the written task 'sourceJar' that generates the source jar
archives sourceJar
}

// Note: These properties can be filled in via commandline arguments
// '-PsonatypeUser=example -PsonatypePassword=password'
// There have been attempts to use the maven-publish-auth plugin for automated reading of the
// .m2/settings.xml for authentication, however, changing of the upload task to the unstable
// publish task is required.
def sonatypeUser = hasProperty('sonatypeUser') ? sonatypeUser : System.getenv('sonatypeUser')
def sonatypePassword = hasProperty('sonatypePassword') ? sonatypePassword : System.getenv('sonatypePassword')

// Uploads the produced archives from the 'artifacts' task in a sudo-Maven like manner.
// The repositories defined are
// Note: To use this task, add the commandline argument 'uploadArchives'.
uploadArchives {
repositories.mavenDeployer {
beforeDeployment { MavenDeployment deployment ->
// Generates the pom and signs the pom as necessary
signing.signPom(deployment)
}
repository(id: 'artifactory', url: "http://europambee-build.jpl.nasa.gov:8082/artifactory/libs-release-local") {
authentication(userName: sonatypeUser, password: sonatypePassword)

}
snapshotRepository(id: 'artifactory', url: "http://europambee-build.jpl.nasa.gov:8082/artifactory/libs-snapshot-local") {
authentication(userName: sonatypeUser, password: sonatypePassword)
}
// TODO For Completedness, this pom is generated for uploading to the Maven/Ivy repository
// The commented fields should be filled in in order for this utility to be accepted to
// Maven Central.
pom {
groupId = project.group
version = project.version
artifactId = project.archivesBaseName
project {
name project.archivesBaseName
packaging 'jar'
description 'MBEE java utilities'
// url 'http://example.com/'
// Central repository requirements
scm {
url 'https://github.com/Open-MBEE/util'
connection 'git'
developerConnection '[email protected]:Open-MBEE/util.git'
}
// TODO Note the authors of this project according to
// developers {
// developer {
// id 'example'
// name 'Example'
// email '[email protected]'
// }
// }
}
}
}
}

// This Signing task depends on GNU Privacy Guard generated keys.
// More information can be found here: http://www.gradle.org/docs/current/userguide/signing_plugin.html
// This task is automatically skipped if the Gradle is not configured to use any
// GPG keys.
signing {
required {
gradle.taskGraph.hasTask("uploadArchives")
}
// Automatically signs the produced binaries included in the artifacts configuration section
sign configurations.archives
}

// Includes the following resources in the final jar from the jar task.
processResources {
from 'License.txt'
from 'src/rebel.xml'
from 'README.txt' // Optional inclusion, but can be considered
}

// Processes the license information for headers
license {
ext.name = project.name
ext.company = project.company
ext.companyNick = project.companyNick
ext.url = project.url
ext.year = project.inceptionYear
exclude "**/*.xml"
header file("License.txt")
sourceSets = project.sourceSets
ignoreFailures false
strictCheck true
mapping {
java = 'JAVADOC_STYLE'
}
}

// Checkstyle task - Should be considered for uniformity
//checkstyle {
// configProperties = [
// "name" : project.name,
// "organization": project.organization,
// "url" : project.url,
// "year" : project.inceptionYear
// ]
// configFile = file("checkstyle.xml")
//}


jar {
// Generates the manifest and customizes certain attributes
manifest {
attributes(
"Implementation-Title": project.name,
"Implementation-Version": version + "+" + ciSystem + "-b" + buildNumber + ".git-" + commit,
"Built-By": System.properties['user.name'],
"Created-By": System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")",
"Implementation-Vendor": url
)
}
from ("${projectDir}") {
include('License.txt')
}
}

// Java compiler configuration
configure([compileJava, compileTestJava]) {
options.compilerArgs += ['-Xlint:all', '-Xlint:-path']
options.deprecation = true
options.encoding = 'utf8'
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Sat Nov 08 13:48:18 PST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip
Loading