Skip to content

Commit

Permalink
[JENKINS-42383] Removed maven-plugin optional dependency and using re…
Browse files Browse the repository at this point in the history
…flection instead
  • Loading branch information
v1v committed Feb 28, 2017
1 parent 0856ba2 commit e83cb3d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -109,7 +109,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

0 comments on commit e83cb3d

Please sign in to comment.