Skip to content

Commit

Permalink
Merge pull request #12 from nebula-plugins/ConfigurableInMemoryProces…
Browse files Browse the repository at this point in the history
…sing

Add extension configuration to enable in memory processing on demand instead of enabled always, it helps workaround certain jar format issues but can cause out of memory for big jars so cannot be enabled all the time
  • Loading branch information
chali authored Aug 16, 2023
2 parents aaa1c28 + e291c65 commit 0f6691a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public open class JakartaEeMigrationExtension(
private val configuredCapabilities = AtomicBoolean()
private val registeredTransform = AtomicBoolean()
private val excludeSpecificationsTransform = AtomicBoolean()
private val transformInMemory = AtomicBoolean()
private val preventTransformOfProductionConfigurations = AtomicBoolean()
private val included = mutableListOf<ArtifactCoordinate>()
private val excluded = mutableListOf<ArtifactCoordinate>()
Expand Down Expand Up @@ -304,8 +305,16 @@ public open class JakartaEeMigrationExtension(
.attribute(ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.JAR_TYPE)
parameters.setIncludedArtifacts(included)
parameters.setExcludedArtifacts(excluded)
parameters.setTransformInMemory(transformInMemory)
}
}
}
}

/**
* Enables inmemory zip processing for migration tool.
*/
public fun transformInMemory() {
transformInMemory.set(true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.slf4j.LoggerFactory
import java.io.FileNotFoundException
import java.io.UncheckedIOException
import java.nio.file.Files
import java.util.concurrent.atomic.AtomicBoolean
import java.util.logging.Handler
import java.util.logging.Level
import java.util.logging.LogRecord
Expand All @@ -55,6 +56,10 @@ internal abstract class JakartaEeMigrationTransform : TransformAction<JakartaEeM
@Input
fun getIncludedArtifacts(): List<ArtifactCoordinate>
fun setIncludedArtifacts(includedArtifact: List<ArtifactCoordinate>)

@Input
fun getTransformInMemory(): AtomicBoolean
fun setTransformInMemory(transformInMemory: AtomicBoolean)
}

companion object {
Expand Down Expand Up @@ -83,6 +88,10 @@ internal abstract class JakartaEeMigrationTransform : TransformAction<JakartaEeM
parameters.getIncludedArtifacts().toPaths()
}

private val transformInMemory by lazy {
parameters.getTransformInMemory().get()
}

private fun List<ArtifactCoordinate>.toPaths() = flatMap {
listOf(
"/${it.group}/${it.name}/", // Ivy repository layout. Gradle module cache
Expand Down Expand Up @@ -116,7 +125,7 @@ internal abstract class JakartaEeMigrationTransform : TransformAction<JakartaEeM
migration.setDestination(tempFilePath.toFile())
migration.eeSpecProfile = EESpecProfiles.EE
migration.setEnableDefaultExcludes(false)
migration.setZipInMemory(true)
migration.setZipInMemory(transformInMemory)

migration.execute()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ dependencies {
dependencies {
implementation 'org.projectlombok:lombok:1.18.28'
}
jakartaeeMigration {
transformInMemory()
}
"""
when:
Expand Down

0 comments on commit 0f6691a

Please sign in to comment.