Skip to content

Commit

Permalink
Merge pull request #6 from dcm4che/dev
Browse files Browse the repository at this point in the history
Fix some OSGi bugs and add better IntelliJ support
  • Loading branch information
Nirostar committed Apr 26, 2023
2 parents 0583cf3 + 5ad65be commit 9cd4f7c
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 10 deletions.
29 changes: 24 additions & 5 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repositories {

```groovy
dependencies {
implementation 'org.dcm4che:dcm4che-typeddicom-lib-std:0.5.0'
implementation 'org.dcm4che:dcm4che-typeddicom-lib-std:0.5.1'
}
```

Expand All @@ -41,7 +41,7 @@ repositories {

```kotlin
dependencies {
implementation("org.dcm4che:dcm4che-typeddicom-lib-std:0.5.0")
implementation("org.dcm4che:dcm4che-typeddicom-lib-std:0.5.1")
}
```

Expand All @@ -60,16 +60,25 @@ dependencies {
<dependency>
<groupId>org.dcm4che</groupId>
<artifactId>dcm4che-typeddicom</artifactId>
<version>0.5.0</version>
<version>0.5.1</version>
</dependency>
```
### Use private tags with the gradle plugin

In the ```build.gradle``` put:
```groovy
buildscript {
repositories {
// Add dicom4che repository
maven {
url "https://www.dcm4che.org/maven2/"
}
}
}
plugins {
id 'java-library'
id 'org.dcm4che.typeddicom-java-generator' version '0.5.0'
id 'org.dcm4che.typeddicom-java-generator' version '0.5.1'
}
generateTypeddicomJavaSources {
Expand All @@ -79,10 +88,20 @@ generateTypeddicomJavaSources {
```
or put this into ```build.gradle.kts```:
```kotlin
buildscript {
repositories {
// Add dicom4che repository
maven {
url = uri("https://www.dcm4che.org/maven2/")
}
}
}

plugins {
id("java-library")
id("org.dcm4che.typeddicom-java-generator") version "0.5.0"
id("org.dcm4che.typeddicom-java-generator") version "0.5.1"
}

generateTypeddicomJavaSources {
privateDicomMetamodelYamlDirectory.set(layout.projectDirectory.dir("src/main/resources")) // default - so this is optional when using this directory
generatedJavaOutputDirectory.set(layout.buildDirectory.dir("typeddicom")) // default - so this is optional when using this directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.gradle.api.Project;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.plugins.ide.idea.model.IdeaModel;

public class TypeddicomJavaGeneratorPlugin implements Plugin<Project> {
public void apply(final Project target) {
Expand All @@ -16,12 +17,18 @@ public void apply(final Project target) {
task.getPrivateDicomMetamodelYamlDirectory().set(extension.getPrivateDicomMetamodelYamlDirectory());
task.getGeneratedJavaOutputDirectory().set(extension.getGeneratedJavaOutputDirectory());
});

target.getPluginManager().withPlugin("java-library", javaPlugin -> {
SourceSetContainer sourceSets = target.getExtensions().getByType(SourceSetContainer.class);
sourceSets.named("main", sourceSet -> sourceSet.getJava().srcDir(generateJavaSourcesFileTaskProvider));
String version = TypeddicomJavaGeneratorPlugin.class.getPackage().getImplementationVersion();
target.getDependencies().add("api", "org.dcm4che:dcm4che-typeddicom-skeleton:" + version);
target.getDependencies().add("implementation", "org.dcm4che:dcm4che-core");
});

target.getPluginManager().withPlugin("idea", ideaPlugin -> {
IdeaModel ideaModel = target.getExtensions().getByType(IdeaModel.class);
ideaModel.getModule().getGeneratedSourceDirs().add(extension.getGeneratedJavaOutputDirectory().getAsFile().get());
});
}
}
14 changes: 10 additions & 4 deletions dcm4che-typeddicom-lib/dcm4che-typeddicom-lib-std/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,24 @@ tasks.test {
useJUnitPlatform()
}

// Remove non-numeric version info for Bundle version
val bundleVersion = "$version".replace(Regex(".*(\\d+\\.\\d+\\.\\d+).*"), "$1")

tasks.withType<Jar> {
manifest {
attributes["Manifest-Version"] = "1.0"
attributes["Bundle-ManifestVersion"] = "2"
attributes["Bundle-Name"] = "org.dcm4che.typeddicom"
attributes["Bundle-SymbolicName"] = "org.dcm4che.typeddicom;singleton:=true"
attributes["Bundle-Version"] = version
attributes["Bundle-Name"] = "org.dcm4che.dcm4che-typeddicom-lib-std"
attributes["Bundle-SymbolicName"] = "org.dcm4che.dcm4che-typeddicom-lib-std;singleton:=true"
attributes["Bundle-Version"] = bundleVersion
attributes["Bundle-Vendor"] = "dcm4che"
attributes["Bundle-ClassPath"] = "."
attributes["Bundle-ActivationPolicy"] = "lazy"
attributes["Require-Bundle"] =
"org.dcm4che.dcm4che-typeddicom-skeleton; bundle-version=\"${bundleVersion}\"; visibility:=reexport"
attributes["Export-Package"] =
"org.dcm4che.typeddicom, org.dcm4che.typeddicom.dataelements, org.dcm4che.typeddicom.iods, org.dcm4che.typeddicom.modules, org.dcm4che.typeddicom.valuerepresentations"
"org.dcm4che.typeddicom, org.dcm4che.typeddicom.dataelements, org.dcm4che.typeddicom.iods, " +
"org.dcm4che.typeddicom.modules, org.dcm4che.typeddicom.valuerepresentations"
attributes["Import-Package"] = "org.dcm4che3.data"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public class TypeddicomPublisherPlugin implements Plugin<Project> {
private static final String TYPEDDICOM_GROUP = "org.dcm4che";
private static final String TYPEDDICOM_VERSION = "0.5.0";
private static final String TYPEDDICOM_VERSION = "0.5.1";

private static final String STANDARD_PUBLICATION_NAME = "mavenJava";
private static final String GRADLE_PLUGIN_PUBLICATION_NAME = "pluginMaven";
Expand Down
19 changes: 19 additions & 0 deletions dcm4che-typeddicom-skeleton/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ tasks.getByName<Test>("test") {
useJUnitPlatform()
}

// Remove non-numeric version info for Bundle version
val bundleVersion = "$version".replace(Regex(".*(\\d+\\.\\d+\\.\\d+).*"), "$1")

tasks.withType<Jar> {
manifest {
attributes["Manifest-Version"] = "1.0"
attributes["Bundle-ManifestVersion"] = "2"
attributes["Bundle-Name"] = "org.dcm4che.dcm4che-typeddicom-skeleton"
attributes["Bundle-SymbolicName"] = "org.dcm4che.dcm4che-typeddicom-skeleton;singleton:=true"
attributes["Bundle-Version"] = bundleVersion
attributes["Bundle-Vendor"] = "dcm4che"
attributes["Bundle-ClassPath"] = "."
attributes["Bundle-ActivationPolicy"] = "lazy"
attributes["Export-Package"] =
"org.dcm4che.typeddicom, org.dcm4che.typeddicom.valuerepresentations"
attributes["Import-Package"] = "org.dcm4che3.data"
}
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
Expand Down

0 comments on commit 9cd4f7c

Please sign in to comment.