/** * 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 )
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; }
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" ) ); } } }
protected void mergeLicense_Url( License target, License source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getUrl(); if ( src != null ) { if ( sourceDominant || target.getUrl() == null ) { target.setUrl( src ); target.setLocation( "url", source.getLocation( "url" ) ); } } }
License license = new License(); for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) license.setName( interpolatedTrimmed( parser.nextText(), "name" ) ); license.setUrl( interpolatedTrimmed( parser.nextText(), "url" ) ); license.setDistribution( interpolatedTrimmed( parser.nextText(), "distribution" ) ); license.setComments( interpolatedTrimmed( parser.nextText(), "comments" ) );
for ( License license : licenses ) String name = license.getName(); if ( StringUtils.isEmpty( name ) ) String name = license.getName(); if ( StringUtils.isEmpty( name ) ) String url = license.getUrl(); String comments = license.getComments();
private static StringBuilder printLicenses(List licenses) { if (licenses == null || licenses.isEmpty()) { return null; } StringBuilder sb = new StringBuilder(); String del = ""; for (Object license : licenses) { License l = (License) license; String url = l.getUrl(); if (url == null) { continue; } sb.append(del); sb.append(url); del = ", "; } if (sb.length() == 0) { return null; } return sb; }
@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("")); } } } }
/** * {@inheritDoc} */ public void addLicense( LicenseMap licenseMap, MavenProject project, String... licenseNames ) { List<License> licenses = new ArrayList<>(); for ( String licenseName : licenseNames ) { License license = new License(); license.setName( licenseName.trim() ); license.setUrl( licenseName.trim() ); licenses.add( license ); } addLicense( licenseMap, project, licenses ); }
protected void mergeLicense_Comments( License target, License source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getComments(); if ( src != null ) { if ( sourceDominant || target.getComments() == null ) { target.setComments( src ); target.setLocation( "comments", source.getLocation( "comments" ) ); } } }
protected void mergeLicense_Distribution( License target, License source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getDistribution(); if ( src != null ) { if ( sourceDominant || target.getDistribution() == null ) { target.setDistribution( src ); target.setLocation( "distribution", source.getLocation( "distribution" ) ); } } }
/** * Convenience method used to extract organizational info from the project for use in the copyright, if it * exists. Otherwise, return "Unknown" */ private void appendLicenses( MavenProject project, StringBuffer specBuffer ) { List licenses = project.getLicenses(); specBuffer.append( "\nLicense: " ); if ( licenses != null && !licenses.isEmpty() ) { for ( Iterator it = licenses.iterator(); it.hasNext(); ) { License license = (License) it.next(); specBuffer.append( license.getName() ); if ( it.hasNext() ) { specBuffer.append( ", " ); } } } else { specBuffer.append( "Unknown" ); } }
License license = new License("PrimeSense", "0KOIk2JeIBYClPWVnMoRKn5cdY4="); // vendor, key context.addLicense(license);
private String createDefaultLicenseText() { String toRet = "License terms:\n"; List licenses = project.getLicenses(); if (licenses != null && licenses.size() > 0) { Iterator lic = licenses.iterator(); while (lic.hasNext()) { License ll = ( License )lic.next(); if (ll.getName() != null) { toRet = toRet + ll.getName() + " - "; } if (ll.getUrl() != null) { toRet = toRet + ll.getUrl(); } if (lic.hasNext()) { toRet = toRet + ",\n"; } } } else { toRet = toRet + "Unknown"; } return toRet; } }
License license = new License(); InputLocation _location; _location = new InputLocation( parser.getLineNumber(), parser.getColumnNumber(), source ); license.setLocation( "", _location ); for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) license.setLocation( "name", _location ); license.setName( interpolatedTrimmed( parser.nextText(), "name" ) ); license.setLocation( "url", _location ); license.setUrl( interpolatedTrimmed( parser.nextText(), "url" ) ); license.setLocation( "distribution", _location ); license.setDistribution( interpolatedTrimmed( parser.nextText(), "distribution" ) ); license.setLocation( "comments", _location ); license.setComments( interpolatedTrimmed( parser.nextText(), "comments" ) );
private static StringBuffer printLicenses( List<License> licenses ) { if ( licenses == null || licenses.size() == 0 ) return null; StringBuffer sb = new StringBuffer(); String del = ""; for ( Iterator<License> i = licenses.iterator(); i.hasNext(); ) { License l = i.next(); String url = l.getUrl(); if ( url == null ) continue; sb.append( del ); sb.append( url ); del = ", "; } if ( sb.length() == 0 ) return null; return sb; }
protected void mergeLicense_Url( License target, License source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getUrl(); if ( src != null ) { if ( sourceDominant || target.getUrl() == null ) { target.setUrl( src ); target.setLocation( "url", source.getLocation( "url" ) ); } } }
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" ) ); } } }