protected void mergeLicense_Name( License target, License source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getName(); if ( src != null ) { if ( sourceDominant || target.getName() == null ) { target.setName( src ); target.setLocation( "name", source.getLocation( "name" ) ); } } }
properties.put( "license." + i + ".name", license.getName() ); properties.put( "license." + i + ".url", license.getUrl() ); properties.put( "license." + i + ".comments", license.getComments() );
public static License cloneLicense( License src ) { if ( src == null ) { return null; } License result = new License(); result.setComments( src.getComments() ); result.setDistribution( src.getDistribution() ); result.setName( src.getName() ); result.setUrl( src.getUrl() ); return result; }
/** * Method writeLicense. * * @param license * @param serializer * @param tagName * @throws java.io.IOException */ private void writeLicense( License license, String tagName, XmlSerializer serializer ) throws java.io.IOException { serializer.startTag( NAMESPACE, tagName ); if ( license.getName() != null ) { serializer.startTag( NAMESPACE, "name" ).text( license.getName() ).endTag( NAMESPACE, "name" ); } if ( license.getUrl() != null ) { serializer.startTag( NAMESPACE, "url" ).text( license.getUrl() ).endTag( NAMESPACE, "url" ); } if ( license.getDistribution() != null ) { serializer.startTag( NAMESPACE, "distribution" ).text( license.getDistribution() ).endTag( NAMESPACE, "distribution" ); } if ( license.getComments() != null ) { serializer.startTag( NAMESPACE, "comments" ).text( license.getComments() ).endTag( NAMESPACE, "comments" ); } serializer.endTag( NAMESPACE, tagName ); } //-- void writeLicense( License, String, XmlSerializer )
/** * Method writeLicense. * * @param license * @param serializer * @param tagName * @throws java.io.IOException */ private void writeLicense( License license, String tagName, XmlSerializer serializer ) throws java.io.IOException { serializer.startTag( NAMESPACE, tagName ); if ( license.getName() != null ) { serializer.attribute( NAMESPACE, "name", license.getName() ); } if ( license.getUrl() != null ) { serializer.attribute( NAMESPACE, "url", license.getUrl() ); } if ( license.getDistribution() != null ) { serializer.attribute( NAMESPACE, "distribution", license.getDistribution() ); } if ( license.getComments() != null ) { serializer.attribute( NAMESPACE, "comments", license.getComments() ); } serializer.endTag( NAMESPACE, tagName ); } //-- void writeLicense( License, String, XmlSerializer )
protected void mergeLicense_Name( License target, License source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getName(); if ( src != null ) { if ( sourceDominant || target.getName() == null ) { target.setName( src ); target.setLocation( "name", source.getLocation( "name" ) ); } } }
private List<org.apache.archiva.metadata.model.License> convertLicenses( List<License> licenses ) { List<org.apache.archiva.metadata.model.License> l = new ArrayList<>(); for ( License license : licenses ) { org.apache.archiva.metadata.model.License newLicense = new org.apache.archiva.metadata.model.License(); newLicense.setName( license.getName() ); newLicense.setUrl( license.getUrl() ); l.add( newLicense ); } return l; }
private void gatherProjectDependencies(MavenProject project, Map<MavenProject, List<Pair<String, String>>> dependencyLicenseMap, Map<String, MavenProject> dependencyGavMap) throws ProjectBuildingException { final Set dependencyArtifacts = project.getArtifacts(); if (dependencyArtifacts != null) { for (Object depArtifactObj : dependencyArtifacts) { final Artifact depArtifact = (Artifact) depArtifactObj; if (!excludedScopes.contains(depArtifact.getScope())) { MavenProject dep = resolveDependency(depArtifact); dep.setArtifact(depArtifact); dependencyGavMap.put(toGav(dep), dep); List<Pair<String, String>> licenseUrls = new ArrayList<>(); for (Object license : dep.getLicenses()) { final License license1 = (License) license; String url = license1.getUrl() != null ? license1.getUrl() : (license1.getName() != null ? license1.getName() : "LICENSE_EMPTY_NAME_URL"); licenseUrls.add(new ImmutablePair<>(url, license1.getName())); } dependencyLicenseMap.put(dep, licenseUrls); } } } }
private List<org.apache.archiva.metadata.model.License> convertLicenses( List<License> licenses ) { List<org.apache.archiva.metadata.model.License> l = new ArrayList<>(); for ( License license : licenses ) { org.apache.archiva.metadata.model.License newLicense = new org.apache.archiva.metadata.model.License(); newLicense.setName( license.getName() ); newLicense.setUrl( license.getUrl() ); l.add( newLicense ); } return l; }
/** * Equivalent to {@code new ProjectLicense( license.getName(), license.getUrl(), license.getDistribution(), * license.getComments(), null )} * * @param license the license to get name, URL, ditribution and comments from */ public ProjectLicense( License license ) { this( license.getName(), license.getUrl(), license.getDistribution(), license.getComments(), null ); }
@SuppressWarnings("unchecked") protected Cfg(ScalaGenJsonMojo data) throws Exception { groupId = data.project.getGroupId(); artifactId = data.artifactId; version = data.project.getVersion(); logo = data.logo; license = data.license; description = data.description; tags = data.tags; linksources = data.linksources; if (StringUtils.isBlank(license) && !data.project.getLicenses().isEmpty()) { License lic = (License) data.project.getLicenses().get(0); license = String.format("<a href='%s'>%s</a>", lic.getUrl(), lic.getName()); } dependencies = makeDependencies(data); sources = makeSources(data); artifacts = makeArtifacts(data); if (data.args != null && data.args.length > 0) { additionnalArgs = Arrays.asList(data.args); } kind = makeKind(data); }
@Override public void invoke(MavenProject mavenProject, Map<String, Object> models, ResultCollector resultCollector) { final List<License> licenses = mavenProject.getLicenses(); if (licenses.isEmpty()) { InputLocation location = mavenProject.getOriginalModel().getLocation("licences"); resultCollector.addViolation(mavenProject, this, "missing <licenses/> information", location == null ? getEmptyLocation(mavenProject) : location); } else { for (License license : licenses) { if (StringUtils.isEmpty(license.getName())) { resultCollector.addViolation(mavenProject, this, "missing <name> in <license/> information", license.getLocation("")); } if (StringUtils.isEmpty(license.getUrl())) { resultCollector.addViolation(mavenProject, this, "missing <url> in <license/> information", license.getLocation("")); } } } }
/** * Adds information about references licenses. * * @param pomDescriptor * The descriptor for the current POM. * @param model * The Maven Model. * @param store * The database. */ private void addLicenses(MavenPomDescriptor pomDescriptor, Model model, Store store) { List<License> licenses = model.getLicenses(); for (License license : licenses) { MavenLicenseDescriptor licenseDescriptor = store.create(MavenLicenseDescriptor.class); licenseDescriptor.setUrl(license.getUrl()); licenseDescriptor.setComments(license.getComments()); licenseDescriptor.setName(license.getName()); licenseDescriptor.setDistribution(license.getDistribution()); pomDescriptor.getLicenses().add(licenseDescriptor); } }
/** * Method updateLicense * * @param value * @param element * @param counter * @param xmlTag */ protected void updateLicense( License value, String xmlTag, Counter counter, Element element ) { Element root = element; Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); findAndReplaceSimpleElement( innerCount, root, "distribution", value.getDistribution(), null ); findAndReplaceSimpleElement( innerCount, root, "comments", value.getComments(), null ); } // -- void updateLicense(License, String, Counter, Element)
/** * Method updateLicense. * * @param value * @param element * @param counter * @param xmlTag */ protected void updateLicense(License value, String xmlTag, Counter counter, Element element) { Element root = element; Counter innerCount = new Counter(counter.getDepth() + 1); findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); findAndReplaceSimpleElement(innerCount, root, "distribution", value.getDistribution(), null); findAndReplaceSimpleElement(innerCount, root, "comments", value.getComments(), null); } //-- void updateLicense(License, String, Counter, Element)
/** * Method updateLicense * * @param value * @param element * @param counter * @param xmlTag */ protected void updateLicense(License value, String xmlTag, Counter counter, Element element) { Element root = element; Counter innerCount = new Counter(counter.getDepth() + 1); findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); findAndReplaceSimpleElement(innerCount, root, "distribution", value.getDistribution(), null); findAndReplaceSimpleElement(innerCount, root, "comments", value.getComments(), null); } //-- void updateLicense(License, String, Counter, Element)
/** * Method updateLicense * * @param value * @param element * @param counter * @param xmlTag */ protected void updateLicense( License value, String xmlTag, Counter counter, Element element ) { Element root = element; Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); findAndReplaceSimpleElement( innerCount, root, "distribution", value.getDistribution(), null ); findAndReplaceSimpleElement( innerCount, root, "comments", value.getComments(), null ); } // -- void updateLicense(License, String, Counter, Element)
/** * Method updateLicense. * * @param value * @param element * @param counter * @param xmlTag */ protected void updateLicense( License value, String xmlTag, Counter counter, Element element ) { Element root = element; Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); findAndReplaceSimpleElement( innerCount, root, "distribution", value.getDistribution(), null ); findAndReplaceSimpleElement( innerCount, root, "comments", value.getComments(), null ); } // -- void updateLicense(License, String, Counter, Element)
/** * Method updateLicense. * * @param value * @param element * @param counter * @param xmlTag */ protected void updateLicense(License value, String xmlTag, Counter counter, Element element) { Element root = element; Counter innerCount = new Counter(counter.getDepth() + 1); findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); findAndReplaceSimpleElement(innerCount, root, "distribution", value.getDistribution(), null); findAndReplaceSimpleElement(innerCount, root, "comments", value.getComments(), null); } // -- void updateLicense(License, String, Counter, Element)