Skip to content
Permalink
Browse files
Merge pull request #6 from andresrc/JENKINS-32493
[JENKINS-32493] Adapt to new parent POM.
  • Loading branch information
stephenc committed Mar 9, 2016
2 parents 891ef06 + 4e53909 commit a5027b596c4152167f6a1a4789b6db1e0748c7bb
106 pom.xml
@@ -29,8 +29,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.568</version>
<!-- This should be the highest common parent of the common SCM impls, e.g. Git, SVN, Hg, etc-->
<version>2.3</version>
</parent>

<artifactId>scm-api</artifactId>
@@ -57,10 +56,6 @@
</developer>
</developers>

<prerequisites>
<maven>2.2.1</maven>
</prerequisites>

<scm>
<connection>scm:git:git://github.com/jenkinsci/scm-api-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/scm-api-plugin.git</developerConnection>
@@ -69,11 +64,10 @@
</scm>

<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.findbugs.version>3.0.1</maven.findbugs.version>
<maven.findbugs.failure.strict>true</maven.findbugs.failure.strict>
<!-- This should be the highest common parent of the common SCM impls, e.g. Git, SVN, Hg, etc-->
<!-- Under this criteria, using p4-plugin's version. -->
<jenkins.version>1.596.1</jenkins.version>
<java.level>6</java.level>
</properties>

<repositories>
@@ -90,96 +84,18 @@
</pluginRepositories>

