Skip to content

Commit

Permalink
[JENKINS-32493] Adapt to new parent POM.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Rodriguez committed Jan 29, 2016
1 parent 8c9bca2 commit a32235d
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 130 deletions.
106 changes: 11 additions & 95 deletions pom.xml
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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>
70 changes: 49 additions & 21 deletions src/main/java/jenkins/scm/api/SCMFile.java
Expand Up @@ -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();
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/jenkins/scm/api/SCMFileSystem.java
Expand Up @@ -50,6 +50,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() {
Expand All @@ -58,15 +60,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 {
Expand All @@ -75,6 +82,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;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/jenkins/scm/api/SCMRevisionAction.java
Expand Up @@ -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
Expand Down

0 comments on commit a32235d

Please sign in to comment.