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

Display Git commit info on command line #138

Merged
merged 1 commit into from
Mar 4, 2014
Merged
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
1 change: 0 additions & 1 deletion adam-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
</execution>
</executions>
</plugin>

</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ object AdamMain extends Logging {
Vcf2Adam,
FindReads,
Fasta2Adam,
PluginExecutor)
PluginExecutor,
BuildInformation)

private def printCommands() {
println("\n")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2014. Sebastien Mondet <seb@mondet.org>
*
* 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.
*/
package edu.berkeley.cs.amplab.adam.cli

import scala.collection.JavaConversions._
import scala.Some
import scala.collection.JavaConverters._


object BuildInformation extends AdamCommandCompanion {
val commandName: String = "buildinfo"
val commandDescription: String = "Display build information (use this for bug reports)"

def apply(cmdLine: Array[String]): AdamCommand = {
new BuildInformation()
}
}

class BuildInformation() extends AdamCommand {
val companion = BuildInformation

def run() = {
val properties = edu.berkeley.cs.amplab.adam.core.util.BuildInformation.asString();
println("Build information:\n" + properties);
}


}
1 change: 1 addition & 0 deletions adam-core/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dependency-reduced-pom.xml
src/main/resources/git.properties
20 changes: 20 additions & 0 deletions adam-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.1.9</version>
<executions>
<execution> <goals> <goal>revision</goal> </goals> </execution>
</executions>
<configuration>
<verbose>true</verbose>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<!-- <generateGitPropertiesFilename>adam-cli/src/main/resources/git.properties</generateGitPropertiesFilename> -->
<generateGitPropertiesFilename>src/main/resources/git.properties</generateGitPropertiesFilename>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<excludeProperties>
<!-- Avoid email addresses and names: -->
<excludeProperty>git.commit.user.*</excludeProperty>
<excludeProperty>git.build.user.*</excludeProperty>
</excludeProperties>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2014. Sebastien Mondet <seb@mondet.org>
*
* 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.
*/
package edu.berkeley.cs.amplab.adam.core.util

import scala.collection.JavaConversions._
import scala.Some
import scala.collection.JavaConverters._
import java.util.Properties

/** A static object that gets the resource "git.properties" and renders the
* build-information in different formats. The parsing is “lazy”, it parses
* the properties only the first time a function is called. */
object BuildInformation {

private var properties : scala.Option[scala.collection.mutable.Map[String,String]] = None

/** Return a scala mutable Map (property, value). */
def asMap(): scala.collection.mutable.Map[String,String] = {
properties match {
case Some(inThere) => inThere
case None => {
val javaProperties = new Properties;
javaProperties.load(getClass().getClassLoader().getResourceAsStream("git.properties"));
properties = Some(javaProperties.asScala);
javaProperties.asScala
}
}
}

/** Return a formatted human-readable string. */
def asString(): String = {
asMap().foldLeft(""){
case (prev_string, (key, value)) =>
prev_string + key + ": " + value + "\n"
}
}
}