Skip to content

880 adhere to m2settings securityxml and m2settingsxml #986

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

Merged
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
3 changes: 0 additions & 3 deletions .github/workflows/build-sbm-revamp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ jobs:
working-directory: sbm-support-rewrite
run: mvn --batch-mode clean install

- name: clean install skipTests
run: mvn clean install -DskipTests

- name: clean
run: mvn clean

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ out/
pom.xml.versionsBackup
**/src/generated/java/META-INF
**.java-version
.rewrite-cache
.rewrite-cache
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration;
import org.springframework.sbm.build.impl.MavenBuildFileRefactoringFactory;
import org.springframework.sbm.build.impl.MavenSettingsInitializer;
import org.springframework.sbm.parsers.maven.MavenSettingsInitializer;
import org.springframework.sbm.build.impl.RewriteMavenParser;
import org.springframework.sbm.engine.context.ProjectContextHolder;
import org.springframework.sbm.engine.context.RewriteJavaSearchActionDeserializer;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import org.springframework.sbm.build.migration.visitor.AddOrUpdateDependencyManagement;
import org.springframework.sbm.java.impl.ClasspathRegistry;
import org.springframework.sbm.project.resource.RewriteSourceFileHolder;
import org.springframework.sbm.parsers.RewriteMavenArtifactDownloader;
import org.springframework.sbm.parsers.maven.RewriteMavenArtifactDownloader;
import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe;
import org.springframework.util.Assert;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
import org.openrewrite.SourceFile;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.maven.MavenParser;
import org.openrewrite.xml.XmlParser;
import org.openrewrite.xml.tree.Xml;
import org.springframework.sbm.parsers.maven.MavenSettingsInitializer;
import org.springframework.stereotype.Component;

import java.nio.file.Path;
import java.util.List;
import java.util.stream.Stream;

