Skip to content

Commit

Permalink
[JENKINS-42383] Removed dependent plugins (#16)
Browse files Browse the repository at this point in the history
[JENKINS-42383] Removed dependent plugins
  • Loading branch information
v1v committed Mar 2, 2017
1 parent 0856ba2 commit ccaba77
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 20 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Expand Up @@ -96,6 +96,7 @@
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>javadoc</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>

<dependency>
Expand All @@ -109,7 +110,7 @@
<groupId>org.jenkins-ci.main</groupId>
<artifactId>maven-plugin</artifactId>
<version>2.8</version>
<optional>true</optional>
<scope>test</scope>
</dependency>

<dependency>
Expand Down
@@ -1,7 +1,6 @@
package org.jenkins.ci.plugins.jenkinslint.check;

import hudson.matrix.MatrixProject;
import hudson.maven.MavenModuleSet;
import hudson.model.Item;
import hudson.model.Project;
import hudson.tasks.Builder;
Expand All @@ -25,10 +24,14 @@ public GradleWrapperChecker() {
public boolean executeCheck(Item item) {
boolean found = false;
if (Jenkins.getInstance().pluginManager.getPlugin("gradle") != null) {

if (Jenkins.getInstance().pluginManager.getPlugin("maven-plugin")!=null) {
if (item instanceof MavenModuleSet) {
found = isGradlew(((MavenModuleSet) item).getPrebuilders());
if (item.getClass().getSimpleName().equals("MavenModuleSet")) {
try {
Object getPrebuilders = item.getClass().getMethod("getPrebuilders", null).invoke(item);
if (getPrebuilders instanceof List) {
found = isGradlew((List) getPrebuilders);
}
}catch (Exception e) {
LOG.log(Level.WARNING, "Exception " + e.getMessage(), e.getCause());
}
}
if (item instanceof Project) {
Expand Down
@@ -1,7 +1,6 @@
package org.jenkins.ci.plugins.jenkinslint.check;

import hudson.matrix.MatrixProject;
import hudson.maven.MavenModuleSet;
import hudson.model.Item;
import hudson.model.Project;
import hudson.tasks.Builder;
Expand All @@ -26,9 +25,14 @@ public boolean executeCheck(Item item) {
boolean found = false;
if (Jenkins.getInstance().pluginManager.getPlugin("groovy") != null) {

if (Jenkins.getInstance().pluginManager.getPlugin("maven-plugin")!=null) {
if (item instanceof MavenModuleSet) {
found = isSystemExit(((MavenModuleSet) item).getPrebuilders());
if (item.getClass().getSimpleName().equals("MavenModuleSet")) {
try {
Object getPrebuilders = item.getClass().getMethod("getPrebuilders", null).invoke(item);
if (getPrebuilders instanceof List) {
found = isSystemExit((List) getPrebuilders);
}
}catch (Exception e) {
LOG.log(Level.WARNING, "Exception " + e.getMessage(), e.getCause());
}
}
if (item instanceof Project) {
Expand Down
Expand Up @@ -4,7 +4,6 @@
import hudson.model.Item;
import hudson.model.Project;
import hudson.tasks.Builder;
import hudson.maven.MavenModuleSet;
import hudson.tasks.CommandInterpreter;
import jenkins.model.Jenkins;
import org.jenkins.ci.plugins.jenkinslint.model.AbstractCheck;
Expand All @@ -29,9 +28,14 @@ public HardcodedScriptChecker() {
public boolean executeCheck(Item item) {
LOG.log(Level.FINE, "executeCheck " + item);
boolean found = false;
if (Jenkins.getInstance().pluginManager.getPlugin("maven-plugin")!=null) {
if (item instanceof MavenModuleSet) {
found = isBuilderHarcoded(((MavenModuleSet) item).getPrebuilders());
if (item.getClass().getSimpleName().equals("MavenModuleSet")) {
try {
Object getPrebuilders = item.getClass().getMethod("getPrebuilders", null).invoke(item);
if (getPrebuilders instanceof List) {
found = isBuilderHarcoded((List) getPrebuilders);
}
}catch (Exception e) {
LOG.log(Level.WARNING, "Exception " + e.getMessage(), e.getCause());
}
}
if (item instanceof Project) {
Expand Down
Expand Up @@ -3,11 +3,12 @@
import hudson.model.AbstractProject;
import hudson.model.Descriptor;
import hudson.model.Item;
import hudson.tasks.JavadocArchiver;
import hudson.tasks.Publisher;
import hudson.util.DescribableList;
import org.jenkins.ci.plugins.jenkinslint.model.AbstractCheck;

import java.util.logging.Level;

/**
* @author Victor Martinez
*/
Expand All @@ -20,16 +21,26 @@ public JavadocChecker() {
}

public boolean executeCheck(Item item) {
boolean found = false;
if (item instanceof AbstractProject) {
DescribableList<Publisher, Descriptor<Publisher>> publishersList = ((AbstractProject) item).getPublishersList();
for (Publisher publisher : publishersList) {
if (publisher instanceof hudson.tasks.JavadocArchiver) {
return ( ((JavadocArchiver) publisher).getJavadocDir() == null ||
( ((JavadocArchiver) publisher).getJavadocDir() != null &&
((JavadocArchiver) publisher).getJavadocDir().length() == 0 ));
if (publisher.getClass().getSimpleName().equals("JavadocArchiver")) {
try {
Object getJavadocDir = publisher.getClass().getMethod("getJavadocDir", null).invoke(publisher);
if (getJavadocDir instanceof String) {
if (getJavadocDir == null) {
found = true;
} else {
found = ((String) getJavadocDir).isEmpty();
}
}
} catch (Exception e) {
LOG.log(Level.WARNING, "Exception " + e.getMessage(), e.getCause());
}
}
}
}
return false;
return found;
}
}

0 comments on commit ccaba77

Please sign in to comment.