public void testShouldInterpolateOrganizationNameCorrectly() throws Exception { String orgName = "MyCo"; Model model = new Model(); model.setName( "${pom.organization.name} Tools" ); Organization org = new Organization(); org.setName( orgName ); model.setOrganization( org ); ModelInterpolator interpolator = createInterpolator(); Model out = interpolator.interpolateModel( model, new File( "." ), createModelBuildingRequest( context ), new SimpleProblemCollector() ); assertEquals( orgName + " Tools", out.getName() ); }
/** Constructor. * @param artifact the artifact. * @param name name of the artifact. * @param website website. * @param organization organization. * @param scmRevision url of the SCM. * @param scm SCM. * @param developers developers. * @param contributors constributors. * @param licenses licenses. */ public ExtendedArtifact( Artifact artifact, String name, String website, Organization organization, String scmRevision, Scm scm, List<? extends Developer> developers, List<? extends Contributor> contributors, List<? extends License> licenses) { this.original = artifact; this.artifactName = name; this.developers = developers; this.contributors = contributors; this.website = website; this.organization = organization; this.scm = scm; this.scmRevision = scmRevision; this.licenses = licenses; }
private void writeOrganization(Organization organization, String tagName, XmlSerializer serializer) throws java.io.IOException { serializer.startTag(NAMESPACE, tagName); flush(serializer); StringBuffer b = b(serializer); int start = b.length(); if (organization.getName() != null) { writeValue(serializer, "name", organization.getName(), organization); } if (organization.getUrl() != null) { writeValue(serializer, "url", organization.getUrl(), organization); } serializer.endTag(NAMESPACE, tagName).flush(); logLocation(organization, "", start, b.length()); }
/** * Method updateOrganization * * @param value * @param element * @param counter * @param xmlTag */ protected void updateOrganization( Organization value, String xmlTag, Counter counter, Element element ) { boolean shouldExist = value != null; Element root = updateElement( counter, element, xmlTag, shouldExist ); if ( shouldExist ) { Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); } }
private String createDefaultLicenseHeader() { String organization = ""; Organization org = project.getOrganization(); if (org != null) { organization = org.getName(); } if (organization == null) { List devs = project.getDevelopers(); if (devs.size() > 0) { Iterator dvs = devs.iterator(); String devsString = ""; while (dvs.hasNext()) { Developer d = ( Developer )dvs.next(); devsString = devsString + "," + d.getName() != null ? d.getName() : d.getId(); } organization = devsString.substring( 1 ); } } if (organization == null) { organization = ""; //what's a good default value? } String date = ""; if (project.getInceptionYear() != null) { date = project.getInceptionYear(); } String year = Integer.toString( Calendar.getInstance().get( Calendar.YEAR )); if (!year.equals( date ) ) { date = date.length() == 0 ? year : date + "-" + year; } return "Copyright " + organization + " " + date; }
protected void mergeOrganization_Name( Organization target, Organization 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 mergeOrganization_Url( Organization target, Organization 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 Map<Organization, List<MavenProject>> getProjectsSortedByOrganization( List<MavenProject> projects ) throws MojoExecutionException { Map<Organization, List<MavenProject>> organizations = new TreeMap<Organization, List<MavenProject>>( new OrganizationComparator() ); List<MavenProject> unknownOrganization = new ArrayList<MavenProject>(); for ( MavenProject p : projects ) { if ( p.getOrganization() != null && StringUtils.isNotEmpty( p.getOrganization().getName() ) ) { List<MavenProject> sortedProjects = (List<MavenProject>) organizations.get( p.getOrganization() ); if ( sortedProjects == null ) { sortedProjects = new ArrayList<MavenProject>(); } sortedProjects.add( p ); organizations.put( p.getOrganization(), sortedProjects ); } else { unknownOrganization.add( p ); } } if ( !unknownOrganization.isEmpty() ) { Organization unknownOrg = new Organization(); unknownOrg.setName( "an unknown organization" ); organizations.put( unknownOrg, unknownOrganization ); } return organizations; }
public int compare( Organization org1, Organization org2 ) { int i = compareStrings( org1.getName(), org2.getName() ); if ( i == 0 ) { i = compareStrings( org1.getUrl(), org2.getUrl() ); } return i; }
public Organization getOrganization() { return null; }
/** * Fetches and installs the Minecraft module artifact. */ private void fetchArtifact() throws Exception { VersionIndex index = VersionIndex.fetch(); VersionMetadata metadata = index.getMetadata(this.getGameVersion()).orElseThrow(() -> new NoSuchElementException("No such game version: " + this.getGameVersion())); Artifact artifact = this.createArtifactWithClassifier(MINECRAFT_GROUP_ID, this.getModule(), this.getGameVersion(), VANILLA_CLASSIFIER); DownloadDescriptor descriptor = ("server".equals(this.getModule()) ? metadata.getServerDownload() : metadata.getClientDownload()); this.temporary((a) -> { descriptor.fetch(a); this.temporary((m) -> { this.getLog().info("Storing Minecraft module as artifact " + this.getArtifactCoordinateString(artifact)); { Model model = new Model(); model.setGroupId(MINECRAFT_GROUP_ID); model.setArtifactId(this.getModule()); model.setVersion(this.getGameVersion()); model.setPackaging("jar"); Organization organization = new Organization(); organization.setName("Mojang"); organization.setUrl("http://mojang.com"); model.setOrganization(organization); License license = new License(); license.setName("Mojang EULA"); license.setUrl("https://account.mojang.com/terms"); license.setDistribution("manual"); model.addLicense(license); try (FileOutputStream outputStream = new FileOutputStream(m.toFile())) { try (OutputStreamWriter writer = new OutputStreamWriter(outputStream)) { (new MavenXpp3Writer()).write(writer, model); } } } this.installArtifact(artifact, m, a); }); }); }
@Override public Organization replaceOrganization( Organization organization ) { return organization; }
@Override public void visitOrganization( Organization organization ) { }
@Override protected void renderBody() { startSection( getTitle() ); String name = project.getName(); if ( name == null ) { name = ""; } String description = project.getDescription(); if ( description == null ) { description = ""; } String homepage = project.getUrl(); if ( homepage == null ) { homepage = ""; } startSection( getReportString( "report.summary.general.title" ) ); startTable(); tableHeader( new String[]{getReportString( "report.summary.field" ), getReportString( "report.summary.value" )} ); tableRow( new String[]{getReportString( "report.summary.general.name" ), name} ); tableRow( new String[]{getReportString( "report.summary.general.description" ), description} ); tableRowWithLink( new String[]{getReportString( "report.summary.general.homepage" ), homepage} ); endTable(); endSection(); //organization sub-section startSection( getReportString( "report.summary.organization.title" ) ); Organization organization = project.getOrganization(); if ( organization == null ) { paragraph( getReportString( "report.summary.noorganization" ) ); } else { if ( organization.getName() == null ) { organization.setName( "" ); } if ( organization.getUrl() == null ) { organization.setUrl( "" ); } startTable(); tableHeader( new String[]{getReportString( "report.summary.field" ), getReportString( "report.summary.value" )} ); tableRow( new String[]{getReportString( "report.summary.organization.name" ), organization.getName()} ); tableRowWithLink( new String[]{getReportString( "report.summary.organization.url" ), organization.getUrl()} ); endTable(); } endSection(); //build section startSection( getReportString( "report.summary.build.title" ) ); startTable(); tableHeader( new String[]{getReportString( "report.summary.field" ), getReportString( "report.summary.value" )} ); tableRow( new String[]{getReportString( "report.summary.build.groupid" ), project.getGroupId()} ); tableRow( new String[]{getReportString( "report.summary.build.artifactid" ), project.getArtifactId()} ); tableRow( new String[]{getReportString( "report.summary.build.version" ), project.getVersion()} ); tableRow( new String[]{getReportString( "report.summary.build.type" ), project.getPackaging()} ); endTable(); endSection(); endSection(); }
@Override public Organization get( Model model ) { return model.getOrganization(); }
@Override public void set( Model model, Organization value ) { model.setOrganization( value ); }
protected InfoDescriptor createInfoDescriptor( InfoDescriptor info ) { if ( this.project == null ) { return info; } if ( info.getVersion() == null ) { info.setVersion( this.project.getVersion() ); } if ( info.getTitle() == null ) { info.setTitle( this.project.getArtifactId() ); } if ( info.getDescription() == null ) { info.setDescription( this.project.getDescription() ); } ContactDescriptor contact = info.getContact(); if ( contact == null ) { Organization organization = this.project.getOrganization(); if ( organization != null ) { contact = new ContactDescriptor(); contact.setUrl( organization.getUrl() ); contact.setName( organization.getName() ); info.setContact( contact ); } else { String url = Util.getTrimmed( this.project.getUrl() ); if ( !url.isEmpty() ) { contact = new ContactDescriptor(); contact.setUrl( url ); String name = Util.getTrimmed( this.project.getName() ); if ( name.isEmpty() ) { name = Util.getTrimmed( this.project.getArtifactId() ); } contact.setName( name ); info.setContact( contact ); } else { List<Developer> developers = this.project.getDevelopers(); if ( ( developers != null ) && ( !developers.isEmpty() ) ) { contact = new ContactDescriptor(); Developer developer = developers.get( 0 ); contact.setUrl( Util.getTrimmed( developer.getUrl() ) ); contact.setEmail( Util.getTrimmed( developer.getEmail() ) ); contact.setName( Util.getTrimmed( developer.getName() ) ); info.setContact( contact ); } } } } LicenseDescriptor serviceLicense = info.getLicense(); if ( serviceLicense == null ) { List<org.apache.maven.model.License> licenses = this.project.getLicenses(); if ( ( licenses != null ) && ( !licenses.isEmpty() ) ) { serviceLicense = new LicenseDescriptor(); org.apache.maven.model.License projectLicense = licenses.get( 0 ); serviceLicense.setName( projectLicense.getName() ); serviceLicense.setUrl( projectLicense.getUrl() ); info.setLicense( serviceLicense ); } } return info; }
public void setOrganization( Organization organization ) { getModel().setOrganization( organization ); }
public Organization getOrganization() { return getModel().getOrganization(); }
protected void mergeOrganization( Organization target, Organization source, boolean sourceDominant, Map<Object, Object> context ) { mergeOrganization_Name( target, source, sourceDominant, context ); mergeOrganization_Url( target, source, sourceDominant, context ); }
public boolean equals( Organization o1, Organization o2 ) { return compare( o1, o2 ) == 0; }
@Override public void setOrganization(final Organization organization) { getDelegate().setOrganization(organization); }
@Override public Organization getOrganization() { return getDelegate().getOrganization(); }
public void setOrganization( Organization organization ) { }
/** Replies the organization of this artifact. * * @return the organization of this artifact. */ public Organization getOrganization() { return this.organization; }
Organization replaceOrganization( Organization organization );
void visitOrganization( Organization organization );