Skip to content

Commit a03ea84

Browse files
author
Greg Gibeling
authored
Merge pull request #1 from Roche-CSI/XML1.1
Switch to XML 1.1 and fork repository for self-distribution
2 parents d25e21d + 51aae7a commit a03ea84

File tree

6 files changed

+77
-36
lines changed

6 files changed

+77
-36
lines changed

.github/workflows/java-maven.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Roche-CSI: New CI workflow which deploys to gh packages
2+
name: Java CI with Maven
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
push:
8+
branches:
9+
- master
10+
workflow_dispatch:
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
- name: Set up JDK 8
20+
uses: actions/setup-java@v2
21+
with:
22+
distribution: adopt
23+
java-version: 8
24+
cache: maven
25+
- name: Build with Maven
26+
# Run maven deploy only on push or workflow dispatch to master
27+
run: ./mvnw -s "${GITHUB_WORKSPACE}/.github/workflows/maven-settings.xml" -B ${{ (((github.event_name == 'push') || (github.event_name == 'workflow_dispatch')) && (github.ref == 'refs/heads/master')) && 'deploy' || 'package' }} --file pom.xml -P release -Dgpg.skip
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
5+
6+
<!-- Roche-CSI: New maven config to support deployment to gh packages -->
7+
<servers>
8+
<server>
9+
<id>github-deploy</id>
10+
<username>${env.GITHUB_ACTOR}</username>
11+
<password>${env.GITHUB_TOKEN}</password>
12+
</server>
13+
</servers>
14+
</settings>

.github/workflows/maven.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ target
33
.idea/
44
dependency-reduced-pom.xml
55
.DS_Store
6+
/.classpath
7+
/.project
8+
/.settings/

pom.xml

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020

2121
<modelVersion>4.0.0</modelVersion>
2222

23-
<groupId>org.cyclonedx</groupId>
23+
<!-- Roche-CSI: Changed group to allow publishing, changed version to snapshot -->
24+
<groupId>com.github.roche_csi.cyclonedx_core_java</groupId>
2425
<artifactId>cyclonedx-core-java</artifactId>
2526
<packaging>jar</packaging>
26-
<version>5.0.4</version>
27+
<version>5.0.4-SNAPSHOT</version>
2728

2829
<name>CycloneDX Core (Java)</name>
2930
<description>The CycloneDX core module provides a model representation of the BOM along with utilities to assist in creating, parsing, and validating BOMs.</description>
@@ -52,6 +53,12 @@
5253
<role>Developer</role>
5354
</roles>
5455
</developer>
56+
<!-- Roche-CSI: Added developer -->
57+
<developer>
58+
<name>Greg Gibeling</name>
59+
<email>[email protected]</email>
60+
<organization>Roche</organization>
61+
</developer>
5562
</developers>
5663

5764
<properties>
@@ -69,31 +76,36 @@
6976
</properties>
7077

7178
<scm>
72-
<connection>scm:git:[email protected]:CycloneDX/cyclonedx-core-java.git</connection>
73-
<url>https://github.com/CycloneDX/cyclonedx-core-java.git</url>
74-
<developerConnection>scm:git:git@github.com:CycloneDX/cyclonedx-core-java.git</developerConnection>
75-
<tag>cyclonedx-core-java-5.0.4</tag>
79+
<!-- Roche-CSI: Changed location -->
80+
<connection>scm:git:git@github.com:Roche-CSI/cyclonedx-core-java.git</connection>
81+
<url>https://github.com/Roche-CSI/cyclonedx-core-java.git</url>
82+
<developerConnection>scm:git:[email protected]:Roche-CSI/cyclonedx-core-java.git</developerConnection>
7683
</scm>
7784

7885
<issueManagement>
7986
<system>GitHub</system>
80-
<url>https://github.com/CycloneDX/cyclonedx-core-java/issues</url>
87+
<!-- Roche-CSI: Changed location -->
88+
<url>https://github.com/Roche-CSI/cyclonedx-core-java/issues</url>
8189
</issueManagement>
8290

8391
<ciManagement>
8492
<system>GitHub</system>
85-
<url>https://github.com/CycloneDX/cyclonedx-core-java/actions</url>
93+
<!-- Roche-CSI: Changed location -->
94+
<url>https://github.com/Roche-CSI/cyclonedx-core-java/actions</url>
8695
</ciManagement>
8796

8897
<distributionManagement>
89-
<snapshotRepository>
90-
<id>ossrh</id>
91-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
92-
</snapshotRepository>
98+
<!-- Roche-CSI: Changed location -->
9399
<repository>
94-
<id>ossrh</id>
95-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
100+
<id>github-deploy</id>
101+
<name>GitHub Packages</name>
102+
<url>https://maven.pkg.github.com/Roche-CSI/cyclonedx-core-java</url>
96103
</repository>
104+
<snapshotRepository>
105+
<id>github-deploy</id>
106+
<name>GitHub Packages</name>
107+
<url>https://maven.pkg.github.com/Roche-CSI/cyclonedx-core-java</url>
108+
</snapshotRepository>
97109
</distributionManagement>
98110

99111
<repositories>

src/main/java/org/cyclonedx/generators/xml/AbstractBomXmlGenerator.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.fasterxml.jackson.databind.ObjectMapper;
3737
import com.fasterxml.jackson.databind.module.SimpleModule;
3838
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
39+
import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator;
3940
import com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter;
4041

4142
public abstract class AbstractBomXmlGenerator extends CycloneDxSchema implements BomXmlGenerator {
@@ -46,6 +47,8 @@ public abstract class AbstractBomXmlGenerator extends CycloneDxSchema implements
4647

4748
public AbstractBomXmlGenerator() {
4849
mapper = new XmlMapper();
50+
// Roche-CSI: Use XML 1.1 to handle extended characters in linux copyright files
51+
((XmlMapper) mapper).configure(ToXmlGenerator.Feature.WRITE_XML_1_1, true);
4952
prettyPrinter = new DefaultXmlPrettyPrinter();
5053
setupObjectMapper(mapper);
5154
}
@@ -56,8 +59,6 @@ public ObjectMapper getMapper() {
5659

5760
Document doc;
5861

59-
protected static final String PROLOG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
60-
6162
private void setupObjectMapper(final ObjectMapper mapper) {
6263
mapper.setAnnotationIntrospector(
6364
new VersionXmlAnnotationIntrospector(
@@ -116,9 +117,9 @@ protected Document generateDocument(final Bom bom)
116117
String toXML(final Bom bom, final boolean prettyPrint) throws GeneratorException {
117118
try {
118119
if (prettyPrint) {
119-
return PROLOG + System.lineSeparator() + mapper.writer(prettyPrinter).writeValueAsString(bom);
120+
return mapper.writer(prettyPrinter).writeValueAsString(bom);
120121
}
121-
return PROLOG + mapper.writeValueAsString(bom);
122+
return mapper.writeValueAsString(bom);
122123
} catch (JsonProcessingException ex) {
123124
throw new GeneratorException(ex);
124125
}

0 commit comments

Comments
 (0)