Skip to content

Commit

Permalink
Switch to published plantuml-asl version instead of building from sou…
Browse files Browse the repository at this point in the history
…rces. (#523)
  • Loading branch information
sjoerdtalsma committed Nov 24, 2023
1 parent 6769010 commit 90c20fb
Show file tree
Hide file tree
Showing 4,351 changed files with 126 additions and 356,895 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
72 changes: 22 additions & 50 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.release>9</maven.compiler.release>
<plantuml-asl.version>1.2023.12</plantuml-asl.version>

<!-- Plant UML apache-licensed sources: https://sourceforge.net/projects/plantuml/files/ -->
<plantuml-asl.directory>${project.basedir}/src/plantuml-asl</plantuml-asl.directory>
Expand All @@ -85,6 +86,7 @@
<maven-javadoc-plugin.version>3.6.2</maven-javadoc-plugin.version>
<maven-gpg-plugin.version>3.1.0</maven-gpg-plugin.version>
<maven-release-plugin.version>3.0.1</maven-release-plugin.version>
<maven-shade-plugin.version>3.5.1</maven-shade-plugin.version>
<build-helper-maven-plugin.version>3.4.0</build-helper-maven-plugin.version>
<nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
<license-maven-plugin.version>4.3</license-maven-plugin.version>
Expand All @@ -104,49 +106,30 @@
<include>LICENSE</include>
</includes>
</resource>
<resource>
<directory>${plantuml-asl.directory}/src</directory>
<includes>
<include>net/sourceforge/plantuml/**/*.png</include>
<include>net/sourceforge/plantuml/openiconic/data/**/*.txt</include>
<include>net/sourceforge/plantuml/openiconic/data/**/*.svg</include>
<include>net/sourceforge/plantuml/emoji/data/**/*.txt</include>
<include>net/sourceforge/plantuml/emoji/data/**/*.svg</include>
<include>sprites/archimate/**/*.png</include>
<include>net/sourceforge/plantuml/math/**/*.js</include>
<include>net/sourceforge/plantuml/utils/**/*.txt</include>
<include>net/sourceforge/plantuml/windowsdot/*.dat</include>
</includes>
</resource>
<resource>
<directory>${plantuml-asl.directory}</directory>
<includes>
<include>stdlib/**/*.repx</include>
<include>skin/**/*.skin</include>
<include>themes/**/*.puml</include>
<include>svg/**/*.js</include>
<include>svg/**/*.css</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build-helper-maven-plugin.version}</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<id>shade-dependencies</id>
<phase>package</phase>
<goals>
<goal>add-source</goal>
<goal>shade</goal>
</goals>
<configuration>
<sources>
<source>${plantuml-asl.directory}/src</source>
</sources>
</configuration>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>net.sourceforge.plantuml:plantuml-asl</include>
</includes>
</artifactSet>
<minimizeJar>true</minimizeJar>
<!-- TODO exclude unused packages and resources to save space. -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -175,14 +158,6 @@
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>gen/**/*</exclude>
<exclude>h/**/*</exclude>
<exclude>net/sourceforge/plantuml/**/*</exclude>
<exclude>smetana/**/*</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
Expand Down Expand Up @@ -267,8 +242,6 @@
<artifactId>umldoclet</artifactId>
<version>${project.version}</version>
</docletArtifact>
<sourcepath>${project.build.sourceDirectory}:${plantuml-asl.directory}/src</sourcepath>
<excludePackageNames>gen.*:h:net.sourceforge.*:smetana.*</excludePackageNames>
<additionalOptions>
<additionalOption>-createPumlFiles</additionalOption>
<additionalOption>-failOnCyclicPackageDependencies true</additionalOption>
Expand Down Expand Up @@ -303,13 +276,12 @@
</build>

<dependencies>
<dependency> <!-- Required to compile 'net.sourceforge.plantuml.ant.*' -->
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.10.14</version>
<scope>provided</scope>
<optional>true</optional>
<dependency>
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml-asl</artifactId>
<version>${plantuml-asl.version}</version>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>findbugs-annotations</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2022 Talsma ICT
* Copyright 2016-2023 Talsma ICT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,7 @@
import nl.talsmasoftware.umldoclet.uml.TypeName;

