Permalink
Browse files

basic layout / compilation in place

  • Loading branch information...
0 parents commit 8755909bdd50ad4b349364e3c8b74a99ea0806b5 @ypujante ypujante committed Jul 25, 2011
@@ -0,0 +1,8 @@
+.gradle
+.idea
+*.iml
+*.ipr
+*.iws
+.DS_Store
+build
+out
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2011 Yan Pujante
+ *
+ * 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.
+ */
+
+buildscript {
+ repositories {
+ if(project.hasProperty('maven.buildscript.repository'))
+ {
+ mavenRepo urls: new File(project.properties["maven.buildscript.repository"]).toURI()
+ }
+
+ if(project.hasProperty('ivy.buildscript.repository'))
+ {
+ add(new org.apache.ivy.plugins.resolver.FileSystemResolver()) {
+ name = "ivy.buildscript.repository"
+ addIvyPattern "${project.properties['ivy.buildscript.repository']}/[organisation]/[module]/[revision]/[module]-[revision].ivy"
+ addArtifactPattern "${project.properties['ivy.buildscript.repository']}/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
+ m2compatible = true
+ checkmodified = true
+ }
+ }
+
+ // if you want to disallow maven central
+ if(project.properties['no.maven.central'] != 'true')
+ {
+ mavenCentral()
+ }
+ }
+
+ dependencies {
+ classpath 'org.linkedin:org.linkedin.gradle-plugins:1.5.0'
+ }
+}
+
+apply plugin: 'org.linkedin.userConfig'
+apply plugin: 'org.linkedin.spec'
+
+topBuildDir = userConfig.top.build.dir ?: "${rootDir}/out/build"
+
+apply plugin: 'org.linkedin.repository'
+
+allprojects {
+ apply plugin: 'idea'
+ group = spec.group
+}
+
+def ideaCopyright = """
+<component name="CopyrightManager" default="LinkedIn Apache 2.0">
+ <copyright>
+ <option name="notice" value="Copyright (c) ${userConfig.copyright ?: '2010-&amp;#36;today.year LinkedIn, Inc'}&#10;&#10;Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); you may not&#10;use this file except in compliance with the License. You may obtain a copy of&#10;the License at&#10;&#10;http://www.apache.org/licenses/LICENSE-2.0&#10;&#10;Unless required by applicable law or agreed to in writing, software&#10;distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT&#10;WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the&#10;License for the specific language governing permissions and limitations under&#10;the License." />
+ <option name="keyword" value="Copyright" />
+ <option name="allowReplaceKeyword" value="" />
+ <option name="myName" value="LinkedIn Apache 2.0" />
+ <option name="myLocal" value="true" />
+ </copyright>
+ <module2copyright>
+ <element module="All" copyright="LinkedIn Apache 2.0" />
+ </module2copyright>
+</component>
+"""
+
+// customizing idea project
+ideaProject {
+ withXml { root ->
+ root = root.asNode()
+ root.component.find { it.@name == 'VcsDirectoryMappings' }.mapping.@vcs = 'Git'
+ def copyrightNode = root.component.find { it.@name == 'CopyrightManager'}
+ root.remove(copyrightNode)
+ root.append(new XmlParser().parseText(ideaCopyright))
+ }
+}
+
+subprojects {
+ buildscript {
+ allRepositories.buildscript.configure(repositories)
+ }
+ apply plugin: 'maven'
+
+ allRepositories.build.configure(repositories)
+
+ sourceCompatibility = '1.6'
+ targetCompatibility = '1.6'
+
+ buildDir = "${topBuildDir}${project.path.replace(':','/')}".toString()
+}
+
+task clean(type: Delete) {
+ delete topBuildDir
+}
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011 Yan Pujante
+ *
+ * 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.
+ */
+
+spec = [
+ name: 'glu-scripts-contrib',
+ group: 'org.linkedin',
+ version: '1.0.0',
+
+ versions: [
+ glu: '3.1.0',
+ groovy: '1.7.5',
+ linkedinUtils: '1.7.0'
+ ],
+
+ // information about the build framework itself
+ build: [
+ type: "gradle",
+ version: "0.9",
+ uri: "http://gradle.artifactoryonline.com/gradle/distributions/gradle-0.9-all.zip",
+ commands: [
+ "snapshot": "gradle release",
+ "release": "gradle -Prelease=true release"
+ ]
+ ]
+]
+
+spec.scmUrl = "git@github.com:linkedin/${spec.name}.git"
+
+/**
+ * External dependencies
+ */
+spec.external = [
+ gluAgentAPI: "org.linkedin:org.linkedin.glu.agent-api:${spec.versions.glu}",
+ gluScriptsTestFwk: "org.linkedin:org.linkedin.glu.scripts-test-fwk:${spec.versions.glu}",
+ groovy: "org.codehaus.groovy:groovy:${spec.versions.groovy}",
+ junit: 'junit:junit:4.4',
+ linkedinUtilsCore: "org.linkedin:org.linkedin.util-core:${spec.versions.linkedinUtils}",
+ linkedinUtilsGroovy: "org.linkedin:org.linkedin.util-groovy:${spec.versions.linkedinUtils}"
+]
@@ -0,0 +1,94 @@
+
+/*
+ * Copyright (c) 2010-2010 LinkedIn, Inc
+ *
+ * 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.
+ */
+
+def topReleaseDir = new File(userConfig.top.release.dir ?: "${topBuildDir}/release").canonicalFile
+def topPublishDir = new File(userConfig.top.publish.dir ?: "${topBuildDir}/publish").canonicalFile
+
+/**
+ * Repositories for build
+ */
+allRepositories.build = {
+ mavenRepo urls: "file://${rootDir}/local-maven-repo"
+ add(new org.apache.ivy.plugins.resolver.FileSystemResolver()) {
+ name = "build-release"
+ addIvyPattern "${topReleaseDir}/[organisation]/[module]/[revision]/[module]-[revision].ivy"
+ addArtifactPattern "${topReleaseDir}/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
+ m2compatible = true
+ checkmodified = true
+ }
+
+ mavenRepo name: 'build-publish', urls: topPublishDir.toURI()
+
+ mavenRepo name: 'restlet', urls: "http://maven.restlet.org"
+
+ mavenCentral()
+}
+
+/**
+ * Repositories for buildScript
+ */
+allRepositories.buildscript = allRepositories.build
+
+/**
+ * Repositories for release
+ */
+allRepositories.snapshotRelease = {
+ add(new org.apache.ivy.plugins.resolver.FileSystemResolver()) {
+ name = 'local-release'
+ addIvyPattern "${topReleaseDir}/[organisation]/[module]/[revision]/[module]-[revision].ivy"
+ addArtifactPattern "${topReleaseDir}/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
+ m2compatible = true
+ }
+}
+
+allRepositories.release = allRepositories.snapshotRelease
+
+/**
+ * Repositories for publish
+ */
+allRepositories.snapshotPublish = {
+ mavenDeployer {
+ repository(url: "file://localhost${topPublishDir}")
+ pom.whenConfigured { pomToConfigure ->
+ pomToConfigure.project {
+ name project.name
+ description 'glu scripts contrib'
+ url 'http://github.com/linkedin/glu-scripts-contrib'
+ licenses {
+ license {
+ name 'The Apache Software License, Version 2.0'
+ url 'http://www.apache.org/licenses/LICENSE-2.0'
+ }
+ }
+ developers {
+ developer {
+ id 'ypujante'
+ name 'Yan Pujante'
+ email 'yan@pongasoft.com'
+ }
+ }
+ scm {
+ connection "scm:git:${spec.scmUrl}"
+ developerConnection "scm:git:${spec.scmUrl}"
+ url spec.scmUrl
+ }
+ }
+ }
+ }
+}
+
+allRepositories.publish = allRepositories.snapshotPublish
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2011 Yan Pujante
+ *
+ * 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.
+ */
+
+/**
+ * Configuring for all scripts
+ */
+import org.linkedin.gradle.tasks.SingleArtifactTask
+import org.apache.tools.ant.filters.ReplaceTokens
+import java.util.regex.Pattern
+
+subprojects {
+ apply plugin: 'groovy'
+ apply plugin: 'org.linkedin.release'
+
+ release {
+ releaseConfigurations << 'script'
+ }
+
+ dependencies {
+ compile spec.external.linkedinUtilsGroovy
+ compile spec.external.gluAgentAPI
+ groovy spec.external.groovy
+
+ testCompile spec.external.gluScriptsTestFwk
+ testCompile spec.external.junit
+ }
+
+ def scriptTask = task('scripts')
+
+ def scripts = fileTree(dir: 'src/main/groovy', include: '*.groovy')
+
+ version = computeVersion(scripts)
+
+ logger.lifecycle "${project.name} - ${version}"
+
+ scripts.each { File scriptFile ->
+ def baseName = scriptFile.name - '.groovy'
+ task([type: SingleArtifactTask], baseName) {
+ artifactFile = scriptFile
+ artifactReleaseInfo =
+ [
+ name: baseName,
+ extension: 'groovy',
+ configurations: ['script']
+ ]
+ }
+
+ scriptTask.dependsOn(baseName)
+ }
+}
+
+private String computeVersion(scripts)
+{
+ Pattern VERSION_REGEX = ~/def\s+version\s*=\s*'([^']+)'/
+
+ String version = null
+ scripts.each { File scriptFile ->
+ scriptFile.eachLine { String line ->
+ def matcher = VERSION_REGEX.matcher(line)
+ if(matcher.find())
+ {
+ String newVersion = matcher[0][1]
+ if(version != null && version != newVersion)
+ throw new IllegalStateException("different versions found ${version} != ${newVersion} for ${scripts}")
+ version = newVersion
+ }
+ }
+ }
+ if(version == null)
+ throw new IllegalStateException("could not compute version for ${scripts.collect {it.canonicalPath}}")
+
+ if(spec.version.endsWith('-SNAPSHOT'))
+ version = "${version}-SNAPSHOT".toString()
+
+ return version
+}
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011 Yan Pujante
+ *
+ * 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.
+ */
+
+class SampleGluScript
+{
+ def version = '1.0.0'
+
+ def install = {
+ // nothing
+ }
+
+ def configure = {
+ // nothing
+ }
+
+ def start = {
+ // nothing
+ }
+
+ def stop = {
+ // nothing
+ }
+
+ def unconfigure = {
+ // nothing
+ }
+
+ def uninstall = {
+ // nothing
+ }
+}
Oops, something went wrong.

0 comments on commit 8755909

Please sign in to comment.