Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing usage of defined local repo #32

Merged
merged 1 commit into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 56 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,68 @@
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
resources:
limits:
memory: "4Gi"
cpu: "2000m"
requests:
memory: "4Gi"
cpu: "1000m"
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