import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.QualifiedNameable;
import javax.lang.model.type.ArrayType;
import javax.lang.model.type.DeclaredType;
Expand Down Expand Up @@ -75,17 +76,18 @@ private TypeName _visit(TypeMirror type, Void parameter) {
public TypeName visitPrimitive(PrimitiveType primitiveType, Void parameter) {
// "byte", "char", "short", "int", "long", "float", "double", "boolean"
final String primitive = primitiveType.getKind().name().toLowerCase();
return new TypeName(primitive, primitive);
return new TypeName(null, primitive, primitive);
}

@Override
public TypeName visitNoType(NoType noType, Void parameter) {
// "void", "package", "module", "none"
final String none = noType.getKind().name().toLowerCase();
return new TypeName(none, none);
return new TypeName(null, none, none);
}

@Override

public TypeName visitDeclared(DeclaredType declaredType, Void parameter) {
final Element el = declaredType.asElement();
final String simpleName = el.getSimpleName().toString();
Expand All @@ -94,7 +96,17 @@ public TypeName visitDeclared(DeclaredType declaredType, Void parameter) {
final TypeName[] generics = declaredType.getTypeArguments().stream()
.map(generic -> _visit(generic, parameter))
.toArray(TypeName[]::new);
return new TypeName(simpleName, qualifiedName, generics);
final String packagename;

Element enclosingElement = el.getEnclosingElement();
if (enclosingElement.getKind().isInterface() || enclosingElement.getKind().isClass())
{
packagename = visit(enclosingElement.asType()).packagename;
} else {
int dot = qualifiedName.lastIndexOf('.');
packagename = dot > 0 ? qualifiedName.substring(0, dot) : null;
}
return new TypeName(packagename, simpleName, qualifiedName, generics);
}

@Override
Expand All @@ -115,7 +127,6 @@ public TypeName visitTypeVariable(TypeVariable typeVariable, Void parameter) {
TypeMirror lowerBound = typeVariable.getLowerBound();
if (lowerBound != null && !NO_KNOWN_TYPES.contains(lowerBound.getKind())) {
return TypeName.Variable.superBound(typeVariable.toString(), _visit(lowerBound, parameter));

}

return defaultAction(typeVariable, parameter);
Expand All @@ -136,7 +147,8 @@ protected TypeName defaultAction(TypeMirror tp, Void parameter) {
String qualified = tp.toString();
int lt = qualified.lastIndexOf('<');
int dot = (lt < 0 ? qualified : qualified.substring(0, lt)).lastIndexOf('.');
return new TypeName(qualified.substring(dot + 1), qualified);
String packagename = dot < 0 ? null : qualified.substring(0, dot);
return new TypeName(packagename, qualified.substring(dot + 1), qualified);
}

}
36 changes: 21 additions & 15 deletions src/main/java/nl/talsmasoftware/umldoclet/javadoc/UMLFactory.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2022 Talsma ICT
* Copyright 2016-2023 Talsma ICT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -202,7 +202,7 @@ public Diagram createPackageDiagram(PackageElement packageElement) {
Map<String, Collection<Type>> foreignTypes = new LinkedHashMap<>();
List<Reference> references = new ArrayList<>();

Namespace namespace = createPackage(packageDiagram, packageElement, foreignTypes, references);
Namespace namespace = createPackage(packageDiagram, packageElement, foreignTypes, references, "::");
packageDiagram.addChild(namespace);

// Filter "java.lang" or "java.util" references that occur >= 3 times
Expand Down Expand Up @@ -233,14 +233,16 @@ public Diagram createPackageDiagram(PackageElement packageElement) {
.forEach(packageDiagram::addChild);

namespace.addChild(UmlCharacters.NEWLINE);
references.stream().map(Reference::canonical).forEach(namespace::addChild);

if (config.methods().javaBeanPropertiesAsFields()) {
namespace.getChildren().stream()
.filter(Type.class::isInstance).map(Type.class::cast)
.forEach(POST_PROCESSORS.javaBeanPropertiesAsFieldsPostProcessor());
}

if (!references.isEmpty()) packageDiagram.addChild(UmlCharacters.NEWLINE);
references.stream().map(Reference::canonical).forEach(packageDiagram::addChild);

return packageDiagram;
}

Expand Down Expand Up @@ -438,7 +440,7 @@ private void addForeignType(Map<String, Collection<Type>> foreignTypes, Element
}

private Collection<Reference> findPackageReferences(
Namespace namespace, Map<String, Collection<Type>> foreignTypes, TypeElement typeElement, Type type) {
Namespace namespace, Map<String, Collection<Type>> foreignTypes, TypeElement typeElement, Type type, String separator) {
Collection<Reference> references = new LinkedHashSet<>();

// Superclass reference.
Expand All @@ -452,9 +454,9 @@ private Collection<Reference> findPackageReferences(
TypeName superclassName = TypeNameVisitor.INSTANCE.visit(superclassType);
if (!config.excludedTypeReferences().contains(superclassName.qualified)) {
references.add(new Reference(
Reference.from(type.getName().qualified, null),
Reference.from(type.getName().getQualified(separator), null),
"--|>",
Reference.to(superclassName.qualified, null)));
Reference.to(superclassName.getQualified(separator), null)));
if (!namespace.contains(superclassName)) {
addForeignType(foreignTypes, superclassElement);
}
Expand All @@ -466,9 +468,9 @@ private Collection<Reference> findPackageReferences(
TypeName interfaceName = TypeNameVisitor.INSTANCE.visit(interfaceType);
if (!config.excludedTypeReferences().contains(interfaceName.qualified)) {
references.add(new Reference(
Reference.from(type.getName().qualified, null),
Reference.from(type.getName().getQualified(separator), null),
interfaceRefTypeFrom(type),
Reference.to(interfaceName.qualified, null)));
Reference.to(interfaceName.getQualified(separator), null)));
// TODO Figure out what to do IF the interface is found BUT has a different typename
if (!namespace.contains(interfaceName)) {
addForeignType(foreignTypes, env.getTypeUtils().asElement(interfaceType));
Expand All @@ -480,7 +482,10 @@ private Collection<Reference> findPackageReferences(
ElementKind enclosingKind = typeElement.getEnclosingElement().getKind();
if (enclosingKind.isClass() || enclosingKind.isInterface()) {
TypeName parentType = TypeNameVisitor.INSTANCE.visit(typeElement.getEnclosingElement().asType());
references.add(new Reference(Reference.from(parentType.qualified, null), "+--", Reference.to(type.getName().qualified, null)));
references.add(new Reference(
Reference.from(parentType.getQualified(separator), null),
"+--",
Reference.to(type.getName().getQualified(separator), null)));
// No check needed whether parent type lives in our namespace.
}

Expand All @@ -494,9 +499,9 @@ private Collection<Reference> findPackageReferences(
TypeNameWithCardinality fieldType = typeNameWithCardinality.apply(field.asType());
if (namespace.contains(fieldType.typeName)) {
addReference(references, new Reference(
Reference.from(type.getName().qualified, null),
Reference.from(type.getName().getQualified(separator), null),
"-->",
Reference.to(fieldType.typeName.qualified, fieldType.cardinality),
Reference.to(fieldType.typeName.getQualified(separator), fieldType.cardinality),
fieldName));
type.removeChildren(child -> child instanceof Field && ((Field) child).name.equals(fieldName));
}
Expand All @@ -513,9 +518,9 @@ private Collection<Reference> findPackageReferences(
TypeNameWithCardinality returnType = typeNameWithCardinality.apply(propertyType(method));
if (namespace.contains(returnType.typeName)) {
addReference(references, new Reference(
Reference.from(type.getName().qualified, null),
Reference.from(type.getName().getQualified(separator), null),
"-->",
Reference.to(returnType.typeName.qualified, returnType.cardinality),
Reference.to(returnType.typeName.getQualified(separator), returnType.cardinality),
propertyName));
type.removeChildren(child -> child instanceof Method
&& ((Method) child).name.equals(method.getSimpleName().toString()));
Expand Down Expand Up @@ -591,7 +596,8 @@ private static Stream<TypeElement> innerTypes(TypeElement type) {
Namespace createPackage(Diagram diagram,
PackageElement packageElement,
Map<String, Collection<Type>> foreignTypes,
List<Reference> references) {
List<Reference> references,
String referenceSeparator) {
final ModuleElement module = env.getElementUtils().getModuleOf(packageElement);
Namespace pkg = new Namespace(diagram, packageElement.getQualifiedName().toString(),
module == null ? null : module.getQualifiedName().toString());
Expand All @@ -603,7 +609,7 @@ Namespace createPackage(Diagram diagram,
.filter(env::isIncluded)
.map(typeElement -> {
Type type = createAndPopulateType(pkg, typeElement);
references.addAll(findPackageReferences(pkg, foreignTypes, typeElement, type));
references.addAll(findPackageReferences(pkg, foreignTypes, typeElement, type, referenceSeparator));
return type;
})
.flatMap(type -> Stream.of(UmlCharacters.NEWLINE, type))
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/nl/talsmasoftware/umldoclet/uml/Diagram.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2022 Talsma ICT
* Copyright 2016-2023 Talsma ICT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -63,14 +63,16 @@ public <IPW extends IndentingPrintWriter> IPW writeTo(IPW output) {
IndentingPrintWriter indented = output.indent();
writeCustomDirectives(config.customPlantumlDirectives(), indented);
writeChildrenTo(indented);
indented.newline();
writeFooterTo(indented);
output.append("@enduml").newline();
return output;
}

protected <IPW extends IndentingPrintWriter> IPW writeCustomDirectives(List<String> customDirectives, IPW output) {
customDirectives.forEach(output::println);
if (!customDirectives.isEmpty()) {
output.newline();
}
return output;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/nl/talsmasoftware/umldoclet/uml/Namespace.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2022 Talsma ICT
* Copyright 2016-2023 Talsma ICT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -59,7 +59,7 @@ private <IPW extends IndentingPrintWriter> IPW writeNameTo(IPW output) {

@Override
public <IPW extends IndentingPrintWriter> IPW writeTo(IPW output) {
writeNameTo(output.append("namespace").whitespace()).append('{').newline();
writeNameTo(output.append("package").whitespace()).append('{').newline();
writeChildrenTo(output.indent());
output.append('}').newline();
return output;
Expand Down
Loading

0 comments on commit 90c20fb

Please sign in to comment.