Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
13c0656
feat(QTDI-693): expose nested repository member
undx Dec 17, 2024
b52c305
feat(QTDI-693): allow nested jar as root repository
undx Dec 17, 2024
c079f78
feat(QTDI-693): classes across many scanning.properties
undx Dec 17, 2024
b2386f1
feat(QTDI-693): classes across many scanning.properties
undx Dec 17, 2024
e34c77c
feat(QTDI-693): include nested jars in getURLs
undx Dec 17, 2024
fb44b73
feat(QTDI-693): include nested jars in getURLs
undx Dec 17, 2024
409e850
feat(QTDI-693): fix test
undx Dec 17, 2024
940ab2b
Merge branch 'master' into undx/QTDI-693-runtime-fix
undx Jan 9, 2025
5667ddb
Merge branch 'master' into undx/QTDI-693-runtime-fix
undx Jan 21, 2025
f2bad61
feat(QTDI-675): pr comment
undx Jan 27, 2025
a003c2a
Merge branch 'master' into undx/QTDI-693-runtime-fix
undx Feb 5, 2025
1cfe2a6
Merge branch 'master' into undx/QTDI-693-runtime-fix
undx Jul 16, 2025
29cdac2
Merge branch 'master' into undx/QTDI-693-runtime-fix
undx Jul 21, 2025
f712899
Merge branch 'master' into undx/QTDI-693-runtime-fix
undx Aug 1, 2025
ed2e3f5
chore(QTDI-1826): unblock github action check (#1079)
ozhelezniak-talend Aug 4, 2025
d6b1284
feat(QTDI-113): Support Java 17 compilation (#from:936) (#1061)
yyin-talend Aug 4, 2025
be33a6a
fix(QTDI-1838): register ContainerFinder for studio (#1081)
ozhelezniak-talend Aug 5, 2025
8b9c01d
chore(QTDI-1859): improve CI build (#1084)
ozhelezniak-talend Aug 5, 2025
234cb50
feat(QTDI-693): add plugins.properties location property
undx Aug 5, 2025
bc8f215
Merge branch 'master' into undx/QTDI-693-runtime-fix
undx Aug 5, 2025
ade85f7
feat(QTDI-693): fix path for plugins.properties location propert
undx Aug 5, 2025
a4ec4b3
feat(QTDI-693): fix property name
undx Aug 5, 2025
2b28520
feat(QTDI-693): remove duplicate info log
undx Aug 7, 2025
f63c3df
Merge branch 'master' into undx/QTDI-693-runtime-fix
undx Aug 7, 2025
c87bc43
Merge branch 'master' into undx/QTDI-693-runtime-fix
ypiel-talend Aug 18, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
import static org.talend.sdk.component.runtime.manager.reflect.Constructors.findConstructor;
import static org.talend.sdk.component.runtime.manager.util.Lazy.lazy;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.lang.annotation.Annotation;
Expand Down Expand Up @@ -1303,16 +1305,42 @@ public void onCreate(final Container container) {
try {
String alreadyScannedClasses = null;
Filter filter = KnownClassesFilter.INSTANCE;
try (final InputStream containerFilterConfig =
container.getLoader().getResourceAsStream("TALEND-INF/scanning.properties")) {
if (containerFilterConfig != null) {
// we need to scan the nested repository
if (container.hasNestedRepository()) {
try {
final Enumeration<URL> urls = loader.getResources("TALEND-INF/scanning.properties");
final Properties config = new Properties();
config.load(containerFilterConfig);
filter = createScanningFilter(config);
alreadyScannedClasses = config.getProperty("classes.list");
while (urls.hasMoreElements()) {
final URL url = urls.nextElement();
// ensure we scan the correct classes of plugin in the nested repository
if ("nested".equals(url.getProtocol())
&& url.getPath().contains(container.getRootModule())) {
try (final BufferedReader reader =
new BufferedReader(new InputStreamReader(url.openStream()))) {
config.load(reader);
filter = createScanningFilter(config);
alreadyScannedClasses = config.getProperty("classes.list");
break;
}
}
}
} catch (IOException e) {
log.info("[onCreate] Can't read nested scanning.properties: {}", e.getMessage());
}
}
// normal scanning or nested scan failed
if (alreadyScannedClasses == null) {
try (final InputStream containerFilterConfig =
container.getLoader().getResourceAsStream("TALEND-INF/scanning.properties")) {
if (containerFilterConfig != null) {
final Properties config = new Properties();
config.load(containerFilterConfig);
filter = createScanningFilter(config);
alreadyScannedClasses = config.getProperty("classes.list");
}
} catch (final IOException e) {
log.debug(e.getMessage(), e);
}
} catch (final IOException e) {
log.debug(e.getMessage(), e);
}

AnnotationFinder optimizedFinder = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,11 @@ void extendFamilyInNestedRepo(@TempDir final File temporaryFolder) throws Except
.of(container.getLoader().getURLs())
.map(Files::toFile)
.map(File::getName)
.sorted()
.sorted() // !! for asserts
.toArray(String[]::new);
assertEquals(1, dependencies.length); // ignored transitive deps, enables the new root to control it
assertEquals("main.jar", dependencies[0]); // transitive-1.0.0.jar is nested
assertEquals(2, dependencies.length); // ignored transitive deps, enables the new root to control it
assertEquals("fatjar.jar", dependencies[0]); // transitive-1.0.0.jar is nested
assertEquals("main.jar", dependencies[1]); // main.jar containing fatjar.jar
} finally {
if (!transitive.delete()) {
transitive.deleteOnExit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public class ConfigurableClassLoader extends URLClassLoader {
@Getter
private final List<String> cacheableClasses;

private List<URL> nestedURLs = new ArrayList<>();
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field should be declared as final since it's initialized once and never reassigned. Consider making it final for better immutability.

Suggested change
private List<URL> nestedURLs = new ArrayList<>();
private final List<URL> nestedURLs = new ArrayList<>();

Copilot uses AI. Check for mistakes.

public ConfigurableClassLoader(final String id, final URL[] urls, final ClassLoader parent,
final Predicate<String> parentFilter, final Predicate<String> childFirstFilter,
final String[] nestedDependencies, final String[] jvmPrefixes) {
Expand Down Expand Up @@ -155,6 +157,7 @@ private void loadNestedDependencies(final ClassLoader parent, final String[] nes
if (url == null) {
throw new IllegalArgumentException("Didn't find " + resource + " in " + asList(nestedDependencies));
}
nestedURLs.add(url);
final Map<String, Resource> resources = new HashMap<>();
final URLConnection urlConnection;
final Manifest manifest;
Expand Down Expand Up @@ -458,6 +461,15 @@ public Enumeration<URL> findResources(final String name) throws IOException {
return enumeration(aggregated);
}

@Override
public URL[] getURLs() {
final List<URL> urls = new ArrayList<>(Arrays.asList(super.getURLs()));
if (!nestedURLs.isEmpty()) {
urls.addAll(nestedURLs);
}
return urls.toArray(new URL[0]);
}

private boolean isNestedDependencyResource(final String name) {
return name != null && name.startsWith(NESTED_MAVEN_REPOSITORY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ public Date getCreated() {
return created.get();
}

public boolean hasNestedRepository() {
return hasNestedRepository;
}

public void registerTransformer(final ClassFileTransformer transformer) {
transformers.add(transformer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
Expand Down Expand Up @@ -110,16 +112,23 @@ public ContainerManager(final DependenciesResolutionConfiguration dependenciesRe
this.logInfoLevelMapping = logInfoLevelMapping;
this.containerInitializer = containerInitializer;
this.resolver = dependenciesResolutionConfiguration.getResolver();
this.rootRepositoryLocation = ofNullable(dependenciesResolutionConfiguration.getRootRepositoryLocation())
.filter(Files::exists)
.orElseGet(() -> PathFactory.get(System.getProperty("user.home", "")).resolve(".m2/repository"));

if (log.isDebugEnabled()) {
log.debug("Using root repository: " + this.rootRepositoryLocation.toAbsolutePath());
Path rootRepo = ofNullable(dependenciesResolutionConfiguration.getRootRepositoryLocation())
.filter(Files::exists)
.orElseGet(() -> PathFactory.get(System.getProperty("user.home")).resolve(".m2/repository"));
// if we've defaulted to user home m2 (fallback), we want to check if we're in running in a fatjar
if (PathFactory.get(System.getProperty("user.home")).resolve(".m2/repository").equals(rootRepo)) {
final URL nested = classLoaderConfiguration.getParent().getResource("MAVEN-INF/repository");
if (nested != null) {
rootRepo = Paths.get(nested.getFile().replace("file:", ""));
}
}

this.rootRepositoryLocation = rootRepo;
info("Using root repository: " + this.rootRepositoryLocation.toAbsolutePath());
final String pluginsLocation = System.getProperty("talend.component.manager.plugins.location",
"TALEND-INF/plugins.properties");
final String nestedPluginMappingResource = ofNullable(classLoaderConfiguration.getNestedPluginMappingResource())
.orElse("TALEND-INF/plugins.properties");
.orElse(pluginsLocation);
this.classLoaderConfiguration = new ClassLoaderConfiguration(
ofNullable(classLoaderConfiguration.getParent()).orElseGet(ContainerManager.class::getClassLoader),
ofNullable(classLoaderConfiguration.getClassesFilter()).orElseGet(() -> name -> true),
Expand Down Expand Up @@ -477,8 +486,8 @@ public Container create() {
? nestedContainerMapping.getOrDefault(module, module)
: module;
final Path resolved = resolve(moduleLocation);
info("Creating module " + moduleLocation + " (from " + module
+ (Files.exists(resolved) ? ", location=" + resolved.toAbsolutePath().toString() : "") + ")");
info(String.format("Creating module %s (from %s, location=%s)", moduleLocation, module,
resolved.toAbsolutePath()));
final Stream<Artifact> classpath = Stream
.concat(getBuiltInClasspath(moduleLocation),
additionalClasspath == null ? Stream.empty() : additionalClasspath.stream());
Expand Down
Loading