1111import java .util .List ;
1212import java .util .Map ;
1313import java .util .Map .Entry ;
14+ import java .util .Set ;
1415import java .util .concurrent .ExecutionException ;
1516import java .util .stream .Collectors ;
1617import java .util .stream .Stream ;
1718
18- import org .gradle .api .artifacts .PublishArtifact ;
19- import org .gradle .api .artifacts .PublishArtifactSet ;
19+ import org .gradle .api .artifacts .ResolvedArtifact ;
2020import org .gradle .api .file .FileCollection ;
2121import org .gradle .api .logging .Logger ;
2222import org .jboss .jandex .CompositeIndex ;
@@ -34,23 +34,20 @@ public GradleDependencyIndexCreator(Logger logger) {
3434 this .logger = logger ;
3535 }
3636
37- IndexView createIndex (PublishArtifactSet allArtifacts , FileCollection classesDirs )
37+ IndexView createIndex (Set < ResolvedArtifact > dependencies , FileCollection classesDirs )
3838 throws Exception {
39- List <Entry <PublishArtifact , Duration >> indexDurations = new ArrayList <>();
40- List <PublishArtifact > artifacts = new ArrayList <>();
41- if (allArtifacts != null ) {
42- artifacts .addAll (allArtifacts );
43- }
39+
40+ List <Entry <ResolvedArtifact , Duration >> indexDurations = new ArrayList <>();
4441 List <IndexView > indexes = new ArrayList <>();
4542
4643 for (File f : classesDirs .getFiles ()) {
4744 indexes .add (indexModuleClasses (f ));
4845 }
4946
50- for (PublishArtifact artifact : artifacts ) {
47+ for (ResolvedArtifact artifact : dependencies ) {
5148 try {
5249 if (artifact .getFile ().isDirectory ()) {
53- // Don't cache local worskpace artifacts. Incremental compilation in IDE's would
50+ // Don't cache local workspace artifacts. Incremental compilation in IDE's would
5451 // otherwise use the cached index instead of new one.
5552 // Right now, support for incremental compilation inside eclipse is blocked by:
5653 // https://github.com/eclipse-m2e/m2e-core/issues/364#issuecomment-939987848
@@ -70,30 +67,29 @@ IndexView createIndex(PublishArtifactSet allArtifacts, FileCollection classesDir
7067 return CompositeIndex .create (indexes );
7168 }
7269
73- private Index index (PublishArtifact artifact ) throws IOException {
70+ private Index index (ResolvedArtifact artifact ) throws IOException {
7471 Result result = JarIndexer .createJarIndex (artifact .getFile (), new Indexer (), false ,
7572 false , false );
7673 return result .getIndex ();
7774 }
7875
79- private void printIndexDurations (List <Map .Entry <PublishArtifact , Duration >> indexDurations ) {
76+ private void printIndexDurations (List <Map .Entry <ResolvedArtifact , Duration >> indexDurations ) {
8077 if (logger .isDebugEnabled ()) {
8178 indexDurations .sort (Map .Entry .comparingByValue ());
8279
8380 indexDurations .forEach (e -> {
8481 if (e .getValue ().toMillis () > 25 ) {
85- PublishArtifact artifact = e .getKey ();
86- logger .debug ("Indexing took {} for {}, {}, {}, {}, {}, {}" , e .getValue (), artifact .getName (),
87- artifact .getExtension (), artifact .getClassifier (), artifact .getType (), artifact .getDate (),
88- artifact .getFile ());
82+ ResolvedArtifact artifact = e .getKey ();
83+ logger .debug ("Indexing took {} for {}, {}, {}, {}, {}" , e .getValue (), artifact .getName (),
84+ artifact .getExtension (), artifact .getClassifier (), artifact .getType (), artifact .getFile ());
8985 }
9086 });
9187 }
9288 }
9389
9490 private IndexView timedIndex (
95- List <Map .Entry <PublishArtifact , Duration >> indexDurations ,
96- PublishArtifact artifact ) throws Exception {
91+ List <Map .Entry <ResolvedArtifact , Duration >> indexDurations ,
92+ ResolvedArtifact artifact ) throws Exception {
9793 LocalDateTime start = LocalDateTime .now ();
9894 IndexView result = index (artifact );
9995 LocalDateTime end = LocalDateTime .now ();
@@ -102,7 +98,7 @@ private IndexView timedIndex(
10298 return result ;
10399 }
104100
105- private Index indexModuleClasses (PublishArtifact artifact ) throws IOException {
101+ private Index indexModuleClasses (ResolvedArtifact artifact ) throws IOException {
106102 return indexModuleClasses (artifact .getFile ());
107103 }
108104
0 commit comments