Skip to content

Commit

Permalink
Missing usage of defined local repo
Browse files Browse the repository at this point in the history
This leads to PluginManager not searching for the artifacts at the right
location when repo isn't in default location.

Signed-off-by: Mickael Istria <mistria@redhat.com>
  • Loading branch information
mickaelistria committed Apr 27, 2020
1 parent be74d58 commit 189cb63
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 18 deletions.
57 changes: 49 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,61 @@
pipeline{
agent any
tools {
jdk 'adoptopenjdk-hotspot-jdk8-latest'
maven 'apache-maven-latest'
}
agent {
kubernetes {
label 'lemminx-maven-pod2'
defaultContainer 'jnlp'
yaml """
apiVersion: v1
kind: Pod
spec:
containers:
- name: maven
image: maven
imagePullPolicy: Always
tty: true
command:
- cat
- name: jnlp
image: 'eclipsecbi/jenkins-jnlp-agent'
volumeMounts:
- mountPath: "/home/jenkins/.m2/settings-security.xml"
name: "settings-security-xml"
readOnly: true
subPath: "settings-security.xml"
- mountPath: "/home/jenkins/.m2/settings.xml"
name: "settings-xml"
readOnly: true
volumes:
- name: "settings-security-xml"
secret:
items:
- key: "settings-security.xml"
path: "settings-security.xml"
secretName: "m2-secret-dir"
- name: "settings-xml"
secret:
items:
- key: "settings.xml"
path: "settings.xml"
secretName: "m2-secret-dir"
"""
}
}
environment {
MAVEN_HOME = "$WORKSPACE/.m2/"
MAVEN_USER_HOME = "$MAVEN_HOME"
}
stages{
stage("Maven Build"){
steps {
withMaven {
sh 'mvn -B verify --file lemminx-maven/pom.xml -Dmaven.test.error.ignore=true -Dmaven.test.failure.ignore=true -Dmaven.repo.local=$WORKSPACE/.m2/repository'
}
container('maven') {
sh 'mvn -B verify --file lemminx-maven/pom.xml -Dmaven.test.error.ignore=true -Dmaven.test.failure.ignore=true -Dmaven.repo.local=$WORKSPACE/.m2/repository'
}
}
post {
always {
junit 'lemminx-maven/target/surefire-reports/TEST-*.xml'
}
}
}
stage ('Deploy Maven artifacts') {
when {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,18 @@ public void start(InitializeParams params, XMLExtensionsRegistry registry) {
localRepositorySearcher = new LocalRepositorySearcher(LOCAL_REPOSITORY);
indexSearcher = new RemoteRepositoryIndexSearcher(container);
cache.addProjectParsedListener(indexSearcher::updateKnownRepositories);
MavenPluginManager mavenPluginManager = null;
try {
completionParticipant = new MavenCompletionParticipant(cache, localRepositorySearcher, indexSearcher, container.lookup(MavenPluginManager.class));
mavenPluginManager = container.lookup(MavenPluginManager.class);
} catch (ComponentLookupException e) {
e.printStackTrace();
}
completionParticipant = new MavenCompletionParticipant(cache, localRepositorySearcher, indexSearcher, mavenPluginManager);
registry.registerCompletionParticipant(completionParticipant);
diagnosticParticipant = new MavenDiagnosticParticipant(cache);
registry.registerDiagnosticsParticipant(diagnosticParticipant);
try {
hoverParticipant = new MavenHoverParticipant(cache, indexSearcher, (MavenPluginManager) container.lookup(MavenPluginManager.class));
registry.registerHoverParticipant(hoverParticipant);
} catch (ComponentLookupException e) {
e.printStackTrace();
}
hoverParticipant = new MavenHoverParticipant(cache, indexSearcher, mavenPluginManager);
registry.registerHoverParticipant(hoverParticipant);
definitionParticipant = new MavenDefinitionParticipant(cache, localRepositorySearcher);
registry.registerDefinitionParticipant(definitionParticipant);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.repository.RemoteRepository.Builder;
import org.eclipse.lemminx.dom.DOMNode;
Expand Down Expand Up @@ -98,9 +99,11 @@ public static PluginDescriptor getContainingPluginDescriptor(IPositionRequest re
}

try {
DefaultRepositorySystemSession repositorySystemSession = cache.getRepositorySystemSession();
System.err.println("local repo for plugin manager=" + repositorySystemSession.getLocalRepositoryManager().getRepository().getBasedir());
return pluginManager.getPluginDescriptor(plugin, project.getPluginRepositories().stream()
.map(MavenPluginUtils::toRemoteRepo).collect(Collectors.toList()),
cache.getRepositorySystemSession());
repositorySystemSession);
} catch (PluginResolutionException | PluginDescriptorParsingException | InvalidPluginDescriptorException e) {
e.printStackTrace();
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ private void initializeMavenBuildState() throws ComponentLookupException, Invali
}
projectBuilder = getPlexusContainer().lookup(ProjectBuilder.class);
mavenRequest = new DefaultMavenExecutionRequest();
mavenRequest.setLocalRepositoryPath(RepositorySystem.defaultUserLocalRepository);
mavenRequest.setLocalRepositoryPath(MavenPlugin.LOCAL_REPOSITORY.getAbsolutePath());
repositorySystem = getPlexusContainer().lookup(RepositorySystem.class);
localRepo = repositorySystem.createDefaultLocalRepository();
localRepo = repositorySystem.createLocalRepository(MavenPlugin.LOCAL_REPOSITORY);
mavenRequest.setLocalRepository(getLocalRepository());
DefaultRepositorySystemSessionFactory repositorySessionFactory = getPlexusContainer().lookup(DefaultRepositorySystemSessionFactory.class);
repositorySystemSession = repositorySessionFactory.newRepositorySession(mavenRequest);
Expand Down

0 comments on commit 189cb63

Please sign in to comment.