/**
Expand Down Expand Up @@ -76,7 +74,7 @@ public Stream<SourceFile> parse(String... sources) {

@Override
public Stream<SourceFile> parse(ExecutionContext ctx, String... sources) {
mavenSettingsInitializer.initializeMavenSettings(ctx);
mavenSettingsInitializer.initializeMavenSettings();
return parser.parse(ctx, sources);
}

Expand All @@ -90,7 +88,7 @@ public Stream<SourceFile> parseInputs(Iterable<Input> sources, @Nullable Path re
if (relativeTo != null) {
initMavenParser(ctx, relativeTo);
} else {
mavenSettingsInitializer.initializeMavenSettings(ctx);
mavenSettingsInitializer.initializeMavenSettings();
}
return parser.parseInputs(sources, relativeTo, ctx);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.springframework.sbm.build.impl.RewriteMavenParser;
import org.springframework.sbm.engine.context.ProjectContext;
import org.springframework.sbm.engine.recipe.AbstractAction;
import org.springframework.sbm.parsers.RewriteMavenArtifactDownloader;
import org.springframework.sbm.parsers.maven.RewriteMavenArtifactDownloader;

import java.io.ByteArrayInputStream;
import java.io.StringWriter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.springframework.sbm.build.impl.MavenBuildFileRefactoring;
import org.springframework.sbm.build.impl.MavenBuildFileRefactoringFactory;
import org.springframework.sbm.build.impl.OpenRewriteMavenBuildFile;
import org.springframework.sbm.parsers.RewriteMavenArtifactDownloader;
import org.springframework.sbm.parsers.maven.RewriteMavenArtifactDownloader;
import org.springframework.sbm.project.resource.ProjectResourceWrapper;
import org.springframework.sbm.project.resource.RewriteSourceFileHolder;
import org.springframework.stereotype.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.openrewrite.maven.tree.Scope;
import org.springframework.sbm.build.api.BuildFile;
import org.springframework.sbm.build.impl.OpenRewriteMavenBuildFile;
import org.springframework.sbm.parsers.RewriteMavenArtifactDownloader;
import org.springframework.sbm.parsers.maven.RewriteMavenArtifactDownloader;
import org.springframework.sbm.project.parser.DependencyHelper;

import java.nio.file.Path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.springframework.core.io.FileSystemResource;
import org.springframework.sbm.boot.autoconfigure.SbmSupportRewriteConfiguration;
import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration;
import org.springframework.sbm.build.impl.MavenSettingsInitializer;
import org.springframework.sbm.parsers.maven.MavenSettingsInitializer;
import org.springframework.sbm.engine.commands.ApplicableRecipeListCommand;
import org.springframework.sbm.engine.commands.ApplyCommand;
import org.springframework.sbm.engine.commands.ScanCommand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
import org.openrewrite.maven.tree.ResolvedDependency;
import org.openrewrite.maven.tree.Scope;
import org.openrewrite.xml.tree.Xml;
import org.springframework.sbm.build.impl.MavenSettingsInitializer;
import org.springframework.sbm.build.impl.RewriteMavenParser;
import org.springframework.sbm.parsers.RewriteExecutionContext;
import org.springframework.sbm.parsers.maven.MavenSettingsInitializer;
import org.springframework.sbm.scopes.ProjectMetadata;

import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -105,7 +106,7 @@ void classpathRegistryShouldKeepOnlyExternalDependencies() {

ExecutionContext executionContext = new RewriteExecutionContext();
List<Xml.Document> poms = new RewriteMavenParser(
new MavenSettingsInitializer(),
new MavenSettingsInitializer(executionContext, new ProjectMetadata()),
executionContext
).parse(parentPom, pom1, pom2)
.map(Xml.Document.class::cast)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@

import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Test;
import org.openrewrite.ExecutionContext;
import org.openrewrite.java.marker.JavaProject;
import org.openrewrite.java.marker.JavaVersion;
import org.openrewrite.marker.BuildTool;
import org.openrewrite.marker.Marker;
import org.openrewrite.xml.tree.Xml;
import org.springframework.sbm.build.impl.MavenSettingsInitializer;
import org.springframework.sbm.build.impl.RewriteMavenParser;
import org.springframework.sbm.parsers.RewriteExecutionContext;
import org.springframework.sbm.parsers.maven.MavenSettingsInitializer;
import org.springframework.sbm.scopes.ProjectMetadata;

import java.nio.file.Path;
import java.util.List;
Expand Down Expand Up @@ -63,7 +65,8 @@ void test() {
"</project>";

Path projectDirectory = Path.of("./faked-project-dir/pom.xml");
Xml.Document maven = new RewriteMavenParser(new MavenSettingsInitializer(), new RewriteExecutionContext()).parse(pomXmlSource).toList().get(0).withSourcePath(Path.of("pom.xml"));
ExecutionContext executionContext = new RewriteExecutionContext();
Xml.Document maven = new RewriteMavenParser(new MavenSettingsInitializer(executionContext, new ProjectMetadata()), executionContext).parse(pomXmlSource).toList().get(0).withSourcePath(Path.of("pom.xml"));

List<Marker> javaProvenanceMarkers = sut.createJavaProvenanceMarkers(maven, projectDirectory, new RewriteExecutionContext());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration;
import org.springframework.sbm.build.impl.MavenSettingsInitializer;
import org.springframework.sbm.parsers.maven.MavenSettingsInitializer;
import org.springframework.sbm.build.impl.RewriteMavenParser;
import org.springframework.sbm.build.migration.MavenPomCacheProvider;
import org.springframework.sbm.engine.commands.ScanCommand;
Expand Down Expand Up @@ -64,7 +64,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.sbm.project.parser.ResourceVerifierTestHelper.*;
import org.springframework.sbm.parsers.RewriteMavenArtifactDownloader;
import org.springframework.sbm.parsers.maven.RewriteMavenArtifactDownloader;

@SpringBootTest(classes = {
ProjectContextInitializer.class,
Expand Down

This file was deleted.

2 changes: 2 additions & 0 deletions sbm-support-rewrite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/testcode/**/target/**
/testcode/**/.rewrite-cache/**
26 changes: 25 additions & 1 deletion sbm-support-rewrite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-cipher</artifactId>
<version>${plexus-cypher.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
Expand All @@ -249,6 +248,31 @@
<version>${junit-pioneer.version}</version>
<scope>test</scope>
</dependency>
<!-- Required by PrivateArtifactRepositoryTest -->
<!-- TODO: Move into separate module -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.10.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-core</artifactId>
<version>2.0.9</version>
<scope>test</scope>
</dependency>
<!-- END: Required by PrivateArtifactRepositoryTest -->
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

import org.openrewrite.ExecutionContext;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.java.AddOrUpdateAnnotationAttribute;
import org.openrewrite.maven.MavenExecutionContextView;
import org.openrewrite.maven.cache.MavenPomCache;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfiguration;
Expand Down Expand Up @@ -74,9 +72,6 @@ Supplier<ExecutionContext> executionContextSupplier() {
@org.springframework.sbm.scopes.annotations.ScanScope
ExecutionContext executionContext(ProjectMetadata projectMetadata, Supplier<ExecutionContext> executionContextSupplier, MavenPomCache mavenPomCache) {
ExecutionContext executionContext = executionContextSupplier.get();
MavenExecutionContextView contextView = MavenExecutionContextView.view(executionContext);
contextView.setMavenSettings(projectMetadata.getMavenSettings());
contextView.setPomCache(mavenPomCache);
return executionContext;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import lombok.extern.slf4j.Slf4j;
import org.openrewrite.ExecutionContext;
import org.openrewrite.maven.MavenExecutionContextView;
import org.openrewrite.maven.cache.*;
import org.openrewrite.maven.utilities.MavenArtifactDownloader;
import org.openrewrite.tree.ParsingEventListener;
Expand All @@ -34,13 +33,11 @@
import org.springframework.sbm.parsers.events.RewriteParsingEventListenerAdapter;
import org.springframework.sbm.parsers.maven.*;
import org.springframework.sbm.project.resource.SbmApplicationProperties;
import org.springframework.sbm.scopes.ProjectMetadata;
import org.springframework.sbm.scopes.ScanScope;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.function.Consumer;


Expand All @@ -52,19 +49,9 @@
@Slf4j
@AutoConfiguration(after = {ScopeConfiguration.class})
@EnableConfigurationProperties({ParserProperties.class, SbmApplicationProperties.class})
@Import({ScanScope.class, ScopeConfiguration.class})
@Import({ScanScope.class, ScopeConfiguration.class, RewriteParserMavenConfiguration.class})
public class RewriteParserConfiguration {

@Bean
MavenPasswordDecrypter mavenPasswordDecrypter() {
return new MavenPasswordDecrypter();
}

@Bean
MavenProvenanceMarkerFactory mavenProvenanceMarkerFactory() {
return new MavenProvenanceMarkerFactory();
}

@Bean
ProvenanceMarkerFactory provenanceMarkerFactory(MavenProvenanceMarkerFactory mavenPovenanceMarkerFactory) {
return new ProvenanceMarkerFactory(mavenPovenanceMarkerFactory);
Expand All @@ -76,38 +63,19 @@ JavaParserBuilder javaParserBuilder() {
return new JavaParserBuilder();
}

@Bean
BuildFileParser buildFileParser() {
return new BuildFileParser();
}


@Bean
@ConditionalOnMissingBean(MavenArtifactCache.class)
MavenArtifactCache mavenArtifactCache() {
return new LocalMavenArtifactCache(Paths.get(System.getProperty("user.home"), ".m2", "repository")).orElse(
new LocalMavenArtifactCache(Paths.get(System.getProperty("user.home"), ".rewrite", "cache", "artifacts"))
);
}

@Bean
Consumer<Throwable> artifactDownloaderErrorConsumer() {
return (t) -> {throw new RuntimeException(t);};
}

@Bean
RewriteMavenArtifactDownloader artifactDownloader(MavenArtifactCache mavenArtifactCache, ProjectMetadata projectMetadata, Consumer<Throwable> artifactDownloaderErrorConsumer) {
return new RewriteMavenArtifactDownloader(mavenArtifactCache, projectMetadata.getMavenSettings(), artifactDownloaderErrorConsumer);
}

@Bean
ModuleParser helperWithoutAGoodName() {
ModuleParser moduleParser() {
return new ModuleParser();
}

@Bean
MavenModuleParser mavenModuleParser(ParserProperties parserPropeties, ModuleParser moduleParser) {
return new MavenModuleParser(parserPropeties, moduleParser);
MavenModuleParser mavenModuleParser(ParserProperties parserProperties, ModuleParser moduleParser) {
return new MavenModuleParser(parserProperties, moduleParser);
}

@Bean
Expand Down
Loading