Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-43507] Update to latest -SNAPSHOT of scm-api
  • Loading branch information
stephenc committed Jun 12, 2017
1 parent fc22556 commit d41c751
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 30 deletions.
11 changes: 10 additions & 1 deletion pom.xml
Expand Up @@ -16,7 +16,7 @@
<properties>
<jenkins.version>1.642.3</jenkins.version>
<no-test-jar>false</no-test-jar>
<scm-api-plugin.version>2.2.0-20170504.132618-8</scm-api-plugin.version>
<scm-api-plugin.version>2.2.0-20170612.200107-11</scm-api-plugin.version>
</properties>

<developers>
Expand Down Expand Up @@ -70,7 +70,16 @@
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>scm-api</artifactId>
<version>${scm-api-plugin.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
Expand Down
@@ -1,18 +1,31 @@
package hudson.plugins.mercurial.traits;

import hudson.Extension;
import hudson.plugins.mercurial.MercurialSCM;
import hudson.plugins.mercurial.MercurialSCMBuilder;
import hudson.plugins.mercurial.MercurialSCMSource;
import hudson.scm.SCM;
import javax.annotation.Nonnull;
import jenkins.scm.api.trait.SCMBuilder;
import jenkins.scm.api.trait.SCMSourceTrait;
import jenkins.scm.api.trait.SCMSourceTraitDescriptor;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* A {@link SCMSourceTrait} for {@link MercurialSCMSource} that configures {@link MercurialSCM#setClean(boolean)}.
*
* @since 2.0
*/
public class CleanMercurialSCMSourceTrait extends SCMSourceTrait {
/**
* Constructor.
*/
@DataBoundConstructor public CleanMercurialSCMSourceTrait() { }

@Override protected <B extends SCMBuilder<B, S>, S extends SCM> void decorateBuilder(B builder) {
/**
* {@inheritDoc}
*/
@Override protected void decorateBuilder(SCMBuilder<?, ?> builder) {
((MercurialSCMBuilder<?>) builder).withClean(true);
}

Expand All @@ -21,9 +34,18 @@ public class CleanMercurialSCMSourceTrait extends SCMSourceTrait {
return "Clean Build";
}

@Override public boolean isApplicableToBuilder(@Nonnull Class<? extends SCMBuilder> builderClass) {
return MercurialSCMBuilder.class.isAssignableFrom(builderClass)
&& super.isApplicableToBuilder(builderClass);
/**
* {@inheritDoc}
*/
@Override public Class<? extends SCMBuilder> getBuilderClass() {
return MercurialSCMBuilder.class;
}

/**
* {@inheritDoc}
*/
@Override public Class<? extends SCM> getScmClass() {
return MercurialSCM.class;
}
}
}
Expand Up @@ -29,6 +29,7 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.model.Descriptor;
import hudson.plugins.mercurial.MercurialSCM;
import hudson.plugins.mercurial.MercurialSCMBuilder;
import hudson.plugins.mercurial.MercurialSCMSource;
import hudson.plugins.mercurial.browser.HgBrowser;
Expand All @@ -47,7 +48,7 @@
/**
* Exposes {@link HgBrowser} configuration of a {@link MercurialSCMSource} as a {@link SCMSourceTrait}.
*
* @since 3.4.0
* @since 2.0
*/
public class MercurialBrowserSCMSourceTrait extends SCMSourceTrait {

Expand Down Expand Up @@ -80,22 +81,19 @@ public HgBrowser getBrowser() {
/**
* {@inheritDoc}
*/
@Override
protected <B extends SCMBuilder<B, S>, S extends SCM> void decorateBuilder(B builder) {
@Override protected void decorateBuilder(SCMBuilder<?, ?> builder) {
((MercurialSCMBuilder<?>) builder).withBrowser(browser);
}

/**
* Our {@link Descriptor}
*/
@Extension
public static class DescriptorImpl extends SCMSourceTraitDescriptor {
@Extension public static class DescriptorImpl extends SCMSourceTraitDescriptor {

/**
* {@inheritDoc}
*/
@Override
public @Nonnull String getDisplayName() {
@Override public @Nonnull String getDisplayName() {
return "Configure Repository Browser";
}

Expand All @@ -112,10 +110,15 @@ public List<Descriptor<RepositoryBrowser<?>>> getBrowserDescriptors() {
/**
* {@inheritDoc}
*/
@Override
public boolean isApplicableToBuilder(@NonNull Class<? extends SCMBuilder> builderClass) {
return super.isApplicableToBuilder(builderClass)
&& MercurialSCMBuilder.class.isAssignableFrom(builderClass);
@Override public Class<? extends SCMBuilder> getBuilderClass() {
return MercurialSCMBuilder.class;
}

/**
* {@inheritDoc}
*/
@Override public Class<? extends SCM> getScmClass() {
return MercurialSCM.class;
}
}
}
Expand Up @@ -49,7 +49,7 @@
/**
* Exposes {@link MercurialInstallation} configuration of a {@link MercurialSCMSource} as a {@link SCMSourceTrait}.
*
* @since 3.4.0
* @since 2.0
*/
public class MercurialInstallationSCMSourceTrait extends SCMSourceTrait {
/**
Expand Down Expand Up @@ -78,14 +78,14 @@ public class MercurialInstallationSCMSourceTrait extends SCMSourceTrait {
/**
* {@inheritDoc}
*/
@Override protected <B extends SCMSourceContext<B, R>, R extends SCMSourceRequest> void decorateContext(B context) {
@Override protected void decorateContext(SCMSourceContext<?, ?> context) {
((MercurialSCMSourceContext<?>)context).withInstallation(installation);
}

/**
* {@inheritDoc}
*/
@Override protected <B extends SCMBuilder<B, S>, S extends SCM> void decorateBuilder(B builder) {
@Override protected void decorateBuilder(SCMBuilder<?, ?> builder) {
((MercurialSCMBuilder<?>) builder).withInstallation(installation);
}

Expand All @@ -101,11 +101,32 @@ public class MercurialInstallationSCMSourceTrait extends SCMSourceTrait {
return "Select Mercurial installation";
}

/**
* {@inheritDoc}
*/
@Override public Class<? extends SCMBuilder> getBuilderClass() {
return MercurialSCMBuilder.class;
}

/**
* {@inheritDoc}
*/
@Override public Class<? extends SCMSourceContext> getContextClass() {
return MercurialSCMSourceContext.class;
}

/**
* {@inheritDoc}
*/
@Override public Class<? extends SCM> getScmClass() {
return MercurialSCM.class;
}

/**
* {@inheritDoc}
*/
@Override public boolean isApplicableToBuilder(@Nonnull Class<? extends SCMBuilder> builderClass) {
if (super.isApplicableToBuilder(builderClass) && MercurialSCMBuilder.class.isAssignableFrom(builderClass)) {
if (super.isApplicableToBuilder(builderClass)) {
for (MercurialInstallation i : MercurialInstallation.allInstallations()) {
if (i.isUseCaches()) {
return true;
Expand All @@ -119,22 +140,28 @@ public class MercurialInstallationSCMSourceTrait extends SCMSourceTrait {
* {@inheritDoc}
*/
@Override public boolean isApplicableToContext(@Nonnull Class<? extends SCMSourceContext> contextClass) {
return super.isApplicableToContext(contextClass) && MercurialSCMSourceContext.class
.isAssignableFrom(contextClass);
if (super.isApplicableToContext(contextClass)) {
for (MercurialInstallation i : MercurialInstallation.allInstallations()) {
if (i.isUseCaches()) {
return true;
}
}
}
return false;
}

/**
* {@inheritDoc}
*/
@Override public boolean isApplicableToSCM(@Nonnull Class<? extends SCM> scmClass) {
return super.isApplicableToSCM(scmClass) && MercurialSCM.class.isAssignableFrom(scmClass);
}

/**
* {@inheritDoc}
*/
@Override public boolean isApplicableTo(@Nonnull SCMSource source) {
return super.isApplicableTo(source) && source instanceof MercurialSCMSource;
if (super.isApplicableToSCM(scmClass)) {
for (MercurialInstallation i : MercurialInstallation.allInstallations()) {
if (i.isUseCaches()) {
return true;
}
}
}
return false;
}

/**
Expand Down

0 comments on commit d41c751

Please sign in to comment.