Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
18,700
void (@Nullable File file, @Nullable DependencyResolutionResult result, Collection<MavenProjectProblem> problems) { if (result == null) return; String path = file == null ? "" : file.getPath(); for (Dependency unresolvedDependency : result.getUnresolvedDependencies()) { for (Exception exception : result.getResolutionErrors(unresolvedDependency)) { String message = getRootMessage(exception); Artifact artifact = RepositoryUtils.toArtifact(unresolvedDependency.getArtifact()); MavenArtifact mavenArtifact = Maven3ModelConverter.convertArtifact(artifact, myEmbedder.getLocalRepositoryFile()); problems.add(MavenProjectProblem.createUnresolvedArtifactProblem(path, message, true, mavenArtifact)); break; } } }
collectUnresolvedArtifactProblems
18,701
String (Throwable each) { String baseMessage = each.getMessage() != null ? each.getMessage() : ""; Throwable rootCause = ExceptionUtils.getRootCause(each); String rootMessage = rootCause != null ? rootCause.getMessage() : ""; return StringUtils.isNotEmpty(rootMessage) ? rootMessage : baseMessage; }
getRootMessage
18,702
Collection<AbstractMavenLifecycleParticipant> (Collection<MavenProject> projects) { Collection<AbstractMavenLifecycleParticipant> lifecycleListeners = new LinkedHashSet<>(); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { lifecycleListeners.addAll(myEmbedder.getComponents(AbstractMavenLifecycleParticipant.class)); Collection<ClassLoader> scannedRealms = new HashSet<>(); for (MavenProject project : projects) { ClassLoader projectRealm = project.getClassRealm(); if (projectRealm != null && scannedRealms.add(projectRealm)) { Thread.currentThread().setContextClassLoader(projectRealm); lifecycleListeners.addAll(myEmbedder.getComponents(AbstractMavenLifecycleParticipant.class)); } } } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } return lifecycleListeners; }
getLifecycleParticipants
18,703
boolean (String a, String b) { return notNullize(a).equals(notNullize(b)); }
equals
18,704
void (ModelProblemCollectorRequest request) { myHasFatalErrors |= (request.getSeverity() == ModelProblem.Severity.FATAL); myDelegate.add(request); }
add
18,705
boolean () { return myHasFatalErrors; }
hasFatalErrors
18,706
void (ModelProblemCollectorRequest request) { super.add(request); throw new AbortOnErrorException(); }
add
18,707
void (Model model, ModelBuildingRequest request, ModelProblemCollector problems) { myDefaultModelValidator.validateEffectiveModel(model, request, problems); }
validateEffectiveModel
18,708
boolean (String a, String b) { return notNullize(a).equals(notNullize(b)); }
equals
18,709
void (ModelProblemCollectorRequest request) { myHasFatalErrors |= (request.getSeverity() == ModelProblem.Severity.FATAL); myDelegate.add(request); }
add
18,710
boolean () { return myHasFatalErrors; }
hasFatalErrors
18,711
void (ModelProblemCollectorRequest request) { super.add(request); throw new AbortOnErrorException(); }
add
18,712
void (Runnable command ) { command.run(); }
execute
18,713
RepositorySystemSession ( ArtifactRepository localRepository ) { return LegacyLocalRepositoryManager.overlay( localRepository, legacySupport.getRepositorySession(), repoSystem ); }
getSession
18,714
void (RepositoryRequest request, MavenSession session) { if ( session != null ) { request.setOffline( session.isOffline() ); request.setForceUpdate( session.getRequest().isUpdateSnapshots() ); } }
injectSession1
18,715
void (ArtifactResolutionRequest request, MavenSession session) { injectSession1( request, session ); if ( session != null ) { request.setServers( session.getRequest().getServers() ); request.setMirrors( session.getRequest().getMirrors() ); request.setProxies( session.getRequest().getProxies() ); } }
injectSession2
18,716
ArtifactResolutionResult (ArtifactResolutionRequest request ) { Artifact rootArtifact = request.getArtifact(); Set<Artifact> artifacts = request.getArtifactDependencies(); Map<String, Artifact> managedVersions = request.getManagedVersionMap(); List<ResolutionListener> listeners = request.getListeners(); ArtifactFilter collectionFilter = request.getCollectionFilter(); ArtifactFilter resolutionFilter = request.getResolutionFilter(); RepositorySystemSession session = getSession( request.getLocalRepository() ); //TODO: hack because metadata isn't generated in m2e correctly and i want to run the maven i have in the workspace if ( source == null ) { try { source = container.lookup( ArtifactMetadataSource.class ); } catch ( ComponentLookupException e ) { // won't happen } } if ( listeners == null ) { listeners = new ArrayList<ResolutionListener>(); if ( logger.isDebugEnabled() ) { listeners.add( new DebugResolutionListener( logger ) ); } listeners.add( new WarningResolutionListener( logger ) ); } ArtifactResolutionResult result = new ArtifactResolutionResult(); // The root artifact may, or may not be resolved so we need to check before we attempt to resolve. // This is often an artifact like a POM that is taken from disk and we already have hold of the // file reference. But this may be a Maven Plugin that we need to resolve from a remote repository // as well as its dependencies. if ( request.isResolveRoot() /* && rootArtifact.getFile() == null */ ) { try { resolve( rootArtifact, request.getRemoteRepositories(), session ); } catch ( ArtifactResolutionException e ) { result.addErrorArtifactException( e ); return result; } catch ( ArtifactNotFoundException e ) { result.addMissingArtifact( request.getArtifact() ); return result; } } ArtifactResolutionRequest collectionRequest = request; if ( request.isResolveTransitively() ) { MetadataResolutionRequest metadataRequest = new DefaultMetadataResolutionRequest( request ); metadataRequest.setArtifact( rootArtifact ); metadataRequest.setResolveManagedVersions( managedVersions == null ); try { ResolutionGroup resolutionGroup = source.retrieve( metadataRequest ); if ( managedVersions == null ) { managedVersions = resolutionGroup.getManagedVersions(); } Set<Artifact> directArtifacts = resolutionGroup.getArtifacts(); if ( artifacts == null || artifacts.isEmpty() ) { artifacts = directArtifacts; } else { List<Artifact> allArtifacts = new ArrayList<Artifact>(); allArtifacts.addAll( artifacts ); allArtifacts.addAll( directArtifacts ); Map<String, Artifact> mergedArtifacts = new LinkedHashMap<String, Artifact>(); for ( Artifact artifact : allArtifacts ) { String conflictId = artifact.getDependencyConflictId(); if ( !mergedArtifacts.containsKey( conflictId ) ) { mergedArtifacts.put( conflictId, artifact ); } } artifacts = new LinkedHashSet<Artifact>( mergedArtifacts.values() ); } collectionRequest = new ArtifactResolutionRequest( request ); collectionRequest.setServers( request.getServers() ); collectionRequest.setMirrors( request.getMirrors() ); collectionRequest.setProxies( request.getProxies() ); collectionRequest.setRemoteRepositories( resolutionGroup.getResolutionRepositories() ); } catch ( ArtifactMetadataRetrievalException e ) { ArtifactResolutionException are = new ArtifactResolutionException( "Unable to get dependency information for " + rootArtifact.getId() + ": " + e.getMessage(), rootArtifact, metadataRequest.getRemoteRepositories(), e ); result.addMetadataResolutionException( are ); return result; } } if ( artifacts == null || artifacts.isEmpty() ) { if ( request.isResolveRoot() ) { result.addArtifact( rootArtifact ); } return result; } // After the collection we will have the artifact object in the result but they will not be resolved yet. result = artifactCollector.collect( artifacts, rootArtifact, managedVersions, collectionRequest, source, collectionFilter, listeners, null ); // We have metadata retrieval problems, or there are cycles that have been detected // so we give this back to the calling code and let them deal with this information // appropriately. if ( result.hasMetadataResolutionExceptions() || result.hasVersionRangeViolations() || result.hasCircularDependencyExceptions() ) { return result; } if ( result.getArtifactResolutionNodes() != null ) { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); CountDownLatch latch = new CountDownLatch( result.getArtifactResolutionNodes().size() ); for ( ResolutionNode node : result.getArtifactResolutionNodes() ) { Artifact artifact = node.getArtifact(); if ( resolutionFilter == null || resolutionFilter.include( artifact ) ) { executor.execute( new ResolveTask( classLoader, latch, artifact, session, node.getRemoteRepositories(), result ) ); } else { latch.countDown(); } } try { latch.await(); } catch ( InterruptedException e ) { result.addErrorArtifactException( new ArtifactResolutionException( "Resolution interrupted", rootArtifact, e ) ); } } // We want to send the root artifact back in the result but we need to do this after the other dependencies // have been resolved. if ( request.isResolveRoot() ) { // Add the root artifact (as the first artifact to retain logical order of class path!) Set<Artifact> allArtifacts = new LinkedHashSet<Artifact>(); allArtifacts.add( rootArtifact ); allArtifacts.addAll( result.getArtifacts() ); result.setArtifacts( allArtifacts ); } return result; }
resolve
18,717
void (MavenWorkspaceMap workspaceMap) { myWorkspaceMap = workspaceMap; }
customize
18,718
void () { myWorkspaceMap = null; }
reset
18,719
boolean (Artifact a) { // method is called from different threads, so we have to copy the reference so ensure there is no race conditions. MavenWorkspaceMap map = myWorkspaceMap; if (map == null) return false; MavenWorkspaceMap.Data resolved = map.findFileAndOriginalId(Maven3ModelConverter.createMavenId(a)); if (resolved == null) return false; a.setResolved(true); a.setFile(resolved.getFile(a.getType())); a.selectVersion(resolved.originalId.getVersion()); return true; }
resolveAsModule
18,720
Thread (Runnable r ) { Thread newThread = new Thread( GROUP, r, "resolver-" + THREAD_NUMBER.getAndIncrement() ); newThread.setDaemon( true ); newThread.setContextClassLoader( null ); return newThread; }
newThread
18,721
void () { ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader( classLoader ); resolve( artifact, remoteRepositories, session ); } catch ( ArtifactNotFoundException anfe ) { // These are cases where the artifact just isn't present in any of the remote repositories // because it wasn't deployed, or it was deployed in the wrong place. synchronized ( result ) { result.addMissingArtifact( artifact ); } } catch ( ArtifactResolutionException e ) { // This is really a wagon TransferFailedException so something went wrong after we successfully // retrieved the metadata. synchronized ( result ) { result.addErrorArtifactException( e ); } } finally { latch.countDown(); Thread.currentThread().setContextClassLoader( old ); } }
run
18,722
void () { if ( executor instanceof ExecutorService ) { ( (ExecutorService) executor ).shutdownNow(); } }
dispose
18,723
void () { assertPrintResult("[IJ]-1-null", null); assertPrintResult("[IJ]-1-type", "type"); assertPrintResult("[IJ]-1-type-[IJ]-name=value", "type", "name", "value"); assertPrintResult("[IJ]-1-type-[IJ]-name=null", "type", "name", null); assertPrintResult("[IJ]-1-type-[IJ]-name1=value1-[IJ]-name2=value2", "type", "name1", "value1", "name2", "value2"); }
testBasicPrinting
18,724
void () { assertPrintResult("[IJ]-1-type-[IJ]-name=-[N]-", "type", "name", "\n"); assertPrintResult("[IJ]-1-type-[IJ]-name=-[N]--[N]-", "type", "name", "\n\n"); assertPrintResult("[IJ]-1-type-[IJ]-name=-[N]-abc", "type", "name", "\nabc"); assertPrintResult("[IJ]-1-type-[IJ]-name=abc-[N]-", "type", "name", "abc\n"); assertPrintResult("[IJ]-1-type-[IJ]-name=abc-[N]-def", "type", "name", "abc\ndef"); assertPrintResult("[IJ]-1-type-[IJ]-name=-[N]-abc-[N]-", "type", "name", "\nabc\n"); assertPrintResult("[IJ]-1-type-[IJ]-name=1-[N]-2-[N]-3-[N]--[N]-4-[N]--[N]-5-[N]--[N]-6", "type", "name", "1\n2\n\r3\n\n4\n\r\n5\n\n\r6"); }
testPrintingWithNewLines
18,725
void (String expected, Object type, CharSequence... objects) { assertEquals(expected, EventInfoPrinter.printToBuffer(type, objects).toString()); }
assertPrintResult
18,726
void (Object type, CharSequence... args) { //noinspection UseOfSystemOutOrSystemErr System.out.println(printToBuffer(type, args)); }
print
18,727
StringBuilder (Object type, CharSequence... args) { StringBuilder out = new StringBuilder(); out.append(PREFIX); out.append(Thread.currentThread().getId()); out.append('-'); out.append(type); if (args != null) { for (int i = 0; i < args.length; i += 2) { out.append(SEPARATOR); out.append(args[i]); out.append('='); appendReplacingNewLines(out, args[i + 1]); } } return out; }
printToBuffer
18,728
void (StringBuilder out, CharSequence value) { if (value == null) { out.append("null"); return; } int appendFrom = 0; int length = value.length(); for (int i = 0; i < length; i++) { char ch = value.charAt(i); if (ch == '\n') { out.append(value.subSequence(appendFrom, i)); if (i < length - 1 && value.charAt(i + 1) == '\r') { //noinspection AssignmentToForLoopParameter i++; } out.append(NEWLINE); appendFrom = i + 1; } } if (appendFrom == 0) { out.append(value); } else { out.append(value.subSequence(appendFrom, value.length())); } }
appendReplacingNewLines
18,729
void (Object type, String name1, CharSequence value1) { print(type, name1, value1); }
printMavenEventInfo
18,730
void (Object type, String name1, CharSequence value1, String name2, CharSequence value2) { print(type, name1, value1, name2, value2); }
printMavenEventInfo
18,731
void (Object type, String name1, CharSequence value1, String name2, CharSequence value2, String name3, CharSequence value3) { print(type, name1, value1, name2, value2, name3, value3); }
printMavenEventInfo
18,732
void (Object type, String name1, CharSequence value1, String name2, CharSequence value2, String name3, CharSequence value3, String name4, CharSequence value4) { print(type, name1, value1, name2, value2, name3, value3, name4, value4); }
printMavenEventInfo
18,733
void (Object event) { try { if (event instanceof ExecutionEvent) { onExecutionEvent((ExecutionEvent)event); } else if (event instanceof RepositoryEvent) { onRepositoryEvent((RepositoryEvent)event); } else if (event instanceof DependencyResolutionRequest) { onDependencyResolutionRequest((DependencyResolutionRequest)event); } else if (event instanceof DependencyResolutionResult) { onDependencyResolutionResult((DependencyResolutionResult)event); } } catch (Throwable e) { collectAndPrintLastLinesForEA(e); } }
onEvent
18,734
void (DependencyResolutionRequest event) { String projectId = event.getMavenProject() == null ? "unknown" : event.getMavenProject().getId(); printMavenEventInfo("DependencyResolutionRequest", "id", projectId); }
onDependencyResolutionRequest
18,735
void (DependencyResolutionResult event) { List<Exception> errors = event.getCollectionErrors(); StringBuilder result = new StringBuilder(); for (Exception e : errors) { if (result.length() > 0) { result.append(NEWLINE); } result.append(e.getMessage()); } printMavenEventInfo("DependencyResolutionResult", "error", result); }
onDependencyResolutionResult
18,736
void (Throwable e) { //need to collect last 3 lines to send to EA int lines = Math.max(e.getStackTrace().length, 3); StringBuilder builder = new StringBuilder(); builder.append(e.getMessage()); for (int i = 0; i < lines; i++) { builder.append(e.getStackTrace()[i]).append("\n"); } printMavenEventInfo("INTERR", "error", builder); }
collectAndPrintLastLinesForEA
18,737
void (RepositoryEvent event) { RepositoryEvent.EventType type = event.getType(); // optimization to prevent unnecessary CPU and memory pressure on many irrelevant events // only these events are currently used (see MavenEventType) if (type != RepositoryEvent.EventType.ARTIFACT_DOWNLOADING && type != RepositoryEvent.EventType.ARTIFACT_RESOLVING) return; String errMessage = event.getException() == null ? "" : event.getException().getMessage(); String path = event.getFile() == null ? "" : event.getFile().getPath(); String artifactCoord = event.getArtifact() == null ? "" : event.getArtifact().toString(); printMavenEventInfo(type, "path", path, "artifactCoord", artifactCoord, "error", errMessage); }
onRepositoryEvent
18,738
void (ExecutionEvent event) { MojoExecution mojoExec = event.getMojoExecution(); String projectId = event.getProject() == null ? "unknown" : event.getProject().getId(); if (mojoExec != null) { String errMessage = event.getException() == null ? "" : getErrorMessage(event.getException()); printMavenEventInfo(event.getType(), "source", String.valueOf(mojoExec.getSource()), "goal", mojoExec.getGoal(), "id", projectId, "error", errMessage); } else { if (event.getType() == ExecutionEvent.Type.SessionStarted) { printSessionStartedEventAndReactorData(event, projectId); } else { printMavenEventInfo(event.getType(), "id", projectId); } } }
onExecutionEvent
18,739
String (Exception exception) { String baseMessage = exception.getMessage(); Throwable rootCause = ExceptionUtils.getRootCause(exception); String rootMessage = rootCause != null ? rootCause.getMessage() : StringUtils.EMPTY; return StringUtils.isNotEmpty(rootMessage) ? rootMessage : baseMessage; }
getErrorMessage
18,740
void (ExecutionEvent event, String projectId) { MavenSession session = event.getSession(); if (session != null) { List<MavenProject> projectsInReactor = session.getProjects(); if (projectsInReactor == null) { projectsInReactor = new ArrayList<>(); } StringBuilder builder = new StringBuilder(); for (MavenProject project : projectsInReactor) { builder .append(project.getGroupId()).append(":") .append(project.getArtifactId()).append(":") .append(project.getVersion()).append("&&"); } printMavenEventInfo(ExecutionEvent.Type.SessionStarted, "id", projectId, "projects", builder); } else { printMavenEventInfo(ExecutionEvent.Type.SessionStarted, "id", projectId, "projects", ""); } }
printSessionStartedEventAndReactorData
18,741
String (final Maven3ServerEmbedder embedder, @NotNull final File file, @NotNull List<String> activeProfiles, @NotNull List<String> inactiveProfiles) { final StringWriter w = new StringWriter(); try { MavenExecutionRequest request = embedder.createRequest(file, activeProfiles, inactiveProfiles); embedder.executeWithMavenSession(request, () -> { try { // copied from DefaultMavenProjectBuilder.buildWithDependencies ProjectBuilder builder = embedder.getComponent(ProjectBuilder.class); ProjectBuildingResult buildingResult = builder.build(new File(file.getPath()), request.getProjectBuildingRequest()); MavenProject project = buildingResult.getProject(); XMLWriter writer = new PrettyPrintXMLWriter(new PrintWriter(w), StringUtils.repeat(" ", XmlWriterUtil.DEFAULT_INDENTATION_SIZE), "\n", null, null); writeHeader(writer); writeEffectivePom(project, writer); } catch (Exception e) { throw new RuntimeException(e); } }); } catch (Exception e) { return null; } return w.toString(); }
evaluateEffectivePom
18,742
void (Model pom) { Properties properties = new SortedProperties(); properties.putAll(pom.getProperties()); pom.setProperties(properties); }
cleanModel
18,743
void (XMLWriter writer) { XmlWriterUtil.writeCommentLineBreak(writer); XmlWriterUtil.writeComment(writer, " "); // Use ISO8601-format for date and time DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss"); XmlWriterUtil.writeComment(writer, "Generated on " + dateFormat.format(new Date(System.currentTimeMillis()))); XmlWriterUtil.writeComment(writer, " "); XmlWriterUtil.writeCommentLineBreak(writer); XmlWriterUtil.writeLineBreak(writer); }
writeHeader
18,744
void (XMLWriter writer, String comment) { XmlWriterUtil.writeCommentLineBreak(writer); XmlWriterUtil.writeComment(writer, " "); XmlWriterUtil.writeComment(writer, comment); XmlWriterUtil.writeComment(writer, " "); XmlWriterUtil.writeCommentLineBreak(writer); XmlWriterUtil.writeLineBreak(writer); }
writeComment
18,745
boolean (Element e) { return !e.getChildren().isEmpty() || e.getText().contains("\n"); }
hasLineBreak
18,746
boolean (String text) { int eof = text.indexOf('\n'); return eof != -1 && eof == text.lastIndexOf('\n') && text.trim().isEmpty(); }
isOneEOFText
18,747
void (Element element) { List<Content> children = element.getContent(); for (int i = 0; i < children.size() - 2; i++) { Content c1 = children.get(i); Content c2 = children.get(i + 1); Content c3 = children.get(i + 2); if (c1 instanceof Element && c2 instanceof Text && c3 instanceof Element && (hasLineBreak((Element)c1) || hasLineBreak((Element)c3)) && isOneEOFText(((Text)c2).getText())) { element.setContent(i + 1, new Text(((Text)c2).getText().replace("\n", "\n\n"))); } } }
addLineBreaks
18,748
void (Document pomXml, Namespace pomNamespace) { Element rootElement = pomXml.getRootElement(); addLineBreaks(rootElement); Element buildElement = rootElement.getChild("build", pomNamespace); if (buildElement != null) { addLineBreaks(buildElement); } }
addLineBreaks
18,749
String (String effectiveXml, boolean isPom) { SAXBuilder builder = new SAXBuilder(); try { Document document = builder.build(new StringReader(effectiveXml)); Element rootElement = document.getRootElement(); // added namespaces Namespace pomNamespace = Namespace.getNamespace("", "http://maven.apache.org/POM/4.0.0"); rootElement.setNamespace(pomNamespace); Namespace xsiNamespace = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); rootElement.addNamespaceDeclaration(xsiNamespace); if (rootElement.getAttribute("schemaLocation", xsiNamespace) == null) { rootElement.setAttribute("schemaLocation", "http://maven.apache.org/POM/4.0.0 " + (isPom ? POM_XSD_URL : SETTINGS_XSD_URL), xsiNamespace); } ElementFilter elementFilter = new ElementFilter(Namespace.getNamespace("")); for (Iterator<Element> i = rootElement.getDescendants(elementFilter); i.hasNext(); ) { Element e = i.next(); e.setNamespace(pomNamespace); } addLineBreaks(document, pomNamespace); StringWriter w = new StringWriter(); Format format = Format.getRawFormat(); XMLOutputter out = new XMLOutputter(format); out.output(document.getRootElement(), w); return w.toString(); } catch (JDOMException | IOException e) { return effectiveXml; } }
addMavenNamespace
18,750
Set<Object> () { Set<Object> keys = super.keySet(); List<Object> list = new ArrayList<Object>(keys); Collections.sort(list, null); return new LinkedHashSet<Object>(list); }
keySet
18,751
MavenLeakDetector () { markShutdownHooks(); return this; }
mark
18,752
void () { markedHooks.putAll(getShutdownHooks()); }
markShutdownHooks
18,753
void () { checkShutdownHooks(); }
check
18,754
void () { IdentityHashMap<Thread, Thread> checkedHooks = new IdentityHashMap<Thread, Thread>(getShutdownHooks()); for (Thread t : markedHooks.values()) { checkedHooks.remove(t); } for (Thread t : checkedHooks.values()) { removeHook(t); } }
checkShutdownHooks
18,755
void (Thread thread) { Runtime.getRuntime().removeShutdownHook(thread); MavenServerGlobals.getLogger().print(String.format("ShutdownHook[%s] was removed to avoid memory leak", thread)); }
removeHook
18,756
MavenModel (Model model, File localRepository) { if(model.getBuild() == null) { model.setBuild(new Build()); } Build build = model.getBuild(); return convertModel(model, asSourcesList(build.getSourceDirectory()), asSourcesList(build.getTestSourceDirectory()), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), localRepository); }
convertModel
18,757
List<String> (String directory) { return directory == null ? Collections.emptyList() : Collections.singletonList(directory); }
asSourcesList
18,758
MavenModel (Model model, List<String> sources, List<String> testSources, Collection<? extends Artifact> dependencies, Collection<? extends DependencyNode> dependencyTree, Collection<? extends Artifact> extensions, File localRepository) { MavenModel result = new MavenModel(); result.setMavenId(new MavenId(model.getGroupId(), model.getArtifactId(), model.getVersion())); Parent parent = model.getParent(); if (parent != null) { result.setParent(new MavenParent(new MavenId(parent.getGroupId(), parent.getArtifactId(), parent.getVersion()), parent.getRelativePath())); } result.setPackaging(model.getPackaging()); result.setName(model.getName()); result.setProperties(model.getProperties() == null ? new Properties() : model.getProperties()); result.setPlugins(convertPlugins(model)); Map<Artifact, MavenArtifact> convertedArtifacts = new HashMap<Artifact, MavenArtifact>(); result.setExtensions(convertArtifacts(extensions, convertedArtifacts, localRepository)); result.setDependencies(convertArtifacts(dependencies, convertedArtifacts, localRepository)); result.setDependencyTree(convertDependencyNodes(null, dependencyTree, convertedArtifacts, localRepository)); result.setRemoteRepositories(convertRepositories(model.getRepositories())); result.setProfiles(convertProfiles(model.getProfiles())); result.setModules(model.getModules()); convertBuild(result.getBuild(), model.getBuild(), sources, testSources); return result; }
convertModel
18,759
void (MavenBuild result, Build build, List<String> sources, List<String> testSources) { convertBuildBase(result, build); result.setOutputDirectory(build.getOutputDirectory()); result.setTestOutputDirectory(build.getTestOutputDirectory()); result.setSources(sources); result.setTestSources(testSources); }
convertBuild
18,760
void (MavenBuildBase result, BuildBase build) { result.setFinalName(build.getFinalName()); result.setDefaultGoal(build.getDefaultGoal()); result.setDirectory(build.getDirectory()); result.setResources(convertResources(build.getResources())); result.setTestResources(convertResources(build.getTestResources())); result.setFilters(build.getFilters() == null ? Collections.emptyList() : build.getFilters()); }
convertBuildBase
18,761
MavenId (Artifact artifact) { return new MavenId(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()); }
createMavenId
18,762
List<MavenResource> (List<Resource> resources) { if (resources == null) return new ArrayList<MavenResource>(); List<MavenResource> result = new ArrayList<MavenResource>(resources.size()); for (Resource each : resources) { String directory = each.getDirectory(); if (null == directory) continue; result.add(new MavenResource(directory, each.isFiltering(), each.getTargetPath(), ensurePatterns(each.getIncludes()), ensurePatterns(each.getExcludes()))); } return result; }
convertResources
18,763
List<String> (List<String> patterns) { return patterns == null ? Collections.emptyList() : patterns; }
ensurePatterns
18,764
List<MavenRemoteRepository> (List<? extends Repository> repositories) { if (repositories == null) return new ArrayList<MavenRemoteRepository>(); List<MavenRemoteRepository> result = new ArrayList<MavenRemoteRepository>(repositories.size()); for (Repository each : repositories) { result.add(new MavenRemoteRepository(each.getId(), each.getName(), each.getUrl(), each.getLayout(), convertPolicy(each.getReleases()), convertPolicy(each.getSnapshots()))); } return result; }
convertRepositories
18,765
List<MavenRemoteRepository> (List<? extends ArtifactRepository> repositories) { if (repositories == null) return new ArrayList<MavenRemoteRepository>(); List<MavenRemoteRepository> result = new ArrayList<MavenRemoteRepository>(repositories.size()); for (ArtifactRepository each : repositories) { result.add(new MavenRemoteRepository(each.getId(), each.getId(), each.getUrl(), each.getLayout() != null ? each.getLayout().getId() : "default", convertPolicy(each.getReleases()), convertPolicy(each.getSnapshots()))); } return result; }
convertRemoteRepositories
18,766
List<MavenArtifact> (Collection<? extends Artifact> artifacts, Map<Artifact, MavenArtifact> nativeToConvertedMap, File localRepository) { if (artifacts == null) return new ArrayList<MavenArtifact>(); Set<MavenArtifact> result = new LinkedHashSet<MavenArtifact>(artifacts.size()); for (Artifact each : artifacts) { result.add(convertArtifact(each, nativeToConvertedMap, localRepository)); } return new ArrayList<MavenArtifact>(result); }
convertArtifacts
18,767
List<MavenArtifactNode> (MavenArtifactNode parent, Collection<? extends DependencyNode> nodes, Map<Artifact, MavenArtifact> nativeToConvertedMap, File localRepository) { List<MavenArtifactNode> result = new ArrayList<MavenArtifactNode>(nodes.size()); for (DependencyNode each : nodes) { Artifact a = each.getArtifact(); MavenArtifact ma = convertArtifact(a, nativeToConvertedMap, localRepository); MavenArtifactState state = MavenArtifactState.ADDED; switch (each.getState()) { case DependencyNode.INCLUDED: break; case DependencyNode.OMITTED_FOR_CONFLICT: state = MavenArtifactState.CONFLICT; break; case DependencyNode.OMITTED_FOR_DUPLICATE: state = MavenArtifactState.DUPLICATE; break; case DependencyNode.OMITTED_FOR_CYCLE: state = MavenArtifactState.CYCLE; break; default: assert false : "unknown dependency node state: " + each.getState(); } MavenArtifact relatedMA = each.getRelatedArtifact() == null ? null : convertArtifact(each.getRelatedArtifact(), nativeToConvertedMap, localRepository); MavenArtifactNode newNode = new MavenArtifactNode(parent, ma, state, relatedMA, each.getOriginalScope(), each.getPremanagedVersion(), each.getPremanagedScope()); newNode.setDependencies(convertDependencyNodes(newNode, each.getChildren(), nativeToConvertedMap, localRepository)); result.add(newNode); } return result; }
convertDependencyNodes
18,768
MavenArtifact (Artifact artifact, Map<Artifact, MavenArtifact> nativeToConvertedMap, File localRepository) { MavenArtifact result = nativeToConvertedMap.get(artifact); if (result == null) { result = convertArtifact(artifact, localRepository); nativeToConvertedMap.put(artifact, result); } return result; }
convertArtifact
18,769
MavenArtifact (Artifact artifact, File localRepository) { return new MavenArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getBaseVersion(), artifact.getType(), artifact.getClassifier(), artifact.getScope(), artifact.isOptional(), convertExtension(artifact), artifact.getFile(), localRepository, artifact.isResolved(), artifact instanceof CustomMaven3Artifact && ((CustomMaven3Artifact)artifact).isStub()); }
convertArtifact
18,770
String (Artifact artifact) { ArtifactHandler handler = artifact.getArtifactHandler(); String result = null; if (handler != null) result = handler.getExtension(); if (result == null) result = artifact.getType(); return result; }
convertExtension
18,771
List<MavenPlugin> (Model mavenModel) { List<MavenPlugin> result = new ArrayList<MavenPlugin>(); Build build = mavenModel.getBuild(); if (build != null) { List<Plugin> plugins = build.getPlugins(); if (plugins != null) { for (Plugin each : plugins) { result.add(convertPlugin(false, each)); } } } return result; }
convertPlugins
18,772
MavenPlugin (boolean isDefault, Plugin plugin) { List<MavenPlugin.Execution> executions = new ArrayList<MavenPlugin.Execution>(plugin.getExecutions().size()); for (PluginExecution each : plugin.getExecutions()) { executions.add(convertExecution(each)); } List<MavenId> deps = new ArrayList<MavenId>(plugin.getDependencies().size()); for (Dependency each : plugin.getDependencies()) { deps.add(new MavenId(each.getGroupId(), each.getArtifactId(), each.getVersion())); } return new MavenPlugin(plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), isDefault, "true".equals(plugin.getExtensions()), convertConfiguration(plugin.getConfiguration()), executions, deps); }
convertPlugin
18,773
Element (Object config) { return config == null ? null : xppToElement((Xpp3Dom)config); }
convertConfiguration
18,774
Element (Xpp3Dom xpp) { Element result; try { result = new Element(xpp.getName()); } catch (IllegalNameException e) { MavenServerGlobals.getLogger().info(e); return null; } Xpp3Dom[] children = xpp.getChildren(); if (children == null || children.length == 0) { result.setText(xpp.getValue()); } else { for (Xpp3Dom each : children) { Element child = xppToElement(each); if (child != null) result.addContent(child); } } return result; }
xppToElement
18,775
List<MavenProfile> (Collection<? extends Profile> profiles) { if (profiles == null) return Collections.emptyList(); List<MavenProfile> result = new ArrayList<MavenProfile>(); for (Profile each : profiles) { String id = each.getId(); if (id == null) continue; MavenProfile profile = new MavenProfile(id, each.getSource()); List<String> modules = each.getModules(); profile.setModules(modules == null ? Collections.emptyList() : modules); profile.setActivation(convertActivation(each.getActivation())); if (each.getBuild() != null) convertBuildBase(profile.getBuild(), each.getBuild()); result.add(profile); } return result; }
convertProfiles
18,776
MavenProfileActivation (Activation activation) { if (activation == null) return null; MavenProfileActivation result = new MavenProfileActivation(); result.setActiveByDefault(activation.isActiveByDefault()); result.setOs(convertOsActivation(activation.getOs())); result.setJdk(activation.getJdk()); result.setFile(convertFileActivation(activation.getFile())); result.setProperty(convertPropertyActivation(activation.getProperty())); return result; }
convertActivation
18,777
MavenProfileActivationOS (ActivationOS os) { return os == null ? null : new MavenProfileActivationOS(os.getName(), os.getFamily(), os.getArch(), os.getVersion()); }
convertOsActivation
18,778
MavenProfileActivationFile (ActivationFile file) { return file == null ? null : new MavenProfileActivationFile(file.getExists(), file.getMissing()); }
convertFileActivation
18,779
MavenProfileActivationProperty (ActivationProperty property) { return property == null ? null : new MavenProfileActivationProperty(property.getName(), property.getValue()); }
convertPropertyActivation
18,780
boolean (String toStringResult, Object o) { String className = o.getClass().getName(); return (toStringResult.startsWith(className) && toStringResult.startsWith("@", className.length())); }
isNativeToString
18,781
boolean (Class clazz) { return clazz.isArray() || Collection.class.isAssignableFrom(clazz) || Map.class.isAssignableFrom(clazz) || Xpp3Dom.class.isAssignableFrom(clazz); }
shouldSkip
18,782
Model (MavenModel model) { Model result = new Model(); result.setArtifactId(model.getMavenId().getArtifactId()); result.setGroupId(model.getMavenId().getGroupId()); result.setVersion(model.getMavenId().getVersion()); result.setPackaging(model.getPackaging()); result.setName(model.getName()); if (model.getParent() != null) { Parent parent = new Parent(); parent.setArtifactId(model.getParent().getMavenId().getArtifactId()); parent.setGroupId(model.getParent().getMavenId().getGroupId()); parent.setVersion(model.getParent().getMavenId().getVersion()); parent.setRelativePath(model.getParent().getRelativePath()); result.setParent(parent); } toNativeModelBase(model, result); result.setBuild(new Build()); MavenBuild modelBuild = model.getBuild(); toNativeBuildBase(modelBuild, result.getBuild()); result.getBuild().setOutputDirectory(modelBuild.getOutputDirectory()); result.getBuild().setTestOutputDirectory(modelBuild.getTestOutputDirectory()); if (modelBuild.getSources().size() > 1) throw new RuntimeException("too many source directories: " + modelBuild.getSources()); if (modelBuild.getTestSources().size() > 1) throw new RuntimeException("too many test directories: " + modelBuild.getTestSources()); if (modelBuild.getSources().size() == 1) { result.getBuild().setSourceDirectory(modelBuild.getSources().get(0)); } if (modelBuild.getTestSources().size() == 1) { result.getBuild().setTestSourceDirectory(modelBuild.getTestSources().get(0)); } result.setProfiles(toNativeProfiles(model.getProfiles())); return result; }
toNativeModel
18,783
List<Profile> (List<MavenProfile> profiles) { List<Profile> result = new ArrayList<Profile>(profiles.size()); for (MavenProfile each : profiles) { Profile p = new Profile(); p.setId(each.getId()); p.setSource(each.getSource()); p.setBuild(new Build()); p.setActivation(toNativeActivation(each.getActivation())); toNativeModelBase(each, p); toNativeBuildBase(each.getBuild(), p.getBuild()); result.add(p); } return result; }
toNativeProfiles
18,784
Activation (MavenProfileActivation activation) { if (activation == null) return null; Activation result = new Activation(); result.setActiveByDefault(activation.isActiveByDefault()); result.setJdk(activation.getJdk()); result.setOs(toNativeOsActivation(activation.getOs())); result.setFile(toNativeFileActivation(activation.getFile())); result.setProperty(toNativePropertyActivation(activation.getProperty())); return result; }
toNativeActivation
18,785
ActivationOS (MavenProfileActivationOS os) { if (os == null) return null; ActivationOS result = new ActivationOS(); result.setArch(os.getArch()); result.setFamily(os.getFamily()); result.setName(os.getName()); result.setVersion(os.getVersion()); return result; }
toNativeOsActivation
18,786
ActivationFile (MavenProfileActivationFile file) { if (file == null) return null; ActivationFile result = new ActivationFile(); result.setExists(file.getExists()); result.setMissing(file.getMissing()); return result; }
toNativeFileActivation
18,787
ActivationProperty (MavenProfileActivationProperty property) { if (property == null) return null; ActivationProperty result = new ActivationProperty(); result.setName(property.getName()); result.setValue(property.getValue()); return result; }
toNativePropertyActivation
18,788
void (MavenModelBase from, ModelBase to) { to.setModules(from.getModules()); to.setProperties(from.getProperties()); }
toNativeModelBase
18,789
void (MavenBuildBase from, BuildBase to) { to.setFinalName(from.getFinalName()); to.setDefaultGoal(from.getDefaultGoal()); to.setDirectory(from.getDirectory()); to.setFilters(from.getFilters()); to.setResources(toNativeResources(from.getResources())); to.setTestResources(toNativeResources(from.getTestResources())); }
toNativeBuildBase
18,790
List<Resource> (List<MavenResource> resources) { List<Resource> result = new ArrayList<Resource>(resources.size()); for (MavenResource each : resources) { Resource r = new Resource(); r.setDirectory(each.getDirectory()); r.setTargetPath(each.getTargetPath()); r.setFiltering(each.isFiltered()); r.setIncludes(each.getIncludes()); r.setExcludes(each.getExcludes()); result.add(r); } return result; }
toNativeResources
18,791
Repository (MavenRemoteRepository r) { Repository result = new Repository(); result.setId(r.getId()); result.setName(r.getName()); result.setUrl(r.getUrl()); result.setLayout(r.getLayout() == null ? "default" : r.getLayout()); if (r.getReleasesPolicy() != null) result.setReleases(toNativePolicy(r.getReleasesPolicy())); if (r.getSnapshotsPolicy() != null) result.setSnapshots(toNativePolicy(r.getSnapshotsPolicy())); return result; }
toNativeRepository
18,792
RepositoryPolicy (MavenRemoteRepository.Policy policy) { RepositoryPolicy result = new RepositoryPolicy(); result.setEnabled(policy.isEnabled()); result.setUpdatePolicy(policy.getUpdatePolicy()); result.setChecksumPolicy(policy.getChecksumPolicy()); return result; }
toNativePolicy
18,793
MavenArtifactInfo (ArtifactInfo a) { return new MavenArtifactInfo(a.groupId, a.artifactId, a.version, a.packaging, a.classifier, a.classNames, a.repository); }
convertArtifactInfo
18,794
MavenArchetype (Archetype archetype) { return new MavenArchetype(archetype.getGroupId(), archetype.getArtifactId(), archetype.getVersion(), archetype.getRepository(), archetype.getDescription()); }
convertArchetype
18,795
int (MavenToken token) { MavenServerUtil.checkToken(token); return myIndexer.getIndexingContexts().size(); }
getIndexCount
18,796
String (IndexingContext index) { File file = index.getRepository(); return file == null ? index.getRepositoryUrl() : file.getPath(); }
getRepositoryPathOrUrl
18,797
WagonTransferListenerAdapter (MavenServerProgressIndicator indicator) { return new WagonTransferListenerAdapter(indicator) { @Override protected void downloadProgress(long downloaded, long total) { super.downloadProgress(downloaded, total); try { myIndicator.setFraction(((double)downloaded) / total); } catch (RemoteException e) { throw new RuntimeRemoteException(e); } } @Override public void transferCompleted(TransferEvent event) { super.transferCompleted(event); try { myIndicator.setText2("Processing indices..."); } catch (RemoteException e) { throw new RuntimeRemoteException(e); } } }; }
getWagonTransferListenerAdapter
18,798
void (long downloaded, long total) { super.downloadProgress(downloaded, total); try { myIndicator.setFraction(((double)downloaded) / total); } catch (RemoteException e) { throw new RuntimeRemoteException(e); } }
downloadProgress
18,799
void (TransferEvent event) { super.transferCompleted(event); try { myIndicator.setText2("Processing indices..."); } catch (RemoteException e) { throw new RuntimeRemoteException(e); } }
transferCompleted