<dependencies>
<!-- regular dependencies -->
<dependency>
<groupId>net.jcip</groupId>
<artifactId>jcip-annotations</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>2.0.3</version>
</dependency>
<!-- plugin dependencies -->
<!-- jenkins dependencies -->
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>(,2.1.0),(2.1.0,2.2.0),(2.2.0,)</version>
<message>Maven 2.1.0 and 2.2.0 produce incorrect GPG signatures and checksums respectively.
</message>
</requireMavenVersion>
<requireMavenVersion>
<version>(,3.0),[3.0.4,)</version>
<message>Maven 3.0 through 3.0.3 inclusive do not pass correct settings.xml to Maven Release
Plugin.
</message>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${maven.findbugs.version}</version>
<configuration>
<failOnError>${findbugs.failOnError}</failOnError>
<xmlOutput>true</xmlOutput>
</configuration>
<executions>
<execution>
<id>run-findbugs</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
@@ -43,42 +43,49 @@
public abstract class SCMFile {
/**
* Gets the file name of this file without any path portion, such as just "foo.txt"
* <p/>
* This method is the equivalent of {@link File#getName()}
* <p>This method is the equivalent of {@link File#getName()}.</p>
*
* @return the file name of this file without any path portion.
*/
@NonNull
public abstract String getName();

/**
* Gets a child/descendant path relative from this object.
*
* @param path Relative path of the child to return.
* @return null if there's no file/directory at the path represented by it.
* @throws IOException if an error occurs while performing the operation.
*/
@CheckForNull
public abstract SCMFile get(String path) throws IOException;

/**
* If this object represents a directory, lists up all the immediate children.
* <p/>
* This method is the equivalent of {@link File#listFiles()}.
* <p>This method is the equivalent of {@link File#listFiles()}.</p>
*
* @return Always non-null. If this method is not a directory, this method returns
* an empty iterable.
* @throws IOException if an error occurs while performing the operation.
*/
@NonNull
public abstract Iterable<SCMFile> children() throws IOException;

/**
* Returns true if this object represents a file.
* <p/>
* This method is the equivalent of {@link File#isFile()}
* <p>This method is the equivalent of {@link File#isFile()}.</p>
*
* @return true if this object represents a file.
* @throws IOException if an error occurs while performing the operation.
*/
public abstract boolean isFile() throws IOException;

/**
* Returns true if this object represents a directory.
* <p/>
* This method is the equivalent of {@link File#isDirectory()}
* <p>This method is the equivalent of {@link File#isDirectory()}.</p>
*
* @return true if this object represents a directory.
* @throws IOException if an error occurs while performing the operation.
*/
public boolean isDirectory() throws IOException {
return !isFile();
@@ -87,6 +94,7 @@ public boolean isDirectory() throws IOException {
/**
* Reads the content of this file.
*
* @return an open stream to read the file content. The caller must close the stream.
* @throws IOException if this object represents a directory.
*/
@NonNull
@@ -95,29 +103,43 @@ public boolean isDirectory() throws IOException {
/**
* A convenience method that reads the content and then turns it into a byte array.
*
* @return the file content as a byte array.
* @throws IOException if this object represents a directory.
*/
@NonNull
public byte[] contentAsBytes() throws IOException {
return IOUtils.toByteArray(content());
final InputStream is = content();
try {
return IOUtils.toByteArray(is);
} finally {
IOUtils.closeQuietly(is);
}
}

/**
* A convenience method that reads the content and then turns it into a string.
*
* @return the file content as a string.
* @throws IOException if this object represents a directory.
*/
@NonNull
public String contentAsString() throws IOException {
return IOUtils.toString(content(), contentEncoding());
final InputStream is = content();
try {
return IOUtils.toString(is, contentEncoding());
} finally {
IOUtils.closeQuietly(is);
}
}

/**
* Returns the MIME type of this file.
* <p/>
* The default implementation infers this based on the file name, but
* <p>The default implementation infers this based on the file name, but
* sophisticated server might provide this information from different sources,
* such as "svn:mime-type" in Subversion.
* such as "svn:mime-type" in Subversion.</p>
*
* @return the MIME type of this file.
* @throws IOException if an error occurs while performing the operation.
*/
@NonNull
public String contentMimeType() throws IOException {
@@ -126,29 +148,35 @@ public String contentMimeType() throws IOException {

/**
* Checks if this file is a binary file.
* <p/>
* What exactly is a binary file is up to the implementation. Some SCMs (such as Subversion)
* has a way of letting users mark files as binaries.
* <p>What exactly is a binary file is up to the implementation. Some SCMs (such as Subversion)
* has a way of letting users mark files as binaries.</p>
*
* @return true if this file is a binary file.
* @throws IOException if an error occurs while performing the operation.
*/
public boolean isContentBinary() throws IOException {
return !isContentText();
}

/**
* The opposite of {@link #isContentBinary()}
*
* @return true if this file is not a binary file.
* @throws IOException if an error occurs while performing the operation.
*/
public boolean isContentText() throws IOException {
return StringUtils.startsWithIgnoreCase(contentMimeType(), "text/");
}

/**
* Encoding of this file.
* <p/>
* This is used to interpret text files.
* <p/>
* Some SCM implementations allow users to mark content encoding of files, and this method
* <p>This is used to interpret text files.</p>
* <p>Some SCM implementations allow users to mark content encoding of files, and this method
* may provide those. As a fallback, the default implementation returns the platform
* default encoding.
* default encoding.</p>
*
* @return the encoding of this file.
* @throws IOException if an error occurs while performing the operation.
*/
@NonNull
public Charset contentEncoding() throws IOException {
@@ -25,6 +25,7 @@

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.scm.SCM;
import jenkins.model.Jenkins;
@@ -50,6 +51,8 @@ protected SCMFileSystem(@CheckForNull SCMRevision rev) {
* returns that revision. Otherwise null, indicating
* that the inspector is looking at just the latest state
* of the repository.
*
* @return the revision of the commit the inspector is looking at, or null if none.
*/
@CheckForNull
public SCMRevision getRevision() {
@@ -58,15 +61,20 @@ public SCMRevision getRevision() {

/**
* Whether this inspector is looking at the specific commit.
* <p/>
* Short for {@code getRevision()!=null}.
* <p>Short for {@code getRevision()!=null}.</p>.
*
* @return true if this inspector is looking at the specific commit.
*/
public final boolean isFixedRevision() {
return getRevision() != null;
}

/**
* Short for {@code getRoot().get(path)}
* Short for {@code getRoot().get(path)}.
*
* @param path Path of the SCMFile to obtain from the root of the repository.
* @return null if there's no file/directory at the requested path.
* @throws IOException if an error occurs while performing the operation.
*/
@CheckForNull
public final SCMFile get(@NonNull String path) throws IOException {
@@ -75,6 +83,9 @@ public final SCMFile get(@NonNull String path) throws IOException {

/**
* Returns the {@link SCMFile} object that represents the root directory of the repository.
*
* @return the root directory of the repository.
* @throws IOException if an error occurs while performing the operation.
*/
@NonNull
public abstract SCMFile getRoot() throws IOException;
@@ -102,11 +113,7 @@ public static SCMFileSystem of(@NonNull SCM scm) {
public static SCMFileSystem of(@NonNull SCM scm, @CheckForNull SCMRevision rev) {
scm.getClass(); // throw NPE if null
SCMFileSystem fallBack = null;
Jenkins j = Jenkins.getInstance();
if (j == null) {
return fallBack;
}
for (Builder b : j.getExtensionList(Builder.class)) { // TODO 1.572+ ExtensionList.lookup
for (Builder b : ExtensionList.lookup(Builder.class)) {
SCMFileSystem inspector = b.build(scm, rev);
if (inspector != null) {
if (inspector.isFixedRevision()) {
@@ -148,11 +155,7 @@ public static SCMFileSystem of(@NonNull SCMSource source, @NonNull SCMHead head,
@CheckForNull SCMRevision rev) {
source.getClass(); // throw NPE if null
SCMFileSystem fallBack = null;
Jenkins j = Jenkins.getInstance();
if (j == null) {
return fallBack;
}
for (Builder b : j.getExtensionList(Builder.class)) { // TODO 1.572+ ExtensionList.lookup
for (Builder b : ExtensionList.lookup(Builder.class)) {
SCMFileSystem inspector = b.build(source, head, rev);
if (inspector != null) {
if (inspector.isFixedRevision()) {
@@ -202,11 +202,7 @@ public static abstract class HeadByItem implements ExtensionPoint {
*/
@CheckForNull
public static SCMHead findHead(Item item) {
Jenkins j = Jenkins.getInstance();
if (j == null) {
return null;
}
for (HeadByItem ext : j.getExtensionList(HeadByItem.class)) { // TODO 1.572+ ExtensionList.lookup
for (HeadByItem ext : ExtensionList.lookup(HeadByItem.class)) {
SCMHead head = ext.getHead(item);
if (head != null) {
return head;
@@ -66,6 +66,7 @@ public SCMRevision getRevision() {
/**
* Gets the {@link SCMRevision} from the specified {@link Actionable}.
*
* @param actionable {@link Actionable} containing a possible {@link SCMRevisionAction}.
* @return the {@link SCMRevision}.
*/
@CheckForNull

0 comments on commit a5027b5

Please sign in to